woocommerce-paypal-payments/modules.local/ppcp-button/resources/js/modules/OnApproveHandler/onApproveForPayNow.js
2020-07-16 13:14:35 +03:00

22 lines
653 B
JavaScript

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) {
errorHandler.message(data.data);
return actions.restart();
}
document.querySelector('#place_order').click()
});
}
}
export default onApprove;