Wednesday, 27 January 2021

Paypal Smart Button: how to redirect to a PHP page after successfull payment?

I'm trying to integrate paypal payment into my web site.

EDIT:

After a sucessfull payment I want to redirect to a PHP page to manipulate payment data, for instance: Saving to db transaction and payment id, payer email , send email etc.

So this is my "onApprove" function:

onApprove: function(data, actions) {

  var EXECUTE_URL = 'https://www.mywebsite.com/actions/paymentsuccess.php';

  return fetch(EXECUTE_URL, {
    method: 'post',
    headers: {
      'content-type': 'application/json'
    },
    body: JSON.stringify({
      paymentID: data.paymentID,
      payerID: data.payerID,
      payerEmail: data.payerEmail,
      payerName: data.payerName,
      payerPhone: data.payerPhone
    })
  });
},

How to call a PHP page (maybe with a POST ) and pass all payment data, and elaborate that page (i don't need to stay to the payment page) ?

Thanks



from Paypal Smart Button: how to redirect to a PHP page after successfull payment?

No comments:

Post a Comment