Skip to content

Convert Google Pay amounts using the currency's exponent - #977

Draft
Max Harrison (maxharrison) wants to merge 4 commits into
masterfrom
google-pay-currency-exponent
Draft

Convert Google Pay amounts using the currency's exponent#977
Max Harrison (maxharrison) wants to merge 4 commits into
masterfrom
google-pay-currency-exponent

Conversation

@maxharrison

@maxharrison Max Harrison (maxharrison) commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

buildPaymentRequest always divided minor-unit amounts by 100, 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.

@changeset-bot

changeset-bot Bot commented Aug 12, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 5f5e299

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@evervault/ui-components Major
@evervault/ui-components-e2e-tests Patch

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

@ana-maksimovskikh ana-maksimovskikh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! Thanks, Max 🙏

@maxharrison
Max Harrison (maxharrison) force-pushed the google-pay-currency-exponent branch 2 times, most recently from 0a67013 to c1b52bd Compare August 18, 2026 09:40
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.
@maxharrison

Max Harrison (maxharrison) commented Aug 20, 2026

Copy link
Copy Markdown
Contributor Author

Updated the changeset to major and added coverage for a zero JPY total when lineItems is omitted

@maxharrison

Copy link
Copy Markdown
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants