Post by mediatechnology2 » Thu Oct 12, 2023 7:40 pm

PayPal IPN API Callback Fails, Orders Flagged "Cancelled"

This seems to be somewhat of a popular theme and I just discovered a new reason for the PayPal standard payments API callback to fail.

A recent store upgrade to 3.0.8 maintenance release in a test environment would properly handle the API callback. The store was put into production by renaming the path of it to the live store.

Then, "suddenly and without warning" PayPal orders would find themselves in the missing orders "jailhouse" as cancelled. A quick check of the server logs showed the listener URL being sent by PayPal to be corrupted:
/shop%0D%0A/index.php?route=extension/payment/pp_standard/callback
The correct path is:
shop/index.php?route=extension/payment/pp_standard/callback
A number of solutions to PayPal callback failures suggest checking PayPal. A visit to PayPal IPN settings showed no api callback address specified and I never recall setting one.

I checked the log at PayPal for a "failed" transaction (which financially completed) and it showed that the callback path was
/shop /index.php?route=extension/payment/pp_standard/callback
Note the extra space after /shop.

So I set PayPal's IPN to the correct path with no spaces and no added CR LF (%0D%0A) and ran a test purchase in sandbox. My test order was sent to missing orders jail and a check of the server log still showed a 404 response to the path
/shop%0D%0A/index.php?route=extension/payment/pp_standard/callback
Double-checking the PayPal IPN showed it to still be correct. It became obvious that the shop was using CURL to create the URL and that the api was overrding PayPal's internal IPN setting. Hmm...

Fast-forward to the following morning after a night's sleep. A quick inspection of /shop/config.php showed the following:
// HTTPS
define('HTTPS_SERVER', 'https://redactedshopname.com/shop
/');
Found it! Should be:
// HTTPS
define('HTTPS_SERVER', 'https://redactedshopname.com/shop/');
So this didn't occur "suddenly and without warning" it was of my own doing when I renamed the path /shop309 to /shop to take the store live. I added a CR LF to config.php

Moral of the story:
(1) Always check config.php for this type of problem.
(2) The payments module sends the callback URL to PayPal and it overrides PayPal settings.

New member

Posts

Joined
Wed Oct 26, 2022 11:24 pm
Who is online

Users browsing this forum: No registered users and 7 guests