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