Get payer action from gateway response and use it for opening the modal

This commit is contained in:
dinamiko 2022-07-15 12:13:38 +02:00
parent d248a278be
commit 859c99aa49
3 changed files with 27 additions and 32 deletions

View file

@ -1,15 +1,18 @@
window.addEventListener('load', function() {
const oxxoButton = document.getElementById('ppcp-oxxo-payer-action');
if(oxxoButton) {
oxxoButton.addEventListener('click', (event) => {
event.preventDefault();
window.open(
oxxoButton.href,
'_blank',
'popup'
);
document.addEventListener(
'DOMContentLoaded',
function() {
jQuery('form.checkout').on('checkout_place_order_success', function(type, data) {
if(data.payer_action && data.payer_action !== '') {
const width = screen.width / 2;
const height = screen.height / 2;
const left = (screen.width / 2) - (width / 2);
const top = (screen.height / 2) - (height / 2);
window.open(
data.payer_action,
'_blank',
'popup, width=' + width + ', height=' + height + ', top=' + top + ', left=' + left
);
}
});
window.open(oxxoButton.href);
}
});
);