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

use consistent country code from config model in callback payment req… #1

Merged
merged 1 commit into from
Oct 27, 2022

Conversation

josh-carter
Copy link
Contributor

@josh-carter josh-carter commented Oct 26, 2022

Summary

Fixes unexpected developer error when the customers' address is from a different country to the configured "Default Country" for the store.
When Google Pay is initialised we have to provide the countryCode as part of GooglePays "PaymentRequest", countryCode is optional but required for EAA countries. We use the stores' Default Country, but in our onPaymentDataChanged callback function we resolve it by returning a new updated "PaymentRequest: object like below:

...
{
    newShippingOptionParameters: {
        defaultSelectedOptionId: ...,
        shippingOptions: [{...}]
    },
    newTransactionInfo: {
        displayItems: [
            {
                label: 'Shipping',
                type: 'LINE_ITEM',
                price: xx,
                status: 'FINAL'
            }
        ],
            currencyCode: ...,
            totalPriceStatus: 'FINAL',
            totalPrice: xx,
            totalPriceLabel: 'Total',
            countryCode: ...
    }
...

The countryCode in the newTransactionInfo object here was being set from the customers shipping address rather than the stores countryCode, and hence we were getting the error reported around the initial paymentRequest having a different countryCode to the callback paymentRequest object. I've updated this callback country code so that it uses the same countryCode used when initialising (from the configModel)

The countryCode should be (taken from Google Pays docs):

The ISO 3166-1 alpha-2 country code where the transaction is processed. This property is required for merchants who process transactions in European Economic Area (EEA) countries and any other countries that are subject to Strong Customer Authentication (SCA). Merchants must specify the acquirer bank country code.

So I'd say it makes sense to use the stores' country for the countryCode and this update making it consistent fixes the error reported because we use a consistent countryCode in the PaymentRequest throughout the Google Pay flow.

Tested scenarios

  • Google Pay guest/customer transactions from PDP/Minicart using a GooglePay shipping address with a different country to the stores configured default country - all worked as expected
  • Regular E2E tests of ApplePay/GooglePay on PDP, Cart, Minicart

Fixed issue: Unexpected Developer Error when using GooglePay as a Customer with a different shipping address country than the stores' configured "Default Country"

@candemiralp candemiralp merged commit 7d1456c into develop Oct 27, 2022
@candemiralp candemiralp deleted the bugfix/use-consistent-country-code branch October 27, 2022 14:16
@peterojo peterojo mentioned this pull request Dec 20, 2022
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.

4 participants