Paypal Sandbox Ipn Always Returns Invalid

Paypal SandBox IPN always returns INVALID

  1. Got it working using the basic sample code 4b,

  2. Cleared $ipnNotificationUrl = ""; from the basic sample code as I had a value in there which I added myself,

  3. Created a seller account instead of a business pro account in sandbox,

  4. Set the seller account to enable the ipn url,

  5. Used the following PHP 5.2 sample code for the ipn listener

  6. Added the 2 lines into the listener, as described here, the 2 lines can be seen below:

  7. Downloaded the cacert.pem certificate to my server from here and put it in the same directory as the ipn listener:

The 2 lines mentioned in point 6:

CURLOPT_SSL_VERIFYPEER => TRUE,
CURLOPT_CAINFO => 'cacert.pem',

I have no idea why the sandbox business pro account does not let me set an ipn url, but the seller account does.

Paypal sandbox IPN return INVALID

Thank you guys for your reply.
ohhh I solved it at last.

Actually in notify URL I also added a username parameter. Paypal want the parameter values for IPN same as it return to the servlet.(You can get it as req.getParameterNames()). As I have username parameter extra, which is not known to paypal. Paypal was returning INVALID.

PayPal IPN Always Returns INVALID

I've spent almost 2 days on this issue and thought I would share with people what have worked for me hopefully It can help a few others who faced the same issue.

Problem

PayPal IPN simulator gives INVALID IPN response always.

Solution

When simulating change the payment_date in simulator fields to NULL and everything should start working if your setup is correct.

PayPal sandbox IPN validation always return INVALID

AARRRRGH!!!!!!!! I have only dirty words to PayPal!!!!!!! The problem was in... (drumroll... tadam!) in the charset field! No, its value must be the same as IPN sent it to you, but... in UPPERCASE! IPN sends it in lowercase! So you MUST modify IPN data to verify it successfully regardless manual tells us to return data back "as-is". PayPal bug?

So my final working code is: (using HTTP_Request2)

protected function verifyPostData() {
$this->request->setBody('cmd=_notify-validate&' . str_replace('=utf-8', '=UTF-8', file_get_contents('php://input')));
$response = $this->request->send();
if ($response->getStatus() != 200) {
throw new \RuntimeException("Transaction data verification request failed with code {$response->getStatus()}");
}
$content = trim($response->getBody());
return ($content == 'VERIFIED');
}

How I did it: I sent the PDT request for this transaction and obtained transaction data. Then I made field to field comparison of PDT and IPN data. PDT have no some IPN fields such as auth, verify_sign and test_ipn. But all other fields seems must be the same. And the only difference was in the characters case of the charset field. Then I tried to verify modified data and unexpectedly it become successful!

Php PayPal IPN returns INVALID

For the record, this url seems to be working fine: https://www.paypal.com/cgi-bin/webscr



Related Topics



Leave a reply



Submit