I have followed the "Basic Integration" from Paypal here : PayPal Checkout
I have tested it with sandbox "buyer" and "facilator" transactions works fine and button too.
How could I make the Paypal javascript below send the POST value I already have on the page to another page PHP if success for example ?
Here is Paypal button code :
<div id="paypal-button-container" align="center"></div>
<script>
paypal.Buttons({
style: {
layout: 'vertical',
color: 'blue',
shape: 'rect',
label: 'paypal',
},
createOrder: function(data, actions) {
return actions.order.create({
purchase_units: [{
amount: {
value: '<?php echo $total_total_euro_photo ?>'
}
}]
});
},
onApprove: function(data, actions) {
return actions.order.capture().then(function(details) {
alert('Transaction completed by ' + details.payer.name.given_name);
// Call your server to save the transaction
return fetch('/paypal-transaction-complete', {
method: 'post',
headers: {
'content-type': 'application/json'
},
body: JSON.stringify({
orderID: data.orderID
})
});
});
}
}).render('#paypal-button-container');
</script>
In the approve function it is writed // Call your server to save the transaction
Can I put there some code that is execute in background exemple savecommande.php?somevalue:anothervalue:etc ? If it could submit the form on the current page it would works too after transaction is successfull.
Some help would be very much appriciate.