mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-03 08:37:53 +08:00
Merge pull request #2390 from woocommerce/PCP-3313-can-not-pay-with-google-pay-from-block-cart-and-block-checkout-page
Google Pay: Fix issuse with data.paymentSource being undefined (3313)
This commit is contained in:
commit
879831d487
7 changed files with 15 additions and 23 deletions
|
@ -87,18 +87,20 @@ const PayPalComponent = ({
|
|||
|
||||
const createOrder = async (data, actions) => {
|
||||
try {
|
||||
const requestBody = {
|
||||
nonce: config.scriptData.ajax.create_order.nonce,
|
||||
bn_code: '',
|
||||
context: config.scriptData.context,
|
||||
payment_method: 'ppcp-gateway',
|
||||
funding_source: window.ppcpFundingSource ?? 'paypal',
|
||||
createaccount: false,
|
||||
...(data?.paymentSource && { payment_source: data.paymentSource })
|
||||
};
|
||||
|
||||
const res = await fetch(config.scriptData.ajax.create_order.endpoint, {
|
||||
method: 'POST',
|
||||
credentials: 'same-origin',
|
||||
body: JSON.stringify({
|
||||
nonce: config.scriptData.ajax.create_order.nonce,
|
||||
bn_code: '',
|
||||
context: config.scriptData.context,
|
||||
payment_method: 'ppcp-gateway',
|
||||
funding_source: window.ppcpFundingSource ?? 'paypal',
|
||||
createaccount: false,
|
||||
payment_source: data.paymentSource
|
||||
}),
|
||||
body: JSON.stringify(requestBody),
|
||||
});
|
||||
|
||||
const json = await res.json();
|
||||
|
|
|
@ -18,7 +18,8 @@ class BaseHandler {
|
|||
}
|
||||
|
||||
shippingAllowed() {
|
||||
return true;
|
||||
// Status of the shipping settings in WooCommerce.
|
||||
return this.buttonConfig.shipping.configured;
|
||||
}
|
||||
|
||||
transactionInfo() {
|
||||
|
|
|
@ -2,10 +2,6 @@ import BaseHandler from "./BaseHandler";
|
|||
|
||||
class CheckoutBlockHandler extends BaseHandler{
|
||||
|
||||
shippingAllowed() {
|
||||
return false;
|
||||
}
|
||||
|
||||
createOrder() {
|
||||
return this.externalHandler.createOrder();
|
||||
}
|
||||
|
|
|
@ -6,10 +6,6 @@ import FormValidator from "../../../../ppcp-button/resources/js/modules/Helper/F
|
|||
|
||||
class CheckoutHandler extends BaseHandler {
|
||||
|
||||
shippingAllowed() {
|
||||
return false;
|
||||
}
|
||||
|
||||
transactionInfo() {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
|
||||
|
|
|
@ -12,10 +12,6 @@ class PayNowHandler extends BaseHandler {
|
|||
return true;
|
||||
}
|
||||
|
||||
shippingAllowed() {
|
||||
return false;
|
||||
}
|
||||
|
||||
transactionInfo() {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
const data = this.ppcpConfig['pay_now'];
|
||||
|
|
|
@ -279,7 +279,7 @@ class GooglepayButton {
|
|||
updatedData.total_str = transactionInfo.totalPrice;
|
||||
|
||||
// Handle unserviceable address.
|
||||
if(!updatedData.shipping_options || !updatedData.shipping_options.shippingOptions.length) {
|
||||
if (!(updatedData.shipping_options?.shippingOptions?.length)) {
|
||||
paymentDataRequestUpdate.error = this.unserviceableShippingAddressError();
|
||||
resolve(paymentDataRequestUpdate);
|
||||
return;
|
||||
|
|
|
@ -412,6 +412,7 @@ class Button implements ButtonInterface {
|
|||
'enabled' => $this->settings->has( 'googlepay_button_shipping_enabled' )
|
||||
? boolval( $this->settings->get( 'googlepay_button_shipping_enabled' ) )
|
||||
: false,
|
||||
'configured' => wc_shipping_enabled() && wc_get_shipping_method_count( false, true ) > 0,
|
||||
);
|
||||
|
||||
if ( $shipping['enabled'] ) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue