Here is how I am constructing the payment request object:
paymentRequestObject: google.payments.api.PaymentDataRequest = {
apiVersion: 2,
apiVersionMinor: 0,
allowedPaymentMethods: [
{
type: 'CARD',
parameters: {
allowedAuthMethods: ['PAN_ONLY', 'CRYPTOGRAM_3DS'],
allowedCardNetworks: ['AMEX', 'VISA', 'MASTERCARD'],
billingAddressRequired: true,
billingAddressParameters:{
format:'FULL',
phoneNumberRequired:true
}
},
tokenizationSpecification: {
type: 'PAYMENT_GATEWAY',
parameters: {
gateway: 'example',
gatewayMerchantId: 'exampleGatewayMerchantId'
}
}
}
],
merchantInfo: {
merchantId: '12345678901234567890',
merchantName: 'Demo Merchant'
},
transactionInfo: {
totalPriceStatus: 'FINAL',
totalPriceLabel: 'Total',
totalPrice: '0.10',
currencyCode: 'EUR',
countryCode: 'BE'
},
callbackIntents: ['PAYMENT_AUTHORIZATION']
And here is how I am using the payment request in my HTML code:
<google-pay-button
environment="TEST"
buttonType="buy"
buttonColor="black"
[paymentRequest]="paymentRequestObject"
(loadpaymentdata)="onLoadPaymentData($event)"
(error)="onError($event)"
[paymentAuthorizedCallback]="onPaymentDataAuthorized"></google-pay-button>
My Inquiry:
I am looking to dynamically add properties inside the request object. For example, I may need to include the property "billingAddressRequired = true" in certain cases only while excluding it in others. How can I achieve this flexibility with my request object?