gpt4 book ai didi

php - 在 paypal 表单中添加自定义隐藏字段并在重定向页面上获取它

转载 作者:行者123 更新时间:2023-11-29 07:03:50 25 4
gpt4 key购买 nike

我想在 paypal 处理成功后(在重定向页面上)立即获取用户信息(电子邮件)和 paypal 账单信息(定价、数量),然后插入到 mysql 表中。

我还使用了 <input type="hidden" name="notify_url">在立即购买按钮中设置它的值(value),例如:

<form action="https://www.paypal.com/cgi-bin/webscr" method="post" id="lf2">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="xxxxx">
<input type="hidden" name="custom">
<input type="hidden" name="notify_url">
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>

$notify_url='http://mysite.com/ipn/index.php?order_sld=123';

<script language="javascript">
document.getElementsByName('custom').value='123';
document.getElementsByName('notify_url').value='<?=$notify_url?>';

document.forms['lf2'].submit();
</script>

我的 ipn/index.php 脚本是:

function FetchOrder()
{
$array = array();

$array['transactionID']=$_POST["txn_id"];
$array['item']=$_POST["item_name"];
$array['amount']=$_POST["mc_gross"];
$array['currency']=$_POST["mc_currency"];
$datefields=explode(" ",$_POST["payment_date"]);
$array['time']=$datefields[0];
$array['date']=str_replace(",","",$datefields[2])." ".$datefields[1]." ".$datefields[3];
$array['timestamp']=strtotime($array['date']." ".$array['time']);
$array['status']=$_POST["payment_status"];
$array['firstname']=$_POST["first_name"];
$array['lastname']=$_POST["last_name"];
$array['email']=$_POST["payer_email"];
$array['custom']=$_POST["option_selection1"];
$array['sld']=$_POST["notify_url"];

if ($array['transactionID'] AND $array['amount']) {
return send_email($array);
} else {
return 0;
}
}

/**
* Send email
*/
function send_email($array)
{
$to = "webspot49@gmail.com";
$email = "webspot17530@gmail.com";
$name = "Sajid";

$subject = "Testing Paypal IPN";

$msg = "<table>
<tr><td>Transaction ID: </td><td>".$array['transactionID']."</td></tr>
<tr><td>Item: </td><td>".$array['item']."</td></tr>
<tr><td>Amount: </td><td>".$array['amount']."</td></tr>
<tr><td>Currency: </td><td>".$array['currency']."</td></tr>
<tr><td>Time: </td><td>".$array['time']."</td></tr>
<tr><td>Date: </td><td>".$array['date']."</td></tr>
<tr><td>Timestamp: </td><td>".$array['timestamp']."</td></tr>
<tr><td>Status: </td><td>".$array['status']."</td></tr>
<tr><td>First Name: </td><td>".$array['firstname']."</td></tr>
<tr><td>Last Name: </td><td>".$array['lastname']."</td></tr>
<tr><td>Email: </td><td>".$array['email']."</td></tr>
<tr><td>Custom: </td><td>".$array['custom']."</td></tr>
<tr><td>SLD: </td><td>".$array['sld']."</td></tr>
</table>";

// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

// Additional headers
$headers .= "From: $name <$email>" . "\r\n";
// Mail it to client.
mail($to, $subject, $msg, $headers);
return 1;
}
FetchOrder();

但邮件只包含:

Transaction ID:     6BD19776WW7238524
Item:
Amount: 12.00
Currency: USD
Time: 04:04:21
Date: 05 Jan 2012
Timestamp: 1325761461
Status: Completed
First Name: ABC
Last Name: XYZ
Email: abc@gmail.com
Custom:
SLD:

请指点一下哪里出了问题...

最佳答案

这对你来说有意义吗?

Get information from PayPal after a transaction

并且...取自已接受的答案:

http://www.ngcoders.com/php/selling-digital-goods-with-paypal-ipn-and-php

当然要归功于@JasonWilliams。

关于php - 在 paypal 表单中添加自定义隐藏字段并在重定向页面上获取它,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8570539/

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