【发布时间】:2021-10-20 10:17:02
【问题描述】:
我正在按如下方式构建此付款请求对象
paymentRequest: 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']
并在 html 中使用这个 paymentRequest 如下
<google-pay-button
environment="TEST"
buttonType="buy"
buttonColor="black"
[paymentRequest]="paymentRequest"
(loadpaymentdata)="onLoadPaymentData($event)"
(error)="onError($event)"
[paymentAuthorizedCallback]="onPaymentDataAuthorized"></google-pay-button>
我的问题:
我想动态添加请求对象内的属性。例如,我想在某些情况下单独添加属性“billingAddressRequired = true”,而在其他情况下我不需要它。所以我的请求对象将不包含“billingAddressRequired”属性。
【问题讨论】:
标签: angular typescript google-pay