Google Pay: Fix issuse with data.paymentSource being undefined and the shipping allowed boolean being hardcoded

This commit is contained in:
Daniel Dudzic 2024-07-03 12:29:29 +02:00
parent 167c2c6883
commit e1bdc64248
No known key found for this signature in database
GPG key ID: 31B40D33E3465483
7 changed files with 15 additions and 23 deletions

View file

@ -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();