paypal / ipn-code-samples

Other
562 stars 486 forks source link

PHP: IPN postback sometimes "INVALID" but "VERIFIED" most of the time. Tried everything #161

Closed BarbzYHOOL closed 4 years ago

BarbzYHOOL commented 4 years ago

General information

Issue description

In 90% of the payments I have no issue. But sometimes I receive payment and Paypal returns "INVALID" to my listener. I have no idea why, I've spent 3 full days on this. I have modified my code to follow exactly https://developer.paypal.com/docs/ipn/integration-guide/IPNTesting/#receive-an-invalid-message then I adapted my code to use what is in the samples and it's the same result. I have set UTF-8 on my paypal settings too. I have set rawurlencode / rawurldecode.

I get HTTP code 200 in my IPN history log even when "INVALID". I also receive the money.

Here is the transaction that keeps failing even when I resend it to test again (note: it takes forever to reach my site).

  1. Sent from paypal to my site (i found these in the ipn history log): https://pastebin.com/LJtxHaYp
  2. Received on my site with file_get_contents('php://input'); as in the examples: https://pastebin.com/Cj2FtSp2
  3. Sent back to paypal: https://pastebin.com/2kjhB9T4

As you can see, the order is different from what is logged in the IPN history log, but I doubt it's related at all since it's working fine in 90% of the cases. The only things that are a bit suspicious are the , in the payment_date and the line return/break in the address but they are encoded.

@overint can you help with this maybe? (i'm so desperate, sorry, but I used parts of your code)