Hi Try This:
paypal.Buttons({
debug: true,
style: {
label: 'pay'
},
createOrder: function(data, actions) {
return actions.order.create({
'PayPal-Partner-Attribution-Id': 'xxxx',
purchase_units: [{
amount: {
value: ''
}
}]
});
},
onApprove: function(data, actions) {
// show loader on screen whilst wating to redirect
$('.checkout-loader').addClass('active');
// excute php script
var EXECUTE_URL = '/checkout/paypal/execute';
// Authorize the transaction
actions.order.capture().then(function(details) {
// Call your server to validate and capture the transaction
return fetch(EXECUTE_URL, {
method: 'post',
headers: {
'content-type': 'application/json'
},
body: JSON.stringify({
orderID : data.orderID
})
}).then(function(response){
// redirect to the completed page if paid
window.location.href = '/checkout/completed';
});
});
}
}).render('#paypal-button-container'); If this does nt work for you let me know. Kenny
... View more