Send email, when paypal payment is made

2019-09-15 19:03发布

问题:

I searched the internet, but didn't find anything relevant for this. I want to make a script which automatically sends an email to the customer, when that customer makes a payment to my Paypal account.

To do this, I want to fetch 3 things from Paypal after successful payments, 1. E-Mail ID of customer, 2. Amount Paid , 3. Product name

Any ideas would be highly appreciated.

回答1:

This question is very open, in short yes you can do what you are asking for. The information you can retrieve is highly dependant on what you are using to generate the original payment request. Check out the services here:

https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/howto_overview

I highly recommend using IPN to initialize the email, why? Payment Data Transfer (PDT) is highly unreliable because it relies on the customer returning to your site after their purchase (which doesn't always happen).

How does IPN work? Paypal lets a script on your site know that a payment has been made, sending a bunch of order information. It is then your scripts job to post that data back to Paypal servers so that you can VERIFY that the data is authentic. Then you can do what you want with it.

Read about IPN here:

https://www.paypal.com/ipn

Depending on the data given at time of purchase you should be able to get everything you want from the IPN response, you can see the variables here.

https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_html_IPNandPDTVariables