Repository navigation
[PB-6857]:feat/enable payments in INR & BRL - #405
Merged
Merged
Conversation
3 of 7 tasks
|
xabg2
approved these changes
Sep 22, 2026
This branch was successfully 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.


Description
The purpose of this PR is to implement everything we need on the backend to enable payments in both INR and BRL.
To do this, the first step was to add INR and BRL to AllowedFiatCurrencies and to the allowedCurrency list in the payments controller, so both currencies are accepted by the API.
Second, we introduced the file paymentMethods.ts. Previously the payment methods were decided inline with a ternary that returned ['card', 'paypal', 'klarna'] for EUR lifetime and ['card', 'paypal'] for everything else, also ['card', 'paypal'] for subscriptions. Since we now have a larger list of currencies and methods, we moved this into the PAYMENT_METHODS constant, which defines the methods to offer based on currency and interval, since not all of them are available in every country (for instance, PayPal does not support INR). Continuing in this file both UPI and PIX have per-transaction limits. We define these in PAYMENT_METHOD_LIMITS and apply them in getPaymentMethodTypes. This matters because Stripe validates every method listed in payment_method_types against the invoice amount when the invoice is finalized, regardless of which one the customer actually picked. Leaving upi on a high-value invoice fails the whole invoice with "Invoice amount_due is too large to pay with upi" and takes the card payment down with it. When the limits filter everything out, we fall back to ['card'], so the list is never empty.
We also needed to update the payment.service.ts file:
finalizeInvoice, we read again, recalculate the payment methods based on the actual total, and update it if the list has changed. This has to be done before finalizing the invoice, because that’s when Stripe checks the payment methods against the amount, otherwise, a lifetime plan costing 150,000 INR would hit that limit with UPI still on the list, and Stripe would reject the entire invoice, including the card payment. This was a small bug I encountered while testing.Description
This PR is related with this one so the testing process is explained there