mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-01 07:02:48 +08:00
46 lines
1.2 KiB
JavaScript
46 lines
1.2 KiB
JavaScript
window.addEventListener('load', function() {
|
|
|
|
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()
|
|
});
|
|
});
|
|
|
|
/*
|
|
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);
|
|
}
|
|
|
|
*/
|
|
});
|