PAYPAL IPN postback returns INVALID - paypal

I'm using Paypal for payment processing in one of my application. And as a part of it I'm using PayPal IPN. So while paypal payment gets completed, the paypal sends the IPN message to the IPN URL(configured in the Paypal site). The IPN message is as follows,
mc_gross=1.00&protection_eligibility=Eligible&address_status=confirmed&payer_id=GXZTE5K9VURMU&tax=0.00&address_street=Department+Of+State+2050+Bamako+Place+Washington%2C+DC+20521-2050&payment_date=01%3A18%3A47+Jul+23%2C+2016+PDT&payment_status=Completed&charset=windows-1252&address_zip=20521&first_name=Test&mc_fee=0.38&address_country_code=US&address_name=Test+Test&notify_version=3.8&custom=3&payer_status=unverified&business=test.test15%40gmail.com&address_country=United+States&address_city=Washington&quantity=1&verify_sign=ABiBx6LFP1A2IuUu8wF.arqoHdTJA5F1TwzPqOjEd01798Nh2NTTbdU0&payer_email=testpayer%40gmail.com&txn_id=7AP55204BB503245S&payment_type=instant&last_name=Test&address_state=DC&receiver_email=test.test15%40gmail.com&payment_fee=&receiver_id=T3SDTD8X2SFZW&txn_type=web_accept&item_name=donation+for+test.com&mc_currency=EUR&item_number=&residence_country=US&test_ipn=1&handling_amount=0.00&transaction_subject=&payment_gross=&shipping=0.00&ipn_track_id=9f24d51b9d45c
So while verifying the above message with Paypal using the following code
<cfset requestData = getHTTPRequestData() /> <!--- getting IPN message --->
<cfhttp url="https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_notify-validate&#URLEncodedFormat(requestData.content)#" resolveurl="false">
<cfhttpparam type="header" name="Host" value="www.sandbox.paypal.com">
</cfhttp>
I'm getting INVALID as response for 90% of the time, and getting VERIFIED as response for remaining 10% of time. Not sure why it gets INVALID. Hope no flaws in the code, because sometimes it gives VERIFIED as response. Did I miss anything ?
Also you can see that in IPN message that, the payer_status is Unverified. Is this the reason for INVALID response (Not sure about it). If so, why the Payer status is Unverified and what to make this status verified ?

Actually you are not supposed to encode the request at all because the content is already URL-encoded (you are repeating the IPN to be verified by echoing the request). To solve your problem, use:
https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_notify-validate&#requestData.content#

Related

PayPal IPN Processing

I have implemented an IPN listener in VBScript/Classic ASP.
From my side, it seems to work perfectly.
When it is called, it sends the message back to Paypal appending cmd=_notify-validate. It then checks the response for objHttp.status = 200 and objHttp.responseText = "VERIFIED" then adds the order to my database.
However Paypal are sending me emails;
Subject: PayPal Instant Payment Notification Warning
Instant Payment Notifications sent to the following URL(s) are failing:
According to IPN Testing
Every listener must include code that handles the "error notification" IPN messages.
Either way you should follow the steps in the IPN troubleshooting tips step by step.
Here is a few I've picked out that should help.
Check the URLs listed in your IPN history to ensure that PayPal is posting each IPN to your listener.
Check your web server's access and error logs.
Check your programming language's error log.
Verify that your IPN listener is responding to all messages, even those you do not intend to process.
Further to the OPs comments
the code samples Paypal give, in which this step isn't performed. Is this step required?
it sounds like you are missing Step 2 from the workflow in the documentation
2. After receiving the IPN message from PayPal, your listener returns an empty HTTP 200 response to PayPal. Otherwise, PayPal resends the IPN message.
Judging by the PHP sample as well both seem to send the verification first, which doesn't tally with the workflow suggested by the documentation.
In which case you should just be able to do
Response.Status = "200 OK"
after the rest of the code, make sure nothing else is written back using Response.Write() so the server response is blank, you could even use
Call Response.Clear()
before setting the Response.Status to make sure nothing else has been written from the Response buffer. This will only work however if Response.Buffer has been set to True beforehand (usually at the beginning of the script).

Is there an IPN sent after DoExpressCheckoutPayment?

After we do DoExpressCheckoutPayment - resulting in payment status Completed or failing with some other status - is there any IPN sent from PayPal?
Yes, DECP sends IPN notifications. If you're not getting them make sure you have IPN enabled either through your profile or by the NOTIFYURL parameter in your request. Then check the IPN History in your PayPal account and your web server logs for details on whether or not the script is getting hit or not, and if there might be an error keeping it from running correctly.

Paypal IPN always INVALID on ie11

Paypal IPN always INVALID, on ie11, in the destination page after the transation. but the transaction happens and I get the e-mails from paypal, etc.
On Chrone there in no problema , and I get VERIFIED
Anybody has experienced this?

PayPal IPN simulator - how to generate INVALID response?

I'm using Paypal IPN simulator to test changes. I'm trying to generate an INVALID response.
I select
Transaction type: Cart Checkout
payment_status: Denied, Failed or Expired.
However all of these generate a notification call with response VERIFIED
update didn't read close enough. Documentation says: PayPal sends a single word back, which is either VERIFIED if the message originated with PayPal or INVALID if there is any discrepancy with what was originally sent. So if I just browse to my IPN URL directly, I will get an INVALID response from Paypal because the call to IPN did not originate with PayPal.
Regarding your update: close, but not exactly.
IPN will return VERIFIED or INVALID depending on whether or not it recognizes the POST data you're sending as having originated from PayPal.
So yes, if you browse to your IPN URL directly and it directly POST's no data / dummy data to PayPal, then yes, we won't recognize it as having originated from us and we'll return INVALID.
For example, this link will return INVALID:
https://www.paypal.com/cgi-bin/webscr?cmd=_notify-validate&dummy_data=true

PayPal Instant Payment Notification (IPN) Issue: PayPal sends VERIFIED response but has FAILED status in IPN History. 404 Error

PayPal is sending the VERIFIED message to my IPN listener but my IPN History shows a FAILED status. The IPN History also shows a 404 error. The code I am using for my listener can be found here: https://cms.paypal.com/cms_content/US/en_US/files/developer/IPN_PHP_41.txt. I am testing this with sandbox. How can I be receiving a VERIFIED response from Paypal but yet the IPN History shows a failed STATUS with a 404 error? Shouldn't PayPal be sending an INVALID response since the IPN History status is failed?
VERIFIED has nothing to do with how the transactions appear in your ipn history. How you respond to the original ipn post is what determines what shows in your ipn history.
If your ipn history says it's receiving a 404 response, then you need to check your ipn script and stop sending a 404 response.
If it were any other error, since you are using PayPal's script, I would bet you didn't change the environment variable/the URLs to match your environments. With a 404 though, you're telling the client (paypal in this case) that the page they want doesn't exist, even if you're still reading the data