IPN "INVALID" response issue in Coldfusion

AFIweborders
Contributor
Contributor

IPN INVALID RESPONSE ISSUE IN COLDFUSION
I have faced an issue when I use CFHTTP tag in coldfusion to get validity response from paypal about data. In Coldfusion I get an INVALID response from paypal. And this issue in coldfusion persist for some of the payments, not in every case.
But when I use the same link to hit through php curl, I get “VERIFIED” in response content.
The URL I use to send to paypal is given below:
http://www.paypal.com/cgi-bin/webscr?cmd=_notify-validate& mc_gross=5.00&protection_eligibility=Eligible&address_status=confirmed&payer_id=SS3F4FDSRYFJ4&address_street=1219+Vernon+St.&payment_date=20%3A08%3A46+Mar+14%2C+2021+PDT&payment_status=Completed&charset=windows-1252&address_zip=54720&first_name=McKenna&mc_fee=0.45&address_country_code=US&address_name=McKenna+Hoff&notify_version=3.9&custom=22744&payer_status=verified&business=orders%40afi-usa.com&address_country=United+States&address_city=Altoona&quantity=1&verify_sign=Ai9pZWO7HELsWF2nYCZXKt9ryPoRAzwhGlFmEofj4cBTZG8k5ZJCV5zB&payer_email=smithcocandlesLLC%40gmail.com&txn_id=6623965058049454H&payment_type=instant&payer_business_name=Smith+%26+Co.+Candles+LLC&last_name=Smith&address_state=WI&receiver_email=sean%40afi-usa.com&payment_fee=0.45&shipping_discount=0.00&insurance_amount=0.00&receiver_id=EBMDNRZ7J4AGL&txn_type=web_accept&item_name=F21035%2Csample%7CF22983%2Csample%7CF20916%2Csample%7CF21778%2Csample%7CF20615%2Csample%7CF22922%2Csample&discount=0.00&mc_currency=USD&item_number=&residence_country=US&shipping_method=Default&transaction_subject=&payment_gross=5.00&ipn_track_id=6372115d45d80

Coldfusion and Php code is on next page……

 

 

 

 

 

COLDFUSION CODE

<CFSET requestData = 'mc_gross=5.00&protection_eligibility=Eligible&address_status=confirmed&payer_id=SS3F4FDSRYFJ4&address_street=1219+Vernon+St.&payment_date=20%3A08%3A46+Mar+14%2C+2021+PDT&payment_status=Completed&charset=windows-1252&address_zip=54720&first_name=McKenna&mc_fee=0.45&address_country_code=US&address_name=McKenna+Hoff&notify_version=3.9&custom=22744&payer_status=verified&business=orders%40afi-usa.com&address_country=United+States&address_city=Altoona&quantity=1&verify_sign=Ai9pZWO7HELsWF2nYCZXKt9ryPoRAzwhGlFmEofj4cBTZG8k5ZJCV5zB&payer_email=smithcocandlesLLC%40gmail.com&txn_id=6623965058049454H&payment_type=instant&payer_business_name=Smith+%26+Co.+Candles+LLC&last_name=Smith&address_state=WI&receiver_email=sean%40afi-usa.com&payment_fee=0.45&shipping_discount=0.00&insurance_amount=0.00&receiver_id=EBMDNRZ7J4AGL&txn_type=web_accept&item_name=F21035%2Csample%7CF22983%2Csample%7CF20916%2Csample%7CF21778%2Csample%7CF20615%2Csample%7CF22922%2Csample&discount=0.00&mc_currency=USD&item_number=&residence_country=US&shipping_method=Default&transaction_subject=&payment_gross=5.00&ipn_track_id=6372115d45d80'>

<cfset urll = "http://www.paypal.com/cgi-bin/webscr?cmd=_notify-validate&#requestData#">

<cfhttp url="#urll#" result="res" method="get" >
<cfhttpparam type="header" name="Host" value="www.paypal.com" />

</cfhttp>

<cfoutput>
#res.FileContent#
</cfoutput>

 

 

PHP CODE
<?php
$raw_post_data = 'mc_gross=5.00&protection_eligibility=Eligible&address_status=confirmed&payer_id=SS3F4FDSRYFJ4&address_street=1219+Vernon+St.&payment_date=20%3A08%3A46+Mar+14%2C+2021+PDT&payment_status=Completed&charset=windows-1252&address_zip=54720&first_name=McKenna&mc_fee=0.45&address_country_code=US&address_name=McKenna+Hoff&notify_version=3.9&custom=22744&payer_status=verified&business=orders%40afi-usa.com&address_country=United+States&address_city=Altoona&quantity=1&verify_sign=Ai9pZWO7HELsWF2nYCZXKt9ryPoRAzwhGlFmEofj4cBTZG8k5ZJCV5zB&payer_email=smithcocandlesLLC%40gmail.com&txn_id=6623965058049454H&payment_type=instant&payer_business_name=Smith+%26+Co.+Candles+LLC&last_name=Smith&address_state=WI&receiver_email=sean%40afi-usa.com&payment_fee=0.45&shipping_discount=0.00&insurance_amount=0.00&receiver_id=EBMDNRZ7J4AGL&txn_type=web_accept&item_name=F21035%2Csample%7CF22983%2Csample%7CF20916%2Csample%7CF21778%2Csample%7CF20615%2Csample%7CF22922%2Csample&discount=0.00&mc_currency=USD&item_number=&residence_country=US&shipping_method=Default&transaction_subject=&payment_gross=5.00&ipn_track_id=6372115d45d80';

$raw_post_array = explode('&', $raw_post_data);
$myPost = array();
foreach ($raw_post_array as $keyval) {
$keyval = explode('=', $keyval);
if (count($keyval) == 2) {
// Since we do not want the plus in the datetime string to be encoded to a space, we manually encode it.
if ($keyval[0] === 'payment_date') {
if (substr_count($keyval[1], '+') === 1) {
$keyval[1] = str_replace('+', '%2B', $keyval[1]);
}
}
$myPost[$keyval[0]] = urldecode($keyval[1]);
}
}

// Build the body of the verification post request, adding the _notify-validate command.
$req = 'cmd=_notify-validate';
$get_magic_quotes_exists = false;
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";
}

 

$curl = curl_init();

curl_setopt_array($curl, array(
CURLOPT_URL => 'http://www.paypal.com/cgi-bin/webscr',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => $req,
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_HTTPHEADER => array([Removed. Phone #s not permitted]ca007e9421ecd7'
),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;



Please help me and let me know why i am facing this issue and how can i resolve this issue.

Login to Me Too
0 REPLIES 0

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.