Instant Payment Notification
IPN can be used to manage and customize a variety of PayPal-enabled APIs and communications, including:
- Customize your website's response to customer purchases in real-time
- Track customers via IPN "pass through" variables
- Deliver access keys for software downloads and other digital goods
- Automate your fulfillment operations
- Track affiliate sales and commissions
- Store transaction information in your own database.
Instant Payment Notification allows you to integrate your PayPal payments with your website's back-end operations, so you get immediate notification and authentication of the PayPal payments you receive.
How It Works
When a customer makes a payment to you, PayPal will post a notification to your server at a URL you specify. Included in this notification will be all of your customer's payment information (e.g. customer name, amount) as well as a piece of encrypted code. When your server receives a notification, it will then post the information, including the encrypted code, back to a secure PayPal URL. PayPal will authenticate the transaction by checking the encrypted string. This post-back of the IPN data to PayPal prevents "spoofing," so you can be sure that the IPN came from PayPal. Upon verification, PayPal will send confirmation of its validity back to your server.
Note: To activate Instant Payment Notification, you will need to enter the URL at which you would like to receive the notification posts from your Profile.
After you have activated Instant Payment Notification, your server will be sent a notification every time you receive a payment, this notification will be sent as a hidden "FORM POST" to the URL you specified, and will include all of the payment information. The FORM variables for the notification are listed at the bottom of this page.
Each time you receive an IPN from PayPal, you must complete the Notification Validation process described below before fulfilling the order. Verifying the information listed will ensure that the transaction is legitimate.
Notification Validation
To ensure that a payment has been made into your PayPal account, you must verify that the email address used as your "receiver_email" has been registered and confirmed in your PayPal account.
Once your server has received the Instant Payment Notification, you will need to confirm it by constructing an HTTP POST to PayPal. Your POST should be sent to https://www.paypal.com/cgi-bin/webscr
You must post all of the form variables you received exactly as you received them. You will also need to append a variable named "cmd" with the value "_notify-validate" (e.g. cmd=_notify-validate) to the POST string.
PayPal will respond to the post with a single word, "VERIFIED" or "INVALID", in the body of the response. When you receive a VERIFIED response, you need to perform several checks before fulfilling the order:
- Confirm that the "payment_status" is "Completed," since IPNs are also sent for other results such as "Pending" or "Failed"
- Check that the "txn_id" is not a duplicate to prevent a fraudster from using reusing an old, completed transaction
- Validate that the "receiver_email" is an email address registered in your PayPal account, to prevent the payment from being sent to a fraudster's account
- Check other transaction details such as the item number and price to confirm that the price has not been changed
Once you have completed the above checks, you may update your database with the IPN data and process the purchase.
If you receive an "INVALID" notification, it should be treated as suspicious and be investigated.
IPN Variables
For a complete list of all IPN variables and detailed instructions on how to use Instant Payment Notification, please refer to the Website Payments Standard Integration Guide (PDF, 4.6 MB, March 2008)
CREATE JSP PAGE - SHOPPING CARTCreate jsp called submitToPaypal.jsp Copy below jsp code page. Call this page at time of checkout.
submitToPaypal.jsp
Create PaypalIPN action .java file or page .jsp and call below method on return from paypal for Notification Validation
No comments:
Post a Comment