Losing POSTed data after return from payment gateway

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
voltrader
Forum Contributor
Posts: 223
Joined: Wed Jul 07, 2004 12:44 pm
Location: SF Bay Area

Losing POSTed data after return from payment gateway

Post by voltrader »

I have a credit card billing form which requires data to be posted securely to the payment gateway. Upon a successful payment transaction, the gateway forwards the user to a billing confirmation page.

That's fine, however, the billing confirmation page requires some data from the credit card billing form to create a transaction record.

i.e.
page 1: payment gateway information, website transaction number
page 2: -> off-site payment gateway ->
page 3: I need the website transaction number

What can I do to send the website transaction number from page 1 to page 3 to tell my script that the transaction has been successful?

I assume I can save the sessionhash (stored in a cookie) and the transaction number in a temporary table. When the user returns from the payment gateway after a successful transaction, I can look up the sessionhash table and retrieve the transaction number.
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post by infolock »

that, or you could save it in a database and verify it that way. or, as you said, use a session cookie. you could also, #3, just pass it page to page. page 1 posts to page 2 which uses that data and passes it to page 3 via url or post.
User avatar
voltrader
Forum Contributor
Posts: 223
Joined: Wed Jul 07, 2004 12:44 pm
Location: SF Bay Area

Post by voltrader »

I would really like to pass it from page to page, since my php/mysql skills are nought, but the info goes to a CC payment gateway and there's no way (I think) of passing it from there to page 3.

Argh... I was hoping for an easier soln.
User avatar
voltrader
Forum Contributor
Posts: 223
Joined: Wed Jul 07, 2004 12:44 pm
Location: SF Bay Area

Post by voltrader »

Thanks for the advice... I managed to get it working for the most part.

1. I save sessionhash and transaction information from billing page into a temphash table.

2. Info is posted to credit card gateway, which redirects to billing confirmation page upon successful payment.

3. At billing confirmation page, I look up the sessionhash stored in $_cookie against what I saved in the db and pick up the required info.

This seems to work -- most of the time :-(

When I close the browser and reopen it, I print_r($_cookie['sessionhash'] to make sure it's there. It is, and it's is displayed in step 1.

I fill in details, send data to CC gateway, which works fine as well.

However, when I get to step 3, the print_r($_cookie) yields only "Object".

To make things more mysterious, when I try to register and pay again, this time without closing browser, steps 1 and 2 are fine again, and so is step 3!
Post Reply