paypal即時(shí)到賬php實(shí)現(xiàn)代碼
更新時(shí)間:2010年11月28日 15:24:01 作者:
paypal即時(shí)到賬php實(shí)現(xiàn)代碼,需要的朋友可以參考下。
http://paypal.ebay.cn/integrationcenter/list__resource_2.html
中文php開發(fā)簡介:http://www.paypal-china.org/wangzhai/197.html
以下是ecshop中paypal的支付代碼
這段代碼是向paypal支付接口提交的
{{{
<form target="_blank" method="post" action="https://www.paypal.com/cgi-bin/webscr" style="text-align: center;"><input type="hidden" value="_xclick" name="cmd"/><input type="hidden" value="xfuajiao@hotmail.com" name="business"/> //商家注冊的郵箱
<input type="hidden" value="2009102370175" name="item_name"/><input type="hidden" value="2888.00" name="amount"/><input type="hidden" value="USD" name="currency_code"/><input type="hidden" value="http://127.0.0.1/ecshop/respond.php?code=paypal" name="return"/><input type="hidden" value="3" name="invoice"/><input type="hidden" value="utf-8" name="charset"/><input type="hidden" value="1" name="no_shipping"/><input type="hidden" value="" name="no_note"/><input type="hidden" value="http://127.0.0.1/ecshop/respond.php?code=paypal" name="notify_url"/><input type="hidden" value="2" name="rm"/><input type="hidden" value="http://127.0.0.1/ecshop/" name="cancel_return"/><input type="submit" value="立即使用 paypal 支付"/></form>
}}}
以下是官方提供的,接受到paypal傳回來的參數(shù)的,并且判斷是否支付成功。
支持成功后由于提交表單中有
<input type="hidden" value="http://127.0.0.1/ecshop/respond.php?code=paypal" name="return"/>
paypal將會主動跳轉(zhuǎn)到espond.php?code=paypal這個(gè)頁面,頁面可現(xiàn)實(shí)以下POST得到的一些數(shù)據(jù)。
// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-validate';
foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$req .= "&$key=$value";
}
// 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.paypal.com', 443, $errno, $errstr, 30);
// assign posted variables to local variables
$item_name = $_POST['item_name'];
$item_number = $_POST['item_number'];
$payment_status = $_POST['payment_status'];
$payment_amount = $_POST['mc_gross'];
$payment_currency = $_POST['mc_currency'];
$txn_id = $_POST['txn_id'];
$receiver_email = $_POST['receiver_email'];
$payer_email = $_POST['payer_email'];
if (!$fp) {
// HTTP ERROR
else {
fputs ($fp, $header . $req);
while (!feof($fp)) {
$res = fgets ($fp, 1024);
if (strcmp ($res, "VERIFIED") == 0) {
// 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
}
else if (strcmp ($res, "INVALID") == 0) {
// log for manual investigation
}
}
fclose ($fp);
}
?>
中文php開發(fā)簡介:http://www.paypal-china.org/wangzhai/197.html
以下是ecshop中paypal的支付代碼
這段代碼是向paypal支付接口提交的
{{{
<form target="_blank" method="post" action="https://www.paypal.com/cgi-bin/webscr" style="text-align: center;"><input type="hidden" value="_xclick" name="cmd"/><input type="hidden" value="xfuajiao@hotmail.com" name="business"/> //商家注冊的郵箱
<input type="hidden" value="2009102370175" name="item_name"/><input type="hidden" value="2888.00" name="amount"/><input type="hidden" value="USD" name="currency_code"/><input type="hidden" value="http://127.0.0.1/ecshop/respond.php?code=paypal" name="return"/><input type="hidden" value="3" name="invoice"/><input type="hidden" value="utf-8" name="charset"/><input type="hidden" value="1" name="no_shipping"/><input type="hidden" value="" name="no_note"/><input type="hidden" value="http://127.0.0.1/ecshop/respond.php?code=paypal" name="notify_url"/><input type="hidden" value="2" name="rm"/><input type="hidden" value="http://127.0.0.1/ecshop/" name="cancel_return"/><input type="submit" value="立即使用 paypal 支付"/></form>
}}}
以下是官方提供的,接受到paypal傳回來的參數(shù)的,并且判斷是否支付成功。
支持成功后由于提交表單中有
<input type="hidden" value="http://127.0.0.1/ecshop/respond.php?code=paypal" name="return"/>
paypal將會主動跳轉(zhuǎn)到espond.php?code=paypal這個(gè)頁面,頁面可現(xiàn)實(shí)以下POST得到的一些數(shù)據(jù)。
復(fù)制代碼 代碼如下:
// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-validate';
foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$req .= "&$key=$value";
}
// 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.paypal.com', 443, $errno, $errstr, 30);
// assign posted variables to local variables
$item_name = $_POST['item_name'];
$item_number = $_POST['item_number'];
$payment_status = $_POST['payment_status'];
$payment_amount = $_POST['mc_gross'];
$payment_currency = $_POST['mc_currency'];
$txn_id = $_POST['txn_id'];
$receiver_email = $_POST['receiver_email'];
$payer_email = $_POST['payer_email'];
if (!$fp) {
// HTTP ERROR
else {
fputs ($fp, $header . $req);
while (!feof($fp)) {
$res = fgets ($fp, 1024);
if (strcmp ($res, "VERIFIED") == 0) {
// 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
}
else if (strcmp ($res, "INVALID") == 0) {
// log for manual investigation
}
}
fclose ($fp);
}
?>
相關(guān)文章
PHP7實(shí)現(xiàn)和CryptoJS的AES加密方式互通示例【AES-128-ECB加密】
這篇文章主要介紹了PHP7實(shí)現(xiàn)和CryptoJS的AES加密方式互通操作,結(jié)合實(shí)例形式分析了PHP AES-128-ECB加密算法相關(guān)使用技巧,需要的朋友可以參考下2019-06-06thinkphp中連接oracle時(shí)封裝方法無法用的解決辦法
本篇文章是對thinkphp中連接oracle時(shí)封裝方法無法用的解決方法進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下2013-06-06PHP面向?qū)ο蟪绦蛟O(shè)計(jì)之命名空間與自動加載類詳解
這篇文章主要介紹了PHP面向?qū)ο蟪绦蛟O(shè)計(jì)之命名空間與自動加載類,結(jié)合實(shí)例形式分析了php命名空間與自動加載類的概念、功能、使用方法與相關(guān)注意事項(xiàng),需要的朋友可以參考下2016-12-12