Paypal SandBox IPN always returns INVALID
Got it working using the basic sample code 4b,
Cleared
$ipnNotificationUrl = "";
from the basic sample code as I had a value in there which I added myself,Created a seller account instead of a business pro account in sandbox,
Set the seller account to enable the ipn url,
Used the following PHP 5.2 sample code for the ipn listener
Added the 2 lines into the listener, as described here, the 2 lines can be seen below:
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
PHP How to Get the Base Domain/Url
How to Use Two Submit Buttons, and Differentiate Between Which One Was Used to Submit the Form
Get Date for Monday and Friday for the Current Week (Php)
Simple Comet Example Using PHP and Jquery
PHP Get Previous Array Element Knowing Current Array Key
Laravel - How to Get Current User in Appserviceprovider
Inserting Now() into Database with Codeigniter's Active Record
PHP Datetime Microseconds Always Returns 0
Url Encode Equivalent in Ruby on Rails
PHP Rename Array Keys in Multidimensional Array
How to Send Notification to Android from PHP
Customize Addresses Fields on Woocommerce My Account and Checkout
File_Get_Contents() How to Fix Error "Failed to Open Stream", "No Such File"
Php: Get List of All Filenames Contained Within My Images Directory
SQL & PHP - Which Is Faster MySQL_Num_Rows() or 'Select Count()'