[PHP]PayPal IPN Script

Joined
Aug 6, 2009
Messages
2,133
Reaction score
433
I have been asked few times about how my script works with paypal ipn. So here it is. Short explanation and example.


[Behind Scenes]
Ok so here is approximetly what happens:

  1. Customer/Player visits your web-site and clicks donate button. Now you can add custom field to button code with name "custom" and then in that hidden input variable you can put user id, or his character id, or whatever you want. Example below...
    PHP:
    <input type="hidden" name="custom" value="XXX">
  2. Once donation/payment is complete on paypal web-site, paypal will send IPN message to specified script.
  3. From then on your script receives information from paypal, resembles it a bit and sends back to paypal for verification.
  4. If everything is ok, paypal will return VERIFIED string.
  5. From here we check if it was verified.
  6. Then if payment status was completed or canceled/reversed
  7. If completed do one thing, if reversed then do another.
Thats is simple enough I guess.

Here is a script itself.
Click here (pastebin)

Also here is a full list of paypal post variables.
Click here (paypal)

P.S. You have to make a button yourself
P.P.S. You have to activate IPN and set IPN link yourself as well
P.P.P.S. You and only you are responsible for the use of the script provided in this topic.
 
Sucks you cannot test it on Paypal Sandbox. They don't send out POST or GET variables anymore. What the ****. o:
 
Sucks you cannot test it on Paypal Sandbox. They don't send out POST or GET variables anymore. What the ****. o:

What? That's not true. It was and still is, functioning for me. The sandbox is meant to replicate that of a production environment, so it should send out the necessary notification variables. If it doesn't, it's perhaps due to an invalid notify URL. Bear in mind that you do not need to set the notify URL via your account IPN, you can set it for individual scripts via, "notify_url". You are also required to have a Premier or Business account to utilise PayPal's IPN.
 
Last edited:
You can check this script via paypal sandbox but you have to change the connect url in script. I would tell it to you but I don't remember it.

Script is fully functional is notification url is set, ipn must be activated.

As I said everything is function, you can create variables for post vars and use script right away.

---------- Post added at 01:24 PM ---------- Previous post was at 01:16 PM ----------

More info:
There is function called write2LogFile.
It can be used to write a log of successful donation, dispute, whatever you want. By default it saves to file mylog.txt in same directory as a script.

Usage is simple:
PHP:
write2LogFile( $messageString );
 
Ah thanks, im guessing this would work with most things not just luna?
 
I know i am not allowed to bump sorry for that but i got one question and since i can't use PM function yet, can this be done with any type of account at paypal?
 
I know i am not allowed to bump sorry for that but i got one question and since i can't use PM function yet, can this be done with any type of account at paypal?

As far as I know there are no restrictions. Or there weren't any last time I used PayPal IPN.

At first I had personal account and worked just fine, then switched to business and still worked without problems. But it was two months ago or more.
 
Back