woocommerce-paypal-payments/modules/ppcp-button/resources/js/modules/OnApproveHandler/onApproveForContinue.js
Alex P 23cb96e6f9 Explicitly send cookies in fetch
Not sent by default in old browsers
2022-09-09 16:28:58 +03:00

26 lines
825 B
JavaScript

const onApprove = (context, errorHandler) => {
return (data, actions) => {
return fetch(context.config.ajax.approve_order.endpoint, {
method: 'POST',
credentials: 'same-origin',
body: JSON.stringify({
nonce: context.config.ajax.approve_order.nonce,
order_id:data.orderID,
funding_source: window.ppcpFundingSource,
})
}).then((res)=>{
return res.json();
}).then((data)=>{
if (!data.success) {
errorHandler.genericError();
return actions.restart().catch(err => {
errorHandler.genericError();
});
}
location.href = context.config.redirect;
});
}
}
export default onApprove;