mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
🐛 Fix critical Google Pay error
This commit is contained in:
parent
fe39793e9a
commit
b4cd6bb121
1 changed files with 27 additions and 1 deletions
|
@ -515,7 +515,9 @@ class GooglepayButton extends PaymentButton {
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
paymentDataRequestUpdate.newShippingOptionParameters =
|
paymentDataRequestUpdate.newShippingOptionParameters =
|
||||||
updatedData.shipping_options;
|
this.sanitizeShippingOptions(
|
||||||
|
updatedData.shipping_options
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( updatedData.total && hasRealCart ) {
|
if ( updatedData.total && hasRealCart ) {
|
||||||
|
@ -541,6 +543,30 @@ class GooglepayButton extends PaymentButton {
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Google Pay throws an error, when the shippingOptions entries contain
|
||||||
|
* custom properties. This function strips unsupported properties from the
|
||||||
|
* provided ajax response.
|
||||||
|
*
|
||||||
|
* @param {Object} responseData Data returned from the ajax endpoint.
|
||||||
|
* @return {Object} Sanitized object.
|
||||||
|
*/
|
||||||
|
sanitizeShippingOptions( responseData ) {
|
||||||
|
const cleanOptions = [];
|
||||||
|
|
||||||
|
responseData.shippingOptions.forEach( ( item ) => {
|
||||||
|
cleanOptions.push( {
|
||||||
|
id: item.id,
|
||||||
|
label: item.label,
|
||||||
|
description: item.description,
|
||||||
|
} );
|
||||||
|
} );
|
||||||
|
|
||||||
|
responseData.shippingOptions = cleanOptions;
|
||||||
|
|
||||||
|
return { ...responseData, shippingOptions: cleanOptions };
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the shipping costs as numeric value.
|
* Returns the shipping costs as numeric value.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue