mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 18:16:38 +08:00
26 lines
825 B
JavaScript
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;
|