Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PayPal IPN sends multiple notifications hours after payment completed

In the IPN docs there is this line:

To handle the possibility of transmission and receipt delays or failures, the IPN message service implements a retry mechanism that resends messages at various intervals until you acknowledge that the message has successfully been received.

IPN is sending the same notification 9 times... What do I need to send back? There are no errors in my script. If I use the IPN simulator I get the following message:

IPN sent successfully

It would seem then that the simulator can tell the message is being sent correctly but the real notifier can't?

I am using sandbox if that makes any difference?

Do I need to print anything upon receipt of the notification?

like image 926
user1326244 Avatar asked Oct 30 '13 12:10

user1326244


2 Answers

No need to worry about the multiple notification. First send back the IPN message then process it. While processing check the check that txn_id has not been previously processed. If it is already processed, it is a duplicate IPN message from the Paypal and you can ignore the processing. For more info refer the pdf file: IPNGuide.pdf

EDIT: Do I need to print anything upon receipt of the notification? No need to print anything but if you want to log the details you can log them. From the pdf file I mentioned above(Page number 10)

Your listener must respond to each message, whether or not you intend to do anything with it. If you do not respond, PayPal assumes that the message was not received and resends the message. PayPal continues to resend the message periodically until your listener sends the correct message back, although the interval between resent messages increases each time. The message can be resent for up to four days. This resend algorithm can lead to situations in which PayPal resends the IPN message while you are sending back the original message. In this case, you should send your response again, to cover the possibility that PayPal did not actually receive your response the first time. You should also ensure that you do not process the transaction associated with the message twice. IMPORTANT: PayPal expects to receive a response to an IPN message within 30 seconds. Your listener should not perform time-consuming operations, such as creating a process, before responding to the IPN message

See page number 19-20 Your listener software must

  • Wait for an HTTP post from PayPal.

  • Create a request that contains exactly the same IPN variables and values in the same order, preceded with cmd=_notify-validate.

  • Post the request to paypal.com or sandbox.paypal.com, depending on whether you are going live or testing your listener in the Sandbox.

  • Wait for a response from PayPal, which is either VERIFIED or INVALID.

  • If the response is VERIFIED, perform the following checks:

  • Confirm that the payment status is Completed. PayPal sends IPN messages for pending and denied payments as well; do not ship until the payment has cleared.

  • Use the transaction ID to verify that the transaction has not already been processed, which prevents duplicate transactions from being processed.

  • Typically, you store transaction IDs in a database so that you know you are only processing unique transactions.

  • Validate that the receiver’s email address is registered to you. This check provides additional protection against fraud.

  • Verify that the price, item description, and so on, match the transaction on your website. This check provides additional protection against fraud.

  • If the verified response passes the checks, take action based on the value of the txn_type variable if it exists; otherwise, take action based on the value of the reason_code variable.

  • If the response is INVALID, save the message for further investigation

like image 156
Damodaran Avatar answered Sep 28 '22 19:09

Damodaran


You have to reply with an empty 200 response to indicate to PayPal the IPN was received correctly after processing the response data as

public function yourIpnHandler(){
    //response verification and processing goes here


    header("HTTP/1.1 200 OK");
}

After getting an empty 200 response, PayPal will not send more responses as it understand that response is delivered successfully to ipn-handler.

like image 25
RAUSHAN KUMAR Avatar answered Sep 28 '22 17:09

RAUSHAN KUMAR