Simple Paypal IPN examples? [closed]

2020-02-17 09:26发布

问题:

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 8 years ago.

I would like to have a text input form with a submit button that goes to paypal, upon payment the contents of the form should go in a mysql database..

This sounds trivial, but I'm having such a hard time with paypal's IPN.

Can anyone point in me in the right direction?

Thanks!

回答1:

PayPal has some sample code on their website. However the bigger problem you'll face is that the user will probably want a real-time response. This is usually done by processing the PDT data that is submitted to your site when the user clicks the link to return to your site. At some point later PayPal will post to your IPN url similar data. You need to avoid processing the data twice.

Also the data in question is only PayPal's data about the transaction. It does not contain arbitrary data. You should probably record the customer's order before sending them to paypal, or else look for a pass-through variable. For example, when creating a billing agreement, there is a variable called custom which is passed back to you as you created it. You can store an order id or whatever you want in that variable. Be careful to validate its contents to make sure it's still correct for the transaction details.



回答2:

You don't, and can't, get the entire contents of the form back from Paypal. What you will get is a postback to the address you sent in the "return" field. The best way to pass arbitrary information through the process from your form to the postback is in the "item_number" field (preferably by using it as an ID in your database linked to whatever information you want to track).



回答3:

I know this question was already answered years ago, but for those who stumble upon it in the future...

I found this class + example to be particularly useful, so much so that I've re-used it for countless projects: http://www.micahcarrick.com/php-paypal-ipn-integration-class.html

Update: The page is offline now, but there's an archived version here which still has a working download link: https://web.archive.org/web/20140210202247/http://www.micahcarrick.com/php-paypal-ipn-integration-class.html

And here's a direct link to the archived download: https://web.archive.org/web/20140210202247/http://www.micahcarrick.com/files/paypal-1.3.0.zip

From the archived page, the author also links to a new version of his library, which is probably the better option now: https://github.com/Quixotix/PHP-PayPal-IPN



回答4:

This PHP sample should help you get started with IPN.

Here you can find the PHP API for PayPal, which might be useful even though it doesn't include sample that deals with IPN.



回答5:

You will find some examples of IPN Script if you follow this link

https://paypaltech.com/SG2/

Just select your programming language and the type of script that you are loonking for.



回答6:

Am guessing what you want is to make a form that when the user clicks the submit button is taken to paypal and then back to your site where you can get YOUR form's content?

I haven't see people do this, what I've seen people do is that when the user submits the form they are taken to a script to process the form and in that script they are redirected to paypal which is where they pay, you can then use IPN to process paypal's response.