Repository navigation
feat(paypal): charge an invoice in its billing currency when the operator chooses to - #189
Open
ertugrulkeyvan wants to merge 3 commits into
Open
ertugrulkeyvan wants to merge 3 commits into
ertugrulkeyvan wants to merge 3 commits into
Conversation
This branch has not been deployed
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
PayPal gets the "Charge in the invoice's billing currency" option that Stripe (#172) and Mollie (#182) have. It is off by default.
When a customer is billed in another currency (Setup > Currencies), the invoice shows that currency at a rate frozen on the invoice. A shop pricing in euros that bills a customer in zloty shows that customer zł43.00 for a €10.00 invoice. PayPal charged €10.00 and left the conversion to the customer's bank. With the option on, PayPal charges zł43.00, the amount on the invoice.
What changes with the option on, for an invoice whose billing currency PayPal takes:
capture()and unattended renewals from a stored PayPal account (chargeStoredMethod) are charged the same way. A caller that names a currency keeps it.What stays the same:
Unlike Stripe and Mollie, nothing about the conversion is written on the PayPal order. The browser builds the order, so nothing on it could be believed. What a capture is worth is worked out again from the invoice when it is captured, and from the recorded payment when it is refunded.
A note for operators, in the setting's description and in
docs/guides/payment-gateways.md: the PayPal account must accept payments in those currencies (Payment receiving preferences). Otherwise PayPal holds them as pending, and the invoice stays unpaid until they are accepted.How
PayPalModule:billingCharge(): currency, value and rate, or null.BILLING_CURRENCIES: PayPal's list, fetched 2026-10-12.verifyInvoiceCapture($invoice, $captureId)andcaptureCurrency($invoice).recordedAmount()andbilledRefund().GatewayWebhookController::paypalCapture: usesverifyInvoiceCapture()when the module has it.processWebhook(): looks the invoice up from the reference before verifying.The work is split into three commits: the module and the controller, the docs, and the tests.
Tests
tests/Feature/PayPalBillingCurrencyTest.php, 14 tests, all against faked responses:Ten of them fail on
main.PayPalCaptureCurrencyTest,PayPalTokenisationTestandPayPalWebhookSecurityTestpass unchanged (67).Full suite: 4171 passed. The one failure is the
CurrencyAndBackupTestdb backup test, which fails onmaintoo in my local setup.