SitePoint Sponsor

User Tag List

Results 1 to 7 of 7

Thread: Paypal subscription (API?)

  1. #1
    SitePoint Zealot
    Join Date
    Sep 2006
    Posts
    190
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Paypal subscription (API?)

    I'm wondering how to pass variables after payment has been made via Paypal.

    Basically it's a membership sign up form.

    1. A member fills out a sign up form and click submit.(i.e. name, address, email)
    2. After submitting the form it takes you to paypal where the member pays for the membership.
    3. After paying, it redirects the user to a page and at the same time the user submitted info(name, address, email) is added to the database
    4. After all this is done, the member can login to the membership page.

    I'm not sure how this API stuff works on Paypal.

    Does anyone have a solution to this? The payment can be on Paypal's site. I'm not looking for to have the payment on my site. I just wonder how the variables from the submitted form can be inserted to the database after payment has been done.(incase they don't pay, nothing will be inserted to the database)

    Thanks

    Bjorn

  2. #2
    SitePoint Wizard
    Join Date
    Mar 2008
    Posts
    1,149
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Look into PayPal's IPN API: http://www.paypal.com/ipn

  3. #3
    SitePoint Zealot
    Join Date
    Sep 2006
    Posts
    190
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    do you have a code example for this? Paypal explains it kind of complicated.

  4. #4
    SitePoint Addict
    Join Date
    Jul 2008
    Location
    sudo rm -rf /
    Posts
    386
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Check https://developer.paypal.com for more info.

  5. #5
    SitePoint Guru
    Join Date
    Jan 2005
    Location
    heaven
    Posts
    953
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by coolisdude View Post
    do you have a code example for this? Paypal explains it kind of complicated.
    Google to the rescue!
    Creativity knows no other restraint than the
    confines of a small mind.
    - Me
    Geekly Humor
    Oh baby! Check out the design patterns on that framework!

  6. #6
    SitePoint Wizard wheeler's Avatar
    Join Date
    Mar 2006
    Location
    Gold Coast, Australia
    Posts
    1,369
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    take a look at this: http://www.phpclasses.org/browse/package/2249.html

    It's a class to interact with Paypal IPN.

    As suggested there is alot of reading to do (and the Paypal docs kindof suck) but basically Paypal will notify a url on your site that you select (eg. mysite.com/paypal.php?paid=true&id=45) when the payment has occurred. Then you run the necessary code to update your data.
    Studiotime - Time Management for Web Developers
    to-do's, messages, invoicing, reporting - 30 day free trial!
    Thomas Multimedia Web Development

  7. #7
    SitePoint Enthusiast Jmz's Avatar
    Join Date
    Jun 2005
    Posts
    93
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've been looking at this for the past month or so. It's pretty fiddly to start with, but when you get your head around it, it's not so bad. I'm presuming here that you have a basic idea of how the ipn api works.

    Firstly, I would advise you to use a script such as the one by Micah Carrick to get you started which you can find here.

    You will have to edit the code for the form and also tell it what you want to do for each status it sends back to your server. An example is below:

    PHP Code:
    if ($p->ipn_data['txn_type'] == "subscr_signup"){
    // A user has subscribed to the service            
    }elseif ($p->ipn_data['txn_type'] == "subscr_cancel"){
    //A user has cancelled the subscription

    All of the users information is sent to your server too. So if you want to get the users email, you could use the code:

    PHP Code:
    $p->ipn_data['payer_email'
    There is a complete reference to all the variables here.

    Finally, you really need to know howto use the paypal sandbox to test your system before you even think about going live.

Bookmarks

Posting Permissions

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