html – 整合paypal

前端之家收集整理的这篇文章主要介绍了html – 整合paypal前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我已成功整合paypal帐户.一切都很好.但我希望当付款成功转移然后重定向到我的网站.另一个问题如何从贝宝获得回应?
这是我的贝宝形式.谢谢
`<form action="https://sandBox.paypal.com/cgi-bin/webscr" method="post">  
    <input type="hidden" name="business" value="savife_1314264698_biz@gmail.com ">  
    <input type="hidden" name="cmd" value="_xclick-subscriptions">  
    <input type="hidden" name="item_name" value="Alice's Weekly Digest">  
    <input type="hidden" name="item_number" value="DIG Weekly">  
    <input type="hidden" name="currency_code" value="USD">  
    <input type="hidden" name="notify_url" value="http://localhost/check.PHP">
    <input type="hidden" name="return" value="http://google.co.in">
    <input type="hidden" name="a3" value="5.00">  
    <input type="hidden" name="p3" value="1">  
    <input type="hidden" name="t3" value="M">  

    <!-- Display the payment button. -->  
    <input type="image" name="submit" border="0" src="btn_subscribe_LG.gif" alt="PayPal - The safer,easier way to pay online">  
    <img alt="" border="0" width="1" height="1" src="https://www.paypal.com/en_US/i/scr/pixel.gif" >  
</form>

解决方法

请仔细阅读:

您想要的是PAYPAL IPN,即时付款通知,在付款完成后发送到用户的网站.

https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_admin_IPNIntro

或者您也可以在购物车中设置IPN路径,paypal将发送通知,如下所示:

<input type="hidden" name="notify_url" value="site.com/ipn/index.PHP" />
<input type="hidden" name="return"     value="site.com/ipn/index.PHP"/>

但是您需要在paypal上登录您的商家帐户才能手动指定ipn和自动返回网址.在配置文件选项卡下的网站付款首选项和即时付款通知部分

我已经添加了成功付款后发送到您网站的示例ipn代码

// 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.sandBox.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);
}
?>

您需要在通知网址页面添加代码.您在购物车的通知网址字段中提到的返回页面,即

<input type="hidden" name="notify_url" value="site.com/ipn/index.PHP" />

将此代码放在site.com/ipn/index.PHP

让我们举一个购物车的例子:

<form action="https://sandBox.paypal.com/cgi-bin/webscr" method="post">  
    <input type="hidden" name="business" value="savife_1314264698_biz@gmail.com ">  
    <input type="hidden" name="cmd" value="_xclick-subscriptions">  
    <input type="hidden" name="item_name" value="Alice's Weekly Digest">  
    <input type="hidden" name="item_number" value="DIG Weekly">  
    <input type="hidden" name="currency_code" value="USD">  
    <input type="hidden" name="notify_url" value="http://localhost/check.PHP">
    <input type="hidden" name="return" value="http://google.co.in">
    <input type="hidden" name="a3" value="5.00">  
    <input type="hidden" name="p3" value="1">  
    <input type="hidden" name="t3" value="M">  

    <!-- Display the payment button. -->  
    <input type="image" name="submit" border="0" src="btn_subscribe_LG.gif" alt="PayPal - The safer,easier way to pay online">  
    <img alt="" border="0" width="1" height="1" src="https://www.paypal.com/en_US/i/scr/pixel.gif" >  
</form>

在这种情况下,paypal将发送ipn的通知URL是http://localhost/check.PHP.

所以将该代码放在check.PHP页面中.收到ipn后,您可以进一步使用它进入您的数据库等.

或者访问此链接获取paypal ipn listener的概述:

https://cms.paypal.com/uk/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_admin_IPNImplementation

希望这可以帮助.

猜你在找的HTML相关文章