IPN Verification Error

I integrate paypal with IPN (I have done this on many websites and have never had this problem before.) I use PHP Integration Class for Paypal IPN - Micah Carrick.

I am testing it on the sandbox tab. All the data I receive from paypal is fine. But the IPN check is always checked.

I used the same class in many projects, but never got this problem, please help me, what could be causing this problem.

This is what I get in the log file:

[10/29/2012 5:02 AM] - FAIL: IPN Validation Failed. IPN POST Vars from Paypal: mc_gross=10.00, protection_eligibility=Eligible, address_status=confirmed, payer_id=LZ3J5RXT7ZRSW, tax=0.00, address_street=1 Main St, payment_date=03:02:41 Oct 29, 2012 PDT, payment_status=Completed, charset=windows-1252, address_zip=95131, first_name=AProfessionals, mc_fee=0.59, address_country_code=US, address_name=AProfessionals Inc, notify_version=3.7, custom=, payer_status=verified, business=brian_1351496665_biz@a1professionals.com , address_country=United States, address_city=San Jose, quantity=1, verify_sign=AV0bkFkV43dlmXuqlWjyHTfWE.SBANTBgLiHNABcsVQsMvyhdLQg8mTi, payer_email=harry_1351496900_per@a1professionals.com , txn_id=9ES74523RB953760X, payment_type=instant, last_name=Inc, address_state=CA, receiver_email=brian_1351496665_biz@a1professionals.com , payment_fee=0.59, receiver_id=NEV59MNUMBET6, txn_type=web_accept, item_name=Paypal Test Transaction, mc_currency=USD, item_number=, residence_country=US, test_ipn=1, handling_amount=0.00, transaction_subject=Paypal Test Transaction, payment_gross=10.00, shipping=0.00, ipn_track_id=74d5b2446aded, IPN Response from Paypal Server: HTTP/1.0 302 Found Location: https://www.sandbox.paypal.com Server: BigIP Connection: close Content-Length: 0 
+4
source share
2 answers

In my experience, these are 3 common reasons why IPN does not validate.

1) cmd=_notify-validate added, not added ... this can sometimes cause problems. Therefore, instead of:

  $post_string = ''; foreach ($_POST as $field=>$value) { $this->ipn_data["$field"] = $value; $post_string .= $field.'='.urlencode(stripslashes($value)).'&'; } $post_string.="cmd=_notify-validate"; // append ipn command 

Follow the code on this page: https://www.x.com/developers/PayPal/documentation-tools/code-sample/216623

 // read the post from PayPal system and add 'cmd' $req = 'cmd=_notify-validate'; if(function_exists('get_magic_quotes_gpc')) { $get_magic_quotes_exists = true; } foreach ($myPost as $key => $value) { if($get_magic_quotes_exists == true && get_magic_quotes_gpc() == 1) { $value = urlencode(stripslashes($value)); } else { $value = urlencode($value); } $req .= "&$key=$value"; } 

2) The address is multi-line.

 // read post data from PayPal and add 'cmd' $req = 'cmd=_notify-validate'; foreach ($_POST as $key => $value) { // put line feeds back to CR+LF as that how PayPal sends them out // otherwise multi-line data will be rejected as INVALID $value = str_replace("\n", "\r\n", $value); $this->ipn_data_arr[$key] = $value; $req .= '&'.$key.'='.urlencode(stripslashes($value)); } 

You can verify this yourself by going to your paypal acc and going from 1 line to 2 lines and using your acc for the transaction. 2 lines fail without $value = str_replace("\n", "\r\n", $value); , we all wonder why PayPal did not have this line in their sample code ...

3) The user has non-English characters in their name, address, etc. (may not apply to you, but since we're in the subject)

see http://blog.tentaclesoftware.com/archive/2010/04/09/87.aspx main thing:

 Log into PayPal Click the 'Profile' link in the menu bar under 'My Account' Click the 'Language Encoding' link under the 'Selling Preferences' column Click 'More Options' Set 'Encoding' to 'UTF-8' Click 'Save' 

If you notice that there is a common theme in all 3: data order, data encoding, etc., if only one small thing is slightly different, it will not work. So, if this is not so, then for these reasons. Find and check the fields whose data is likely to cause problems ... non-standard characters, hidden metadata, etc.

+3
source

one changed in paypal library

// open connection with paypal

  $fp = fsockopen('ssl://'.$url_parsed[host],"443",$err_num,$err_str,30); //$fp = fsockopen($url_parsed[host],"80",$err_num,$err_str,30); 
+2
source

Source: https://habr.com/ru/post/1442711/


All Articles