woocommerce-paypal-payments/modules.local/ppcp-button/resources/js/modules/OnApproveHandler/onApproveForPayNow.js

23 lines
653 B
JavaScript
Raw Normal View History

const onApprove = (context, errorHandler) => {
return (data, actions) => {
return fetch(context.config.ajax.approve_order.endpoint, {
method: 'POST',
body: JSON.stringify({
nonce: context.config.ajax.approve_order.nonce,
order_id:data.orderID
})
}).then((res)=>{
return res.json();
}).then((data)=>{
if (!data.success) {
2020-07-15 11:15:07 +03:00
errorHandler.message(data.data);
2020-07-16 12:16:06 +03:00
return actions.restart();
}
document.querySelector('#place_order').click()
});
}
}
export default onApprove;