gpt4 book ai didi

html - 整合 Paypal

转载 作者:太空狗 更新时间:2023-10-29 14:50:00 31 4
gpt4 key购买 nike

我已经成功集成了 PayPal。一切正常。但我希望我的表格在成功付款后重定向到我的网站。另一个问题:如何从 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 和自动返回 url。在个人资料选项卡下的网站支付偏好和即时支付通知部分。

下面我添加了成功付款后发送到您网站的示例 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);
}
?>

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

<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 监听器的概述:

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

希望这对您有所帮助。

关于html - 整合 Paypal ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7188644/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com