2020-07-16 13:14:35 +03:00
|
|
|
const onApprove = (context, errorHandler) => {
|
2020-04-08 16:23:33 +03:00
|
|
|
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();
|
2020-04-08 16:23:33 +03:00
|
|
|
}
|
2020-04-09 09:33:18 +03:00
|
|
|
document.querySelector('#place_order').click()
|
2020-04-08 16:23:33 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-23 17:05:44 +03:00
|
|
|
export default onApprove;
|