woocommerce-paypal-payments/modules/ppcp-wc-gateway/resources/js/oxxo.js

47 lines
1.2 KiB
JavaScript
Raw Normal View History

2022-07-12 14:44:08 +02:00
window.addEventListener('load', function() {
2022-07-13 16:11:33 +02:00
const oxxoButton = document.getElementById('ppcp-oxxo');
oxxoButton?.addEventListener('click', (event) => {
event.preventDefault();
fetch(OXXOConfig.oxxo_endpoint, {
method: 'POST',
body: JSON.stringify({
nonce: OXXOConfig.oxxo_nonce,
})
}).then((res)=>{
return res.json();
}).then((data)=>{
if (!data.success) {
alert('Could not update signup buttons: ' + JSON.stringify(data));
return;
}
window.open(
data.data.payer_action,
'_blank',
'popup'
);
document.querySelector('#place_order').click()
});
});
/*
2022-07-12 14:44:08 +02:00
const oxxoButton = document.getElementById('ppcp-oxxo-payer-action');
if(oxxoButton) {
oxxoButton.addEventListener('click', (event) => {
event.preventDefault();
window.open(
oxxoButton.href,
'_blank',
'popup'
);
});
window.open(oxxoButton.href);
}
2022-07-13 16:11:33 +02:00
*/
2022-07-12 14:44:08 +02:00
});