Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Locale independent totalPrice #3863

Merged

Conversation

vlad-roid
Copy link
Contributor

Summary

Fixes a major issue with Google Pay returning code 10, developer error, because totalPrice is being displayed in Eastern Arabic numerals when the locale is set to Arabic. This caused payment attempts to fail on multiple real devices.

Motivation

The Google Pay API only supports Arabic numerals 0-9, not Eastern Arabic numerals ٠-٩.

Use case:
Given my locale is set to ar_AE,
When I use Stripe's GooglePayJsonFactory.createPaymentDataRequest,
And send the JSON body to the Google Pay SDK via PaymentsClient.loadPaymentData(PaymentDataRequest.fromJson(...),
Then it should accept it without issues.
However, the Google Pay SDK call currently fails with error code 10, "developer error".

Example JSON that's sent to Google Pay currently and fails as per above:

{"apiVersion":2,"apiVersionMinor":0,"allowedPaymentMethods":[{"type":"CARD","parameters":{"allowedAuthMethods":["PAN_ONLY","CRYPTOGRAM_3DS"],"allowedCardNetworks":["AMEX","DISCOVER","MASTERCARD","VISA","JCB"]},"tokenizationSpecification":{"type":"PAYMENT_GATEWAY","parameters":{"gateway":"stripe","stripe:version":"2020-03-02","stripe:publishableKey":"..."}}}],"transactionInfo":{"currencyCode":"USD","totalPriceStatus":"FINAL","totalPrice":"٥.٠٠","checkoutOption":"COMPLETE_IMMEDIATE_PURCHASE"},"emailRequired":false,"merchantInfo":{"merchantName":"..."}}

Testing

Added test: PayWithGoogleUtilsTest.getPriceString_whenLocaleWithArabicNumerals_returnsExpectedValue

Without applying the bug fix, the test will fail as below:

value of: getPriceString(...)
expected: 1.00
but was : ١.٠٠
Expected :1.00
Actual   :١.٠٠

at com.stripe.android.PayWithGoogleUtilsTest.getPriceString_whenLocaleWithArabicNumerals_returnsExpectedValue(PayWithGoogleUtilsTest.kt:61)

…se totalPrice is being displayed in Eastern Arabic numerals when the locale is set to Arabic
@vlad-roid vlad-roid changed the title Locale independent total price Locale independent totalPrice Jun 21, 2021
@CLAassistant
Copy link

CLAassistant commented Jun 22, 2021

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

@brnunes-stripe brnunes-stripe left a comment

Choose a reason for hiding this comment

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

Thank you for fixing!

@brnunes-stripe brnunes-stripe merged commit d5bb2e7 into stripe:master Jun 22, 2021
mshafrir-stripe pushed a commit that referenced this pull request Jul 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants