|PayPal API PHP Integration|
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.
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.
The following parameters in your form should be of use, then:
- return (guess what it is!)
- 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.
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
|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.
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).