mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-08 21:52:55 +08:00
Add GooglePay shipping support POC
This commit is contained in:
parent
b96e556257
commit
ad08480b67
3 changed files with 21 additions and 8 deletions
|
@ -178,7 +178,6 @@ class ApplePayButton implements ButtonInterface {
|
||||||
$data['products'][0] = 'PAYMENT_METHODS';
|
$data['products'][0] = 'PAYMENT_METHODS';
|
||||||
}
|
}
|
||||||
$data['capabilities'][] = 'APPLE_PAY';
|
$data['capabilities'][] = 'APPLE_PAY';
|
||||||
$nonce = $data['operations'][0]['api_integration_preference']['rest_api_integration']['first_party_details']['seller_nonce'];
|
|
||||||
$data['operations'][] = array(
|
$data['operations'][] = array(
|
||||||
'operation' => 'API_INTEGRATION',
|
'operation' => 'API_INTEGRATION',
|
||||||
'api_integration_preference' => array(
|
'api_integration_preference' => array(
|
||||||
|
@ -190,7 +189,6 @@ class ApplePayButton implements ButtonInterface {
|
||||||
'PAYMENT',
|
'PAYMENT',
|
||||||
'REFUND',
|
'REFUND',
|
||||||
),
|
),
|
||||||
'seller_nonce' => $nonce,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
@ -104,7 +104,7 @@ class GooglepayButton {
|
||||||
environment: this.buttonConfig.environment,
|
environment: this.buttonConfig.environment,
|
||||||
// add merchant info maybe
|
// add merchant info maybe
|
||||||
paymentDataCallbacks: {
|
paymentDataCallbacks: {
|
||||||
//onPaymentDataChanged: onPaymentDataChanged,
|
onPaymentDataChanged: this.onPaymentDataChanged.bind(this),
|
||||||
onPaymentAuthorized: this.onPaymentAuthorized.bind(this),
|
onPaymentAuthorized: this.onPaymentAuthorized.bind(this),
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -186,15 +186,34 @@ class GooglepayButton {
|
||||||
paymentDataRequest.allowedPaymentMethods = googlePayConfig.allowedPaymentMethods;
|
paymentDataRequest.allowedPaymentMethods = googlePayConfig.allowedPaymentMethods;
|
||||||
paymentDataRequest.transactionInfo = await this.contextHandler.transactionInfo();
|
paymentDataRequest.transactionInfo = await this.contextHandler.transactionInfo();
|
||||||
paymentDataRequest.merchantInfo = googlePayConfig.merchantInfo;
|
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;
|
return paymentDataRequest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getGoogleShippingAddressParameters() {
|
||||||
|
return {
|
||||||
|
allowedCountryCodes: ['US'],
|
||||||
|
phoneNumberRequired: true
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
//------------------------
|
//------------------------
|
||||||
// Payment process
|
// Payment process
|
||||||
//------------------------
|
//------------------------
|
||||||
|
|
||||||
|
onPaymentDataChanged(paymentData) {
|
||||||
|
console.log('[GooglePayButton] onPaymentDataChanged', this.context);
|
||||||
|
console.log('[GooglePayButton] paymentData', paymentData);
|
||||||
|
}
|
||||||
|
|
||||||
onPaymentAuthorized(paymentData) {
|
onPaymentAuthorized(paymentData) {
|
||||||
console.log('[GooglePayButton] onPaymentAuthorized', this.context);
|
console.log('[GooglePayButton] onPaymentAuthorized', this.context);
|
||||||
return this.processPayment(paymentData);
|
return this.processPayment(paymentData);
|
||||||
|
|
|
@ -198,9 +198,6 @@ class Button implements ButtonInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
$data['capabilities'][] = 'GOOGLE_PAY';
|
$data['capabilities'][] = 'GOOGLE_PAY';
|
||||||
|
|
||||||
$nonce = $data['operations'][0]['api_integration_preference']['rest_api_integration']['first_party_details']['seller_nonce'];
|
|
||||||
|
|
||||||
$data['operations'][] = array(
|
$data['operations'][] = array(
|
||||||
'operation' => 'API_INTEGRATION',
|
'operation' => 'API_INTEGRATION',
|
||||||
'api_integration_preference' => array(
|
'api_integration_preference' => array(
|
||||||
|
@ -212,7 +209,6 @@ class Button implements ButtonInterface {
|
||||||
'PAYMENT',
|
'PAYMENT',
|
||||||
'REFUND',
|
'REFUND',
|
||||||
),
|
),
|
||||||
'seller_nonce' => $nonce,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue