woocommerce-paypal-payments/modules/ppcp-button/resources/js/modules/OnApproveHandler/onApproveForContinue.js
Emili Castells Guasch 5ceb39c9e0 Fix code style
2023-03-22 17:00:16 +01:00

29 lines
914 B
JavaScript

const onApprove = (context, errorHandler) => {
return (data, actions) => {
return fetch(context.config.ajax.approve_order.endpoint, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
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;