I have added my button script from Paypal to my php file and it outputs the buttons nicely.
I need $myvariable to be at the end of the return url where paypal sends someone back to my site upon successful payment.
This return url will be a constant but the $myvariable will be different with every customer.
ex: https://example.com/index3.php?processid=$myvariable $myvariable will be a 7 digit unique reference number.
I believe I must use Paypals "rm parameter" and have "return url" turned on at paypal developer.
The following was recommended in a 2011 post. But I don't know where to put it. <INPUT TYPE="hidden" NAME="return" value="<?php echo 'example.com/complete.php?option='.$theoption ?>">
Please, what code do I add to the following Paypal button code to get a return as described.
HERE IS MY BUTTON CODE FROM PAYPAL ("example.com" in script is paypal)
<div id="smart-button-container">
<div style="text-align: center;">
<div id="paypal-button-container"></div>
</div>
</div>
<script src="https://www.example.com/sdk/js?client-id=sb&enable-funding=venmo¤cy=USD" data-sdk-integration-source="button-factory"></script>
<script>
function initPayPalButton() {
paypal.Buttons({
style: {
shape: 'rect',
color: 'gold',
layout: 'vertical',
label: 'paypal',
},
createOrder: function(data, actions) {
return actions.order.create({
purchase_units: [{"description":"1 \".csv\" file download","amount":{"currency_code":"USD","value":19.95}}]
});
},
onApprove: function(data, actions) {
return actions.order.capture().then(function(orderData) {
// Full available details
console.log('Capture result', orderData, JSON.stringify(orderData, null, 2));
// Show a success message within this page, e.g.
const element = document.getElementById('paypal-button-container');
element.innerHTML = '';
element.innerHTML = '<h3>Thank you for your payment!</h3>';
// Or go to another URL: actions.redirect('thank_you.html');
});
},
onError: function(err) {
console.log(err);
}
}).render('#paypal-button-container');
}
initPayPalButton();
</script>