use consistent country code from config model in callback payment req… #1
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.
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: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):
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
Fixed issue: Unexpected Developer Error when using GooglePay as a Customer with a different shipping address country than the stores' configured "Default Country"