0
votes

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 ?

1
Encoding the entire parameter set at once is not correct. You have to encode the name and the value of each, separated by an un-encoded =, and the pairs separated by an un-encoded &.user207421
Yeah okay, will check with this one, but at the same time how it gets verified for some payments?Rajesh Manilal

1 Answers

1
votes

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#