Daniel
Daniel

Reputation: 202

PHP Paypal "official" IPN listener not working correctly

I'm new to Paypal and I'm trying to use IPN to know when a transaction is complete. I've read the Paypal documentation for IPN, which provides some IPN listener code samples. I uploaded the PHP sample version (without any changes) to my server and I used the IPN simulator to generate a fake IPN message to the IPN listener. I was expecting that the IPN listener would successfully process the IPN message and the IPN simulator indeed returned the following message: "IPN was sent and the handshake was verified".

However, the log file generated by the IPN listener indicates that the listener failed to process the IPN message correctly. Here is what the log file says:

[2016-03-29 17:48 UTC] HTTP request of validation request:POST /cgi-

bin/webscr HTTP/1.1
Host: www.sandbox.paypal.com
Accept: */*
Connection: Close
Content-Length: 941
Content-Type: application/x-www-form-urlencoded

 for IPN payload: cmd=_notify-validate&payment_type=instant&payment_date=Tue+Mar+29+2016+18%3A16%3A38+GMT%2B0100+%28Hora+de+Ver%C3%83%C2%A3o+de+GMT%29&payment_status=Completed&address_status=confirmed&payer_status=verified&first_name=John&last_name=Smith&payer_email=buyer%40paypalsandbox.com&payer_id=TESTBUYERID01&address_name=John+Smith&address_country=United+States&address_country_code=US&address_zip=95131&address_state=CA&address_city=San+Jose&address_street=123+any+street&business=seller%40paypalsandbox.com&receiver_email=seller%40paypalsandbox.com&receiver_id=seller%40paypalsandbox.com&residence_country=US&item_name1=something&item_number1=AK-1234&tax=2.02&mc_currency=USD&mc_fee=0.44&mc_gross=12.34&mc_gross_1=12.34&mc_handling=2.06&mc_handling1=1.67&mc_shipping=3.02&mc_shipping1=1.02&txn_type=cart&txn_id=302758056&notify_version=2.1&custom=xyz123&invoice=abc1234&test_ipn=1&verify_sign=AFcWxV21C7fd0v3bYYYRCpSSRl31AHYNfmsVFESKyDLknmS3M5A8PkNI
[2016-03-29 17:48 UTC] HTTP response of validation request: HTTP/1.1 200 OK
Date: Tue, 29 Mar 2016 17:48:00 GMT
Server: Apache
X-Frame-Options: SAMEORIGIN
Set-Cookie: c9MWDuvPtT9GIMyPc3jwol1VSlO=2I3qnyCkBB3XdWjX_k6qUfsHuBc1GAbvT7Mvx82vTNttPkSuPqzY2-m8MQq8SaoGHm7SWL4gG3vnyU48YFmYwci1hBFCrewHMEzxJHb6vwOdE3JHuDBlWlPpPKljHvs0XDhyhrpxKRdBKHJbfB8S2r6dpS12MhsnjD20c3TuoB50fahlPAwe-DB_fzV4doj7pFdqyGkujspMt-GVcu4Oag-DHwSpiyUPPDwUFlDP0Mel2BZtpkS9RMOp67FTwauchCGQ43Q1eGBCB5mCsokggySU-xhqk1BVQVT_0_vzmiZuGtQD17fQpVRE396JsQynQO3OKfAsq5hhcKHmRMYbmgY-XLZcGqqRKFsYPFCPMb4oTm79-BbDtOzhMw0VrG70wmInHRwhUEaGWTHoE3Cr1bHJGHuH3T6fJPXme6ygPzugAlmMZIFNsiKNYjy; domain=.paypal.com; path=/; Secure; HttpOnly
Set-Cookie: cookie_check=yes; expires=Fri, 27-Mar-2026 17:48:00 GMT; domain=.paypal.com; path=/; Secure; HttpOnly
Set-Cookie: navcmd=_notify-validate; domain=.paypal.com; path=/; Secure; HttpOnly
Set-Cookie: navlns=0.0; expires=Thu, 29-Mar-2018 17:48:00 GMT; domain=.paypal.com; path=/; Secure; HttpOnly
Set-Cookie: Apache=10.72.108.11.1459273680419868; path=/; expires=Thu, 22-Mar-46 17:48:00 GMT
Vary: Accept-Encoding,User-Agent
Connection: close
HTTP_X_PP_AZ_LOCATOR: sandbox.slc
Paypal-Debug-Id: 513d36fd62f6b
Set-Cookie: X-PP-SILOVER=name%3DSANDBOX3.WEB.1%26silo_version%3D1880%26app%3Dappdispatcher%26TIME%3D3502242390; domain=.paypal.com; path=/; Secure; HttpOnly
Set-Cookie: X-PP-SILOVER=; Expires=Thu, 01 Jan 1970 00:00:01 GMT
Strict-Transport-Security: max-age=14400
Transfer-Encoding: chunked
Content-Type: text/html; charset=UTF-8

INVALID
[2016-03-29 17:48 UTC] Invalid IPN: cmd=_notify-validate&payment_type=instant&payment_date=Tue+Mar+29+2016+18%3A16%3A38+GMT%2B0100+%28Hora+de+Ver%C3%83%C2%A3o+de+GMT%29&payment_status=Completed&address_status=confirmed&payer_status=verified&first_name=John&last_name=Smith&payer_email=buyer%40paypalsandbox.com&payer_id=TESTBUYERID01&address_name=John+Smith&address_country=United+States&address_country_code=US&address_zip=95131&address_state=CA&address_city=San+Jose&address_street=123+any+street&business=seller%40paypalsandbox.com&receiver_email=seller%40paypalsandbox.com&receiver_id=seller%40paypalsandbox.com&residence_country=US&item_name1=something&item_number1=AK-1234&tax=2.02&mc_currency=USD&mc_fee=0.44&mc_gross=12.34&mc_gross_1=12.34&mc_handling=2.06&mc_handling1=1.67&mc_shipping=3.02&mc_shipping1=1.02&txn_type=cart&txn_id=302758056&notify_version=2.1&custom=xyz123&invoice=abc1234&test_ipn=1&verify_sign=AFcWxV21C7fd0v3bYYYRCpSSRl31AHYNfmsVFESKyDLknmS3M5A8PkNI

Why is the IPN listener not working correctly? For info, since I'm still in development mode, I still don't have a SSL certificate on my website, but apparently SSL certificates are not needed to test the IPN listener.

Upvotes: 0

Views: 434

Answers (2)

phillixzk
phillixzk

Reputation: 342

the below string you sent to PayPal for verification seems to be some dummy data. could you please make a real sandbox payment test and post the real IPN data back to PayPal to check the verification result again ?

cmd=_notify-validate&payment_type=instant&payment_date=Tue+Mar+29+2016+18%3A16%3A38+GMT%2B0100+%28Hora+de+Ver%C3%83%C2%A3o+de+GMT%29&payment_status=Completed&address_status=confirmed&payer_status=verified&first_name=John&last_name=Smith&payer_email=buyer%40paypalsandbox.com&payer_id=TESTBUYERID01&address_name=John+Smith&address_country=United+States&address_country_code=US&address_zip=95131&address_state=CA&address_city=San+Jose&address_street=123+any+street&business=seller%40paypalsandbox.com&receiver_email=seller%40paypalsandbox.com&receiver_id=seller%40paypalsandbox.com&residence_country=US&item_name1=something&item_number1=AK-1234&tax=2.02&mc_currency=USD&mc_fee=0.44&mc_gross=12.34&mc_gross_1=12.34&mc_handling=2.06&mc_handling1=1.67&mc_shipping=3.02&mc_shipping1=1.02&txn_type=cart&txn_id=302758056&notify_version=2.1&custom=xyz123&invoice=abc1234&test_ipn=1&verify_sign=AFcWxV21C7fd0v3bYYYRCpSSRl31AHYNfmsVFESKyDLknmS3M5A8PkNI

Upvotes: 1

Peppi Alexandrova
Peppi Alexandrova

Reputation: 401

The IPN code https://github.com/paypal/ipn-code-samples/blob/master/paypal_ipn.php contains:

if (strcmp ($res, "VERIFIED") == 0) {

and in the url you receive it is in lower case. Maybe this is the problem.

Upvotes: 0

Related Questions