Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

paypal and hosting

Status
Not open for further replies.

inusrat

Programmer
Feb 28, 2004
308
CA
Hi,

I have hooked up a website with Palpal on my home server.
It is working fine. I get "FAIL" or "SUCCESS" response from PayPal.
But when I put the exact same code on hosting company (dynonames.com). I get empty response from Paypal.

Paypal says talk to your hosting company, hosting company says everthing is fine on our side talk to PayPal.

I wonder if anyone has any idea why I am having this problem?

Thanks

 
I've never worked with PayPal, but it would seem to me that if the exact same code works on one machine but doesn't on another, then there's something not set up right on that machine. It sounds like a problem with the host.



Hope This Helps!

Ecobb
Beer Consumption Analyst

"My work is a game, a very serious game." - M.C. Escher
 
Check the encoding used on your hosts server. I had the same problem when using a Coldfusion script to accept the response because of the encoding Coldfusion uses. Although you may not be using Coldfusion, the problem was the encoding so could affect any language.

Hope this helps

Wullie

Fresh Look - Quality Coldfusion Hosting

The pessimist complains about the wind. The optimist expects it to change. The leader adjusts the sails. - John Maxwell
 
thanks for your reply.
how do i check for encoding or decoding
Yes there is decoding involved in the script . I am using PHP

The script
***********
<?php
// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-synch';

$tx_token = $_GET['tx'];

$auth_token = "U9ki_Q_3BcBVti61nFNHr5KHudpGu4SzxOjIS9gr0nGY55kcSiWtVX58qQe";

$req .= "&tx=$tx_token&at=$auth_token";


$header = "";
// post back to PayPal system to validate
$header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Content-Type: application/x-$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";



$fp = fsockopen (' 80, $errno, $errstr, 30);


// If possible, securely post back to paypal using HTTPS
// Your PHP server will need to be SSL enabled
// $fp = fsockopen ('ssl:// 443, $errno, $errstr, 30);

if (!$fp) {
// HTTP ERROR
} else {
fputs ($fp, $header . $req);
// read the body data
$res = '';
$headerdone = false;
while (!feof($fp)) {

$line = fgets ($fp, 1024);


if (strcmp($line, "\r\n") == 0) {
// read the header
$headerdone = true;
}
else if ($headerdone)
{
// header has been read. now read the contents
$res .= $line;



}
}

// parse the data
$lines = explode("\n", $res);
$keyarray = array();
//if (strcmp ($lines[0], "SUCCESS") == 0) {


//for ($i=1; $i<count($lines);$i++){
//list($key,$val) = explode("=", $lines[$i]);
//$keyarray[urldecode($key)] = urldecode($val);



//}


if (strcmp ($lines[0], "SUCCESS") == 0) {

for ($i=1; $i<count($lines);$i++)
{
if (strpos($lines[$i], '=') !== false)
{
list($key,$val) = explode("=", $lines[$i]);
$keyarray[urldecode($key)] = urldecode($val);
}
}


// check the payment_status is Completed
// check that txn_id has not been previously processed
// check that receiver_email is your Primary PayPal email
// check that payment_amount/payment_currency are correct
// process payment
$firstname = $keyarray['first_name'];
$lastname = $keyarray['last_name'];
$itemname = $keyarray['item_name'];
$amount = $keyarray['mc_gross'];

echo ("<p><h3>Thank you for your purchase!</h3></p>");

echo ("<b>Payment Details</b><br>\n");
echo ("<li>Name: $firstname $lastname</li>\n");
echo ("<li>Item: $itemname</li>\n");
echo ("<li>Amount: $amount</li>\n");
echo ("");
}
else if (strcmp ($lines[0], "FAIL") == 0) {
// log for manual investigation



}

}



fclose ($fp);

?>
<BR><BR>
Your transaction has been completed, and a receipt for your purchase has been emailed to you.<br>You may log into your account at <a href=' target="_blank"> target="_blank"> to view details of this transaction.<br>


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top