View Full Version : Getting Variables from PayPal

09-16-2011, 01:15 AM
I want to create a code that allows users to purchase something on paypal and then paypal sends me the transaction information and I store it in a mysql database for further use. I have a paypal account and have read some of the information on integrating this with my site, but I am having some problems understanding it. I have some knowledge of html, php, and mysql but would still consider myself a beginner.

So here's the sequence of pages I need help with in the order the customers would view them:

1. My "store" on my website with the option to purchase a product. The customer is logged in and there is a sessions variable with their email in it. They click a buy now button which takes them to paypal. (I don't need help coding this page, but as it is an important step in the process I included it)

2. Paypal website. I have one "product" for sale at a static price, you can purchase multiples of the product though. So here the user should be able to pay for the product and complete the transaction. (I can set this up through paypal myself as well, but once again included it because its an important step.)

3. Back to my website to the "Thank you for your business page." (This is the page I need help with). Here I would like to display to the customer the transaction id, amount of product purchased, and the price of transaction. I would then put the transaction id and amount of product into my database for later use. So I need help figuring out how to send the transaction id, amount of product, and total price from paypal to this page. The user will already be using a session so I will have their email for use in the database.

So my question is how do I get paypal to send variables (specifically the transactionid, amount of product, and total cost) to my webpage? And then how would I retrieve it (I can get items sent with POST, but I'm not sure if that is what paypal is using).


09-16-2011, 01:21 AM
Paypal has a fairly good tutorial on this here is the main link


the ipn listener is what you use to get the vars from paypal, they even have a code sample link on the bottom of that page.

it really depends on what your using website payments, or wsp pro or something else.

Also be careful if you need custom vars, it can be tricky, try to stick with the basic vars they provide for you.

the ipn guide at the bottom of that page will help you.

also set you up a sandbox account, it allows you to test as a live site but no real money changes hands.

to use it you will need to have a special form connection as well as a special var link in your ipn. the guide will help you with that.

then when your ready to go live you change both of those links to the live version and your off and running.

09-16-2011, 02:40 AM
Exactly what I was looking for! Thank you!