paypal / ipn-code-samples

Other
562 stars 486 forks source link

How to handle IPN for Money Request or Mobile Payment types. #143

Open solaceten opened 5 years ago

solaceten commented 5 years ago

we have a basic online shopping cart that receives IPN messages when an order is placed and paid for through PayPal - and this works fine with IPN coming back from PayPal to confirm the payment is completed etc.

However, when we use the PayPal "Request Money" option from within the PayPal dashboard, the IPN system then tries to send an IPN to our system IPN listener. This results in a HTTP response code 500 and a "failed" message in our PayPal IPN log file.

As a result, we are receiving the "PayPal Instant Payment Notification Warning" email from PayPal telling us the IPNs are failing. The only IPNs that are failing are the manual money request transaction IPNs.

What would be the best way to handle this? We don't need the IPNs for manual payment requests. Can we turn it off, or can we add something to our IPN listener to receive these messages but not do anything with them?

We are using the standard IPN listener (PHP) from the PayPal Github. Also, in the PayPal account IPN is turned on and set to our listener URL. Our shopping cart also sends the IPN URL to PayPal. I've also read through the developer documentation, but I'm none the wiser. My current thinking is to turn off IPN in the PayPal settings and just use the IPN notify command from within the script - but I assume this will mean we will then not be able to see any IPN history in our PayPal account?

overint commented 5 years ago

Also, in the PayPal account IPN is turned on and set to our listener URL. Our shopping cart also sends the IPN URL to PayPal.

You can turn off the account wide IPN notifications in your account settings, and you will still receive them correctly as long as it's set in the button/script creating the transaction.

You will still be able to see the IPN history regardless of what triggered it.

solaceten commented 5 years ago

Thanks for your comment and clarification. I have turned off IPN in the account settings page and we'll see what happens. However, just to note, when I turned off IPN, the IPN history page then shows this message:

The IPN feature is turned off. You must turn on IPN in order to create history data. (https://www.paypal.com/cgi-bin/webscr?cmd=_display-ipns-history)

Will I still be able to see IPN history on the above URL, even though it's turned off in PayPal settings?

overint commented 5 years ago

Will I still be able to see IPN history on the above URL, even though it's turned off in PayPal settings?

Hmm, maybe it's changed as I remember being able to see it without the account wide IPN on.

Have you considered getting one of the IPNs that fails from your IPN history and debbuging locally to figure out why it's causing your script to 500 (and fixing that)? You should be able to filter out Money Requests.

solaceten commented 5 years ago

Seems the IPN history is being recorded in Sandbox, even if IPN is disabled, but on the live PayPal, no recent IPN history :-( however, IPNs are being received to the script notify url, so it is working fine, just not recording the history.

solaceten commented 5 years ago

Update: as per this page: https://developer.paypal.com/docs/classic/ipn/integration-guide/IPNSetup/#dynamically-setting-the-notification-url

Note: The IPN message is always sent to your notification URL unless you have disabled the preference to receive IPN messages. Even though you have not enabled receiving IPN messages in your Profile or you have reset your preference by turning off IPN messages, PayPal still sends IPN messages to the notification URL you specify for a specific payment. IPN messages not sent because you disabled the preference in your Profile will appear in the IPN history when you enable receiving IPNs. After they appear in the history, you can choose whether to resend them.

TLDR; it only shows failed or "not sent" IPNs in history...... Why not show all ?

Very confusing......

overint commented 5 years ago

Unfortunately I don't work at PayPal, you would be best to send an email to the development support team.