Add GooglePay shipping support POC

This commit is contained in:
Pedro Silva 2023-09-28 09:32:09 +01:00
parent b96e556257
commit ad08480b67
No known key found for this signature in database
GPG key ID: E2EE20C0669D24B3
3 changed files with 21 additions and 8 deletions

View file

@ -178,7 +178,6 @@ class ApplePayButton implements ButtonInterface {
$data['products'][0] = 'PAYMENT_METHODS';
}
$data['capabilities'][] = 'APPLE_PAY';
$nonce = $data['operations'][0]['api_integration_preference']['rest_api_integration']['first_party_details']['seller_nonce'];
$data['operations'][] = array(
'operation' => 'API_INTEGRATION',
'api_integration_preference' => array(
@ -190,7 +189,6 @@ class ApplePayButton implements ButtonInterface {
'PAYMENT',
'REFUND',
),
'seller_nonce' => $nonce,
),
),
),

View file

@ -104,7 +104,7 @@ class GooglepayButton {
environment: this.buttonConfig.environment,
// add merchant info maybe
paymentDataCallbacks: {
//onPaymentDataChanged: onPaymentDataChanged,
onPaymentDataChanged: this.onPaymentDataChanged.bind(this),
onPaymentAuthorized: this.onPaymentAuthorized.bind(this),
}
});
@ -186,15 +186,34 @@ class GooglepayButton {
paymentDataRequest.allowedPaymentMethods = googlePayConfig.allowedPaymentMethods;
paymentDataRequest.transactionInfo = await this.contextHandler.transactionInfo();
paymentDataRequest.merchantInfo = googlePayConfig.merchantInfo;
paymentDataRequest.callbackIntents = ['PAYMENT_AUTHORIZATION'];
//paymentDataRequest.callbackIntents = ['PAYMENT_AUTHORIZATION'];
paymentDataRequest.callbackIntents = ["SHIPPING_ADDRESS", "SHIPPING_OPTION", "PAYMENT_AUTHORIZATION"];
paymentDataRequest.shippingAddressRequired = true;
paymentDataRequest.shippingAddressParameters = this.getGoogleShippingAddressParameters();
paymentDataRequest.shippingOptionRequired = true;
return paymentDataRequest;
}
getGoogleShippingAddressParameters() {
return {
allowedCountryCodes: ['US'],
phoneNumberRequired: true
};
}
//------------------------
// Payment process
//------------------------
onPaymentDataChanged(paymentData) {
console.log('[GooglePayButton] onPaymentDataChanged', this.context);
console.log('[GooglePayButton] paymentData', paymentData);
}
onPaymentAuthorized(paymentData) {
console.log('[GooglePayButton] onPaymentAuthorized', this.context);
return this.processPayment(paymentData);

View file

@ -198,9 +198,6 @@ class Button implements ButtonInterface {
}
$data['capabilities'][] = 'GOOGLE_PAY';
$nonce = $data['operations'][0]['api_integration_preference']['rest_api_integration']['first_party_details']['seller_nonce'];
$data['operations'][] = array(
'operation' => 'API_INTEGRATION',
'api_integration_preference' => array(
@ -212,7 +209,6 @@ class Button implements ButtonInterface {
'PAYMENT',
'REFUND',
),
'seller_nonce' => $nonce,
),
),
),