Php 如何在paypal的notify_url页面中获取交易详细信息
在paypal notify_url页面中,当我将cmd value用作购物车时,我没有得到任何值。如何在notify_url页面中获得交易详细信息Php 如何在paypal的notify_url页面中获取交易详细信息,php,paypal,payment-gateway,Php,Paypal,Payment Gateway,在paypal notify_url页面中,当我将cmd value用作购物车时,我没有得到任何值。如何在notify_url页面中获得交易详细信息 <form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="POST" name="_xclick" id="paypal_form"> <input type="hidden" name="upload" value="1" /> <inp
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="POST" name="_xclick" id="paypal_form">
<input type="hidden" name="upload" value="1" />
<input type="hidden" name="cmd" value="_xclick" />
<!-- The business email address, where you want to receive the payment -->
<!--<input type="hidden" name="business" value="yesidealpayment@gmail.com" />-->
<input type="hidden" name="business" value="arun_1260247381_per@galtechsupport.us" />
<!-- The customer email address -->
<input type="hidden" name="item_name_1" value="<?php echo ucfirst($couponname); ?>" />
<input type="hidden" name="amount_1" value="<?php echo $total_payable_amount; ?>" />
<!--<input type="hidden" name="currency_code" value="AUD" />-->
<input type="hidden" name="currency_code" value="USD" />
<input type="hidden" name="amount" value="25.58" />
<!-- Where you want to return after PayPal Payment -->
<input type="hidden" name="return" value="http://yes-i-deal.com.au/test/paypal_ipn.php" />
<!-- A back-end notification send to the specific page after successful payment -->
<!--<input type="hidden" name="notify_url" value="http://yes-i-deal.com.au/test/paypal.php" />-->
<input type="hidden" name="notify_url" value="http://yes-i-deal.com.au/test/paypal_ipn.php" />
<!-- Where you want to return after cancel the PayPal Payment -->
<input type="hidden" name="cancel_return" value="http://yes-i-deal.com.au/" />
<input type="hidden" name="custom" value="<?php echo $coupon_id."_".$userid;?>" />
<input type="image" name="submit" src="http://yes-i-deal.com.au/themes/green/images/Buy-Now-Button.png" />
</form>
在我当前的项目中,我对paypal自适应支付也有同样的问题。我已经给了我的 通知url为。在这一页中,我只是简单地编码 $request=$\u POST 邮件('myid@myaccount“,$请求) 然后我将交易结果发送到我的邮件以查看
注意,在我的邮件中,我可以看到交易结果,如果我插入数据库,它将插入,但我无法在我的页面中看到交易结果。尝试将交易结果发送到邮件。创建paypal_ipn.php文件并将php代码放入其中
// Response from Paypal
// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-validate';
foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$value = preg_replace('/(.*[^%^0^D])(%0A)(.*)/i','${1}%0D%0A${3}',$value);// IPN fix
$req .= "&$key=$value";
}
// assign posted variables to local variables
$data['item_name'] = $_POST['item_name'];
$data['item_number'] = $_POST['item_number'];
$data['payment_status'] = $_POST['payment_status'];
$data['payment_amount'] = $_POST['mc_gross'];
$data['payment_currency'] = $_POST['mc_currency'];
$data['txn_id'] = $_POST['txn_id'];
$data['receiver_email'] = $_POST['receiver_email'];
$data['payer_email'] = $_POST['payer_email'];
$data['custom'] = $_POST['custom'];
$data['invoice'] = $_POST['invoice'];
$data['paypallog'] = $req;
// post back to PayPal system to validate
$header = "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
$fp = fsockopen ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);
if (!$fp) {
// HTTP ERROR
} else {
fputs ($fp, $header . $req);
while (!feof($fp)) {
////mail('atiftariq80@gmail.com','Step 9','Step 9');
$res = fgets ($fp, 1024);
if (true || strcmp($res, "VERIFIED") == 0) {
////mail('atiftariq80@gmail.com','PAYMENT VALID','PAYMENT VALID');
// Validate payment (Check unique txnid & correct price)
$valid_txnid = check_txnid($data['txn_id']);
$valid_price = check_price($data['payment_amount'], $data['item_number']);
// PAYMENT VALIDATED & VERIFIED!
if($valid_txnid && $valid_price){
//----------------- INSERT RECORDS TO DATABASE-------------------------------------
if ($data['invoice']=='basic') {
$price = 39;
} else {
$price = 159;
}
$this->user_model->update_user(
array(
'id' => $data['custom'],
'user_status' => 1,
'payment_date' => date("Y-m-d H:i:s",time()),
'next_payment_date' => date('Y-m-d', strtotime('+32 days')),
'user_package' => $data['invoice'],
'package_price' => $price
)
);
$data2 = array('id' => '',
'txn_id' => $data['txn_id'],
'amount' => $data['payment_amount'],
'mode ' => $data['payment_status'],
'paypal_log' => $data['paypallog'],
'user_id' => $data['custom'],
'created_at' => date('Y-m-d H:i:s',time())
);
$this->db->insert('tbl_paypal_log', $data2);
//----------------- INSERT RECORDS TO DATABASE-------------------------------------
}else{
// Payment made but data has been changed
// E-mail admin or alert user
}
} elseif ($res=='INVALID') {
// PAYMENT INVALID & INVESTIGATE MANUALY!
// E-mail admin or alert user
////mail('atiftariq80@gmail.com','PAYMENT INVALID AND INVESTIGATE MANUALY','PAYMENT INVALID AND INVESTIGATE MANUALY');
}
}
fclose ($fp);
}
对于即时支付通知(IPN)和了解其工作方式有着重要的意义。本指南为您提供了使通知url
正常工作所需的步骤
Paypal提供了一些验证响应,非常好。您可以使用这些作为自己的起点。您可以显示您的通知url页面代码吗。。?notify_url页面从paypal获取帖子数据,因此请检查帖子数据。当我使用cmd值作为_xclick时,我会获取详细信息,但当使用_cart时,不会获取。我的notify_url页面作为会话_start()获取值;要求(“ipn_cls1.php”)$paypal_info=$\u POST;打印(贝宝信息)$paypal\u ipn=新的paypal\u ipn($paypal\u info);////echo“status”。$payment_status=trim($paypal_info['payment_status');//Si完成:tout est OK回显“状态1”。$payment\u amount=trim($paypal\u info['mc\u gross']);当我使用将事务详细信息发送到邮件时,该页面中出现错误,警告:mail()希望参数3是字符串,数组在第16行的/home/yesid984/public_html/test/paypal_ipn.php中给出。警告:为foreach()提供的参数无效在第86行的/home/yesid984/public_html/test/paypal_ipn.php中致命错误:在第98行的/home/yesid984/public_html/test/paypal_ipn.php中调用未定义的方法stdClass::is_verified(),我没有得到任何mailyes sreeltha mail需要3个参数。邮件('id@youaccount“,”title“,$request)如何获取自定义值。我将mail()改为like mail('id@youaccount“,”标题“,$request)。然后我也没有收到任何邮件。我需要自定义值我如何才能得到它…你是在本地主机或livehey中尝试。我用我的paypal帐户尝试了你的测试表单,并返回了一些数据。我的代码在这里,放在这里并测试它。$req='';foreach($_postas$key=>$value){if(get_magic_quotes_gpc()==1){$value=urlencode(stripslashes($value));}else{$value=urlencode($value);}$req.=“&$key=$value”}print($req);什么是支票和支票价格?你在哪里定义了这些?
// Response from Paypal
// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-validate';
foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$value = preg_replace('/(.*[^%^0^D])(%0A)(.*)/i','${1}%0D%0A${3}',$value);// IPN fix
$req .= "&$key=$value";
}
// assign posted variables to local variables
$data['item_name'] = $_POST['item_name'];
$data['item_number'] = $_POST['item_number'];
$data['payment_status'] = $_POST['payment_status'];
$data['payment_amount'] = $_POST['mc_gross'];
$data['payment_currency'] = $_POST['mc_currency'];
$data['txn_id'] = $_POST['txn_id'];
$data['receiver_email'] = $_POST['receiver_email'];
$data['payer_email'] = $_POST['payer_email'];
$data['custom'] = $_POST['custom'];
$data['invoice'] = $_POST['invoice'];
$data['paypallog'] = $req;
// post back to PayPal system to validate
$header = "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
$fp = fsockopen ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);
if (!$fp) {
// HTTP ERROR
} else {
fputs ($fp, $header . $req);
while (!feof($fp)) {
////mail('atiftariq80@gmail.com','Step 9','Step 9');
$res = fgets ($fp, 1024);
if (true || strcmp($res, "VERIFIED") == 0) {
////mail('atiftariq80@gmail.com','PAYMENT VALID','PAYMENT VALID');
// Validate payment (Check unique txnid & correct price)
$valid_txnid = check_txnid($data['txn_id']);
$valid_price = check_price($data['payment_amount'], $data['item_number']);
// PAYMENT VALIDATED & VERIFIED!
if($valid_txnid && $valid_price){
//----------------- INSERT RECORDS TO DATABASE-------------------------------------
if ($data['invoice']=='basic') {
$price = 39;
} else {
$price = 159;
}
$this->user_model->update_user(
array(
'id' => $data['custom'],
'user_status' => 1,
'payment_date' => date("Y-m-d H:i:s",time()),
'next_payment_date' => date('Y-m-d', strtotime('+32 days')),
'user_package' => $data['invoice'],
'package_price' => $price
)
);
$data2 = array('id' => '',
'txn_id' => $data['txn_id'],
'amount' => $data['payment_amount'],
'mode ' => $data['payment_status'],
'paypal_log' => $data['paypallog'],
'user_id' => $data['custom'],
'created_at' => date('Y-m-d H:i:s',time())
);
$this->db->insert('tbl_paypal_log', $data2);
//----------------- INSERT RECORDS TO DATABASE-------------------------------------
}else{
// Payment made but data has been changed
// E-mail admin or alert user
}
} elseif ($res=='INVALID') {
// PAYMENT INVALID & INVESTIGATE MANUALY!
// E-mail admin or alert user
////mail('atiftariq80@gmail.com','PAYMENT INVALID AND INVESTIGATE MANUALY','PAYMENT INVALID AND INVESTIGATE MANUALY');
}
}
fclose ($fp);
}