Convert Google Pay amounts using the currency's exponent - #977
Draft
Max Harrison (maxharrison) wants to merge 4 commits into
Draft
Convert Google Pay amounts using the currency's exponent#977Max Harrison (maxharrison) wants to merge 4 commits into
Max Harrison (maxharrison) wants to merge 4 commits into
Conversation
🦋 Changeset detectedLatest commit: 5f5e299 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This was referenced Aug 12, 2026
ana-maksimovskikh
approved these changes
Aug 12, 2026
ana-maksimovskikh
left a comment
Contributor
There was a problem hiding this comment.
Good catch! Thanks, Max 🙏
Max Harrison (maxharrison)
force-pushed
the
google-pay-currency-exponent
branch
2 times, most recently
from
August 18, 2026 09:40
0a67013 to
c1b52bd
Compare
Google Pay carries at most two fraction digits, so the three-decimal currencies this branch started emitting in full (KWD, BHD, OMR, JOD, TND) never worked: 1.000 KWD was sent as "1.000" and rejected. It enforces the ceiling late. The request builds, the sheet opens, and only then does it fail with OR_BIBED_06, which tells the shopper the merchant cannot accept their payment. Verified on both clients. pay.js and a real Android device were each run over matched pairs on USD, KWD, BHD, OMR and TND: every price with three fraction digits failed and every two-digit twin completed. Play Services also quoted the rule it actually applies, `-?[0-9]*(\.[0-9][0-9]?)?`, which allows one digit where the docs say exactly two. So these currencies work down to hundredths of a major unit. Emit two digits for them and throw when the amount needs the third, rather than rounding to an amount nobody asked to be charged. Split formatMinorUnits out of formatTransactionAmount so the Google Pay caller can reduce precision itself. The cap stays out of the shared helper because it is a Google Pay limit; Apple Pay takes these currencies whole.
Max Harrison (maxharrison)
force-pushed
the
google-pay-currency-exponent
branch
from
August 18, 2026 12:37
c1b52bd to
99cc829
Compare
Contributor
Author
|
Updated the changeset to |
Contributor
Author
|
This PR corrects how minor units are handled of non-2-decimal currencies, but merchants that compensated for the old formatting must remove that workaround, so this change is held for the next major release. |
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.
buildPaymentRequestalways divided minor-unit amounts by100, so Google Pay showed zero-decimal currencies at one hundredth of their value and three-decimal currencies at ten times their value.It now formats totals and line items with each currency's exponent and rejects Google Pay amounts that require a third fractional digit, because Google Pay accepts at most two. This corrects the documented minor-unit contract, but merchants that compensated for the old formatting must remove that workaround, so this change is held for the next major release.