Performing a PHP action once when the page loads

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
Jennysaur
Forum Newbie
Posts: 4
Joined: Sat Mar 03, 2007 5:08 pm

Performing a PHP action once when the page loads

Post by Jennysaur »

Hi everybody! I'm new to this forum, and to PHP...(6 months strong and counting,) and I'm having a little issue trying to get a bit of my shopping cart script to work. I have to set it up so that my quantity drops by one once someone purchases an item, but the code goes outside the site to paypal, and it doesn't seem possible. I was thinking that I could have the update occur when the success page loads, but have not been able to figure that out. Any suggestions?

Thank you! 8O
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

Which PayPal API are you using? It should be returning control to your server after the transaction is successful.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Do you have any code that you could provide so we can what is happening?
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

There's something called a "callback" where paypal can optionally "POST" to a URL when a payment is successful, sort of a notification system. It's in the Paypal manual somewhere
Begby
Forum Regular
Posts: 575
Joined: Wed Dec 13, 2006 10:28 am

Post by Begby »

Yes, the paypal thingy is called PayPal IPN. You setup a post url where it will either post to a form, or send XML to a webservice. In the post is data about the order (depending on how your shopping cart is setup).

PayPal has really good documentation on it. They also have a nice developer sandbox and I think developer.paypal.com. That way you can setup a test cart and test out the IPN features with your script.
Post Reply