这是我在Stackoverflow中的第一篇文章。到目前为止,我从本网站获得了最佳解决方案,但没有在本网站发布任何问题。
这是关于Paypal与我网站的整合。我从最近1个月开始挣扎。我试过很多方面但没有成功。来到我的问题,我没有得到Paypal的有效回复。有时TXN Id是空的,有时它正在工作。请检查以下代码并纠正我。
这是Paypal的最终查询字符串
business=xxxxxxxxxxxx&item_name_1=Dell_laptop%29&amount_1=50&item_number_1=10&return=http%3A%2F%2Fwww.xxxx.com%2Fpayments.php&cancel_return=http%3A%2F%2Fwww.xxxxxxxx.com%2Fpayment-not-sucess.php¤cy_code=CAD¬ify_url=http%3A%2F%2Fwww.xxxxxxx.com%2Fpayments.php&no_note=0&country=USA&cmd=_cart&upload=1
Payments.php
if (!isset($_GET['tx']) && !isset($_GET['st'])){
$header = array("Content-type: text/html", "multipart/form-data");
$querystring = "business=".urlencode($paypal_email)."&";
$querystring .= "item_name_1=".urlencode($exam_name_1)."&";
$querystring .= "amount_1=".urlencode($amount_1)."&";
$querystring .= "item_number_1=".urlencode($item_number_1)."&";
if(($amount_2>0) && ($item_number_2 !='')){
$querystring .= "item_name_2=".urlencode($exam_name_2)."&";
$querystring .= "amount_2=".urlencode($amount_2)."&";
$querystring .= "item_number_2=".urlencode($item_number_2)."&";
}
$querystring .= "return=".urlencode(stripslashes($return_url))."&";
$querystring .= "cancel_return=".urlencode(stripslashes($cancel_url))."&";
//$querystring .= "rm=".urlencode($rm)."&";
$querystring .= "currency_code=".urlencode($currency_code)."&";
$querystring .= "notify_url=".urlencode($notify_url)."&";
$querystring .= "no_note=".urlencode($no_note)."&";
$querystring .= "country=".urlencode($country)."&";
$querystring .= "cmd=".urlencode($cmd)."&";
$querystring .= "upload=".urlencode($upload);
header("Location: http://www.paypal.com/cgi-bin/webscr?".$querystring);
}
else{ // Response from Paypal................
echo $payment_gross=$_REQUEST['amt'];
echo $txn_id=$_REQUEST['tx'];
echo $payment_status=$_REQUEST['st'];
header("Location: xxxx.php");
}
Paypal设置:
自动返回:开启
返回网址:http://www.xxxxxxx.com/payments.php
通知网址:http://www.xxxxxxx.com/payments.php
PDT:on
IPN:已启用..
答案 0 :(得分:0)
为了在成功付款后获得PayPal的正确回复,您必须在阵列中提及您发送给PayPal的成功网址
if (!isset($_GET['tx']) && !isset($_GET['st'])){
$header = array("Content-type: text/html", "multipart/form-data");
$querystring = "business=".urlencode($paypal_email)."&";
$querystring .= "item_name_1=".urlencode($exam_name_1)."&";
$querystring .= "amount_1=".urlencode($amount_1)."&";
$querystring .= "item_number_1=".urlencode($item_number_1)."&";
if(($amount_2>0) && ($item_number_2 !='')){
$querystring .= "item_name_2=".urlencode($exam_name_2)."&";
$querystring .= "amount_2=".urlencode($amount_2)."&";
$querystring .= "item_number_2=".urlencode($item_number_2)."&";
}
$querystring .= "return=".urlencode(stripslashes($return_url))."&";
$querystring .= "cancel_return=".urlencode(stripslashes($cancel_url))."&";
//$querystring .= "rm=".urlencode($rm)."&";
$querystring .= "currency_code=".urlencode($currency_code)."&";
$querystring .= "notify_url=".urlencode($notify_url)."&";
//Added Line
$querystring .= "success_url=".urlencode($notify_url)."&";
$querystring .= "no_note=".urlencode($no_note)."&";
$querystring .= "country=".urlencode($country)."&";
$querystring .= "cmd=".urlencode($cmd)."&";
$querystring .= "upload=".urlencode($upload);
header("Location: http://www.paypal.com/cgi-bin/webscr?".$querystring);
}
else{ // Response from Paypal................
echo $payment_gross=$_REQUEST['amt'];
echo $txn_id=$_REQUEST['tx'];
echo $payment_status=$_REQUEST['st'];
header("Location: xxxx.php");
}