mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-07 19:54:15 +08:00
Refactor to create PayPal order first
This commit is contained in:
parent
d248a278be
commit
09ef106a80
6 changed files with 204 additions and 51 deletions
|
@ -1,4 +1,33 @@
|
|||
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) => {
|
||||
|
@ -12,4 +41,6 @@ window.addEventListener('load', function() {
|
|||
|
||||
window.open(oxxoButton.href);
|
||||
}
|
||||
|
||||
*/
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue