If you want to use Google Pay on the web, you must also implement the 3D Secure 2 process via server-to-server if you are located within the European Union.
In particular, this means that you must transfer required data such as the billToCustomer and billingAddress JSON, for which you can obtain all required values directly from Google Pay.
Example to get a billing address in the response from Google:
const BillingAddressParameters = { "format": "FULL" };
const baseCardPaymentMethod = {
type: 'CARD',
parameters: {
allowedAuthMethods: allowedCardAuthMethods,
allowedCardNetworks: allowedCardNetworks,
billingAddressRequired: true,
billingAddressParameters: BillingAddressParameters
},
};
Example object from Google:
{
"apiVersion": 2,
"apiVersionMinor": 0,
"paymentMethodData": {
"description": "Mastercard •••• 8081",
"info": {
"billingAddress": {
"address1": "Teststraße 1",
"address2": "",
"address3": "",
"administrativeArea": "",
"countryCode": "DE",
"locality": "Bamberg",
"name": "Max Mustermann",
"postalCode": "96050",
"sortingCode": ""
},
"cardDetails": "8081",
"cardNetwork": "MASTERCARD"
},
"tokenizationData": {
"token": "examplePaymentMethodToken",
"type": "PAYMENT_GATEWAY"
},
"type": "CARD"
}
}
The mapping for billingAddress:
{
"city": paymentResponse.paymentMethodData.info.billingAddress.locality,
"country": {
"countryA3": convertToA3(paymentResponse.paymentMethodData.info.billingAddress.countryCode)
},
"addressLine1": {
"street": paymentResponse.paymentMethodData.info.billingAddress.address1
},
"postalCode": paymentResponse.paymentMethodData.info.billingAddress.postalCode
}
And for billToCustomer:
{
"consumer": {
"firstName": getFirstName(paymentResponse.paymentMethodData.info.billingAddress.name),
"lastName": getLastName(paymentResponse.paymentMethodData.info.billingAddress.name),
},
"email": (Not included in billingAddress)
}
Please note:
- Google returns the CountryCode in A2 format, but the banks' 3DS server needs it in A3, so a conversion function is required
- First and last names must also be separated as far as possible if they are to be obtained from the Google response object.
It is therefore advisable to obtain names and country codes from the shop whenever possible in order to simplify implementation and avoid errors.