Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    Regular Coder
    Join Date
    Jan 2006
    Posts
    189
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Automated Paypal reward

    I run an online game, and what i have now, is a donation system, where i say donate $10 and get an in-game reward.. but i have to do that manually right now, i have to check paypal, verify their email, and give out the reward... I KNOW there is a way to do this automatically.. but i dont know how.. how do i get paypal to redirect to one of my pages, and how do i carry variables through paypal to that page(ie: how much they paid)... Help would be greatly appreciated

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    Sounds like you want to use Paypal's IPN system (instant payment notification). It's a simple process in theory-- when a user uses your donate button and pays you a donation, Paypal will send a "post" http request to a designated PHP script (that you specify in your Paypal account profile) and that request contains detailed information about the donation. Inside that PHP script you can insert all the processing you need to in order to give the user the ingame reward.

    Paypal has tons of documentation on IPN... look in their help center for the details.

  • #3
    Regular Coder
    Join Date
    Jan 2006
    Posts
    189
    Thanks
    1
    Thanked 0 Times in 0 Posts
    alright, i know how to set it up now, thanks.. but.. how do i know what the variables are called? like.. is it $_POST['amount'] for the amount? or is it something else?

  • #4
    Regular Coder
    Join Date
    Jan 2007
    Posts
    217
    Thanks
    9
    Thanked 0 Times in 0 Posts
    They are listed in the help center. And you can test them out in your sandbox.

  • #5
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    I just happen to be working on this currently so I had this link handy:

    https://www.paypal.com/IntegrationCe...reference.html

  • #6
    Regular Coder
    Join Date
    Jan 2006
    Posts
    189
    Thanks
    1
    Thanked 0 Times in 0 Posts
    ok, i got what i needed... sort of.. when it redirects to the link.. whats to stop someone from changing the stuff around.. like.. i couldnt get it to work using the POST stuff in that page, so i had to resort to the GET values given in the link..

    The link:

    Code:
    http://playsovereignty.com/donated.php?tx=2UC44761HK104574L&st=Completed&amt=100.00&cc=USD&cm=&sig=ku2mN%2bqozkf4nYtvu3%2fvKvM3KMS%2fRCuu6cLbgPnxfVpoNl6DRCl1oKut%2bGqMaLbsAQCg8%2f5l9ZkHlAcdDNzrG%2b5bF2swzVbSg9iJodT%2bjDmTeNCDoxuoUlohlyO02yH3qEeMZhvq018GYrjqy6QnnDVsvG67zf1el%2f7j6y%2fLgiI%3d
    and the code to go along with(just for testing, not complete):

    PHP Code:
    if($_GET['st'] == "Completed"){

    $amount $_GET['amt'];

    $getitem floor($amount/10);

    echo 
    "You would get $getitem items!";

    This is to make it so that for every 10 dollars donated, you get an item... but.. whats to stop someone from simply refreshing, or changing then 'amt' value to '10000000'?

  • #7
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    Well that query string in the return URL is the PDT (Payment Data Transfer), not the IPN (Instant Payment Notification). Yes someone could monkey with the return URL, that's why it's more secure to use IPN.

  • #8
    Regular Coder
    Join Date
    Jan 2006
    Posts
    189
    Thanks
    1
    Thanked 0 Times in 0 Posts
    but... how do you use it.. i tried the snippet:

    PHP Code:

    if(isset($_POST['item_name'])){

    echo 
    "This works";


    and when it redirected to the page, nothing showed

  • #9
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    IPN is a separate POST request. It is outside the loop of the payment process. The POST request gets sent to a different script that you have to write to accept the IPN and process it. It has nothing to do with the return URL coming from Paypal.

    Read this page completely:

    https://www.paypal.com/IntegrationCenter/ic_ipn.html

    Then click on the "script generator" to get examples of how to handle the IPN request. (The scripts are terribly written but they do work.)

    Also this link may help:

    https://www.paypaldeveloper.com/pdn/...pn&thread.id=2

    And I just found this Paypal Summary which is pretty awesome:

    https://www.paypaldeveloper.com/pdn/...&thread.id=368
    Last edited by Fumigator; 09-05-2007 at 09:34 PM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •