views:

101

answers:

1

I'm not sure how to go about doing this.. I want to add a Paypal "buy now" button on my website and when a user pays I want to save the date they paid into the database using mysql.

How would this be possible?

+2  A: 

What you'll need to do is create a PayPal IPN script, which will cause PayPal to call upon a PHP script on your server every time you receive a payment. The full details are available on PayPal's website, but here's an overview of how it works:

Instant Payment Notification (IPN) is a message service that notifies you of events related to PayPal transactions. You can use it to automate back-office and administrative functions, such as fulfilling orders, tracking customers, and providing status and other information related to a transaction

You detect and process IPN messages with a listener, sometimes called a handler, which is a script or program that you write. It waits for messages and passes them to various back-end or administrative processes that respond the messages. PayPal provides sample code that you can modify to implement a listener that detects IPN messages.

The actions to take when your listener is notified of an event are specific to your needs. Examples of the kinds of actions you might take when your listener receives an IPN message include the following:

Trigger order fulfillment or enable media downloads when a check clears or a payment is made Update your list of customers Update accounting records Create specialized “to do” lists based on the kind of event You are typically notified of events by email as well, but the IPN message service enables you to automate your response to events. The following diagram shows how events can occur and how PayPal responds with IPN messages that it sends to your listener:

IPN

Josh