Remove MYR base currency check for refunds#13
Merged
Merged
Conversation
Removed the base currency check for MYR in the refund process. This because WHMCS latest version (9.0) have removed basecurrency option from $params
amirulazreen
approved these changes
Apr 23, 2026
…namespace consistency
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this change?
This PR implements a major architectural refactor transitioning the CHIP WHMCS module to a "Thin Gateway" architecture and introduces comprehensive multi-currency support.
Core Problem:
Previously, module logic was fragmented across multiple entry points (e.g.,
chip_cards.php,chip_fpx.php), leading to significant code duplication and maintenance overhead. Furthermore, the module was largely restricted to MYR-only logic, preventing merchants from accepting payments or processing automated refunds for invoices in other currencies without manual intervention.Technical Solution:
ChipGatewayclass using the Delegation Pattern. Individual gateway files and callback scripts are now thin wrappers that delegate to this central class, ensuring "DRY" (Don't Repeat Yourself) code.convertCurrency()across the entire transaction lifecycle.chip_config_validatenow dynamically fetches available payment methods from the CHIP API based on the "Convert to For Processing" currency setting.GET_LOCKnaming tochip_payment_$payment_idwith a 15-second timeout to prevent race conditions between webhooks and user redirects.$0.01floating-point tolerance check inChipAction::complete_paymentto handle minor rounding discrepancies inherent in currency conversion.declare(strict_types=1)across all core classes (api.php,action.php,gateway.php,exceptions.php).ChipAPIExceptionand upgraded Guzzle error handling to provide granular feedback for401 Unauthorizedand404 Not Foundstatuses.WHMCSSettingto reduce API overhead.Asana / Jira / Trello task link
How to test
composer lintlocally to ensure no PSR-12 violations.Potential Risks & Senior Review Items
ChipGateway::refundandChipAction::complete_payment. It is critical to verify that exchange rates are applied in the correct direction when moving betweeninvoice_currencyandprocessing_currency.abs($payment_amount - $amount) < 0.01handles standard two-decimal currencies. We should verify if this logic holds for zero-decimal currencies (like JPY) if the merchant's CHIP account supports them.declare(strict_types=1), verify that results fromCapsulequeries are explicitly cast where necessary (e.g.,(int)$params['convertto']or(float)$payment['payment']['amount']). Database drivers often return numeric strings which will trigger aTypeError.GET_LOCKimplementation inaction.phpto ensure the lock name is sufficiently unique and the 15-second timeout is appropriate for high-traffic environments.Is this PR warrant an automatic approval?
No. This PR involves critical changes to financial logic, database-level locking, and core architecture. Manual verification of accounting accuracy and automated refund logic is required before merging.
Images