Welcome to WebmasterWorld Guest from

Forum Moderators: buckworks

Message Too Old, No Replies

PayPal API PHP Integration



3:15 am on Sep 29, 2010 (gmt 0)

5+ Year Member

Hi guys,

I have a website now where people who want to pay with paypal, click on PayPal, and the form sends over what they are ordering. They enter in their info and then they pay on PayPal. Once they pay, they don't go back to my site.

I had a few questions:

1) How can I get PayPal to redirect them back to my site, so I can show them a "Thank you" page.

2) I have API access, does anyone know of a good "plug and play" PHP code example of PayPal API access (going through their documentation hurts my noob eyes).

I want to run affiliates through my store, so I need a way to get these guys to return to my site after payment so I can call conversion code, and also give out order numbers.

Thanks everyone


3:19 am on Sep 29, 2010 (gmt 0)

5+ Year Member

BTW, I know there is a Return URL. However, I need it to be dynamic, since I use the same paypal account for multiple sites (so I need to change the URL of the return url).

Also, need a way to pass some kind of identifier.



3:34 am on Sep 29, 2010 (gmt 0)

10+ Year Member

The following parameters in your form should be of use, then:
- return (guess what it is!)
- cancel_return
- rm which dictates how they return (values 0, 1 or 2 IIRC)
- either "custom" or "invoice" for the identifier to be returned. You can configure Paypal not to accept duplicate payments for the same "invoice" number

There's a PDF somewhere which details all the variables and is a bit less ugly than the HTML documentation.

Note that even if you do everything to have them return to your site, in many cases they won't:
- either because they did not have a Paypal account and it was suggested to them after payment that they should open one
- or because they didn't like the warning if you send them back to a non-secure page (depends on the value of rm)
- or simply because they don't feel like it for some reason

You should thus be prepared to store the payments in your DB, and display the tracking code on a future visit (and then flag the payment as "tracked"), or talk to your affiliate network(s) about batch processing or whatever solution they might have for you.

Of course, you should use IPN to receive notifications of the payments.



8:20 pm on Oct 1, 2010 (gmt 0)

WebmasterWorld Administrator ergophobe is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

Almost every open source shopping cart has a Paypal module. Those would be good starting points. The problem is that they are connecting the PP API with the cart API, which can make it hard to sort out if you don't know the cart API.

Also, try searching on "Paypal PHP class" - lots of options


5:53 pm on Oct 4, 2010 (gmt 0)

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member

so I need to change the URL of the return url

You can send this as a parameter in what you post to payPal. Have you found the samples? That's the fastest way to get up to speed.


10:28 am on Oct 5, 2010 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member

Best to setup the return URL at the application so you have flexibility to where you redirect the customer after order placement (different parameters etc).

Featured Threads

Hot Threads This Week

Hot Threads This Month