Php 如何使用txn_id防止paypal重复付款?
所以我使用的是PHP cURL和PayPal IPN 我不想让我的顾客误付两次钱。我听说我可以用txn_id来做,但我不知道怎么做 这是我的密码Php 如何使用txn_id防止paypal重复付款?,php,curl,paypal,Php,Curl,Paypal,所以我使用的是PHP cURL和PayPal IPN 我不想让我的顾客误付两次钱。我听说我可以用txn_id来做,但我不知道怎么做 这是我的密码 <?php // connecting to database // Prepare the URL to send via cURL $req = 'cmd=_notify-validate'; if(function_exists('get_magic_quotes_gpc')) { $get_magic_quotes_exist
<?php
// connecting to database
// Prepare the URL to send via cURL
$req = 'cmd=_notify-validate';
if(function_exists('get_magic_quotes_gpc')) {
$get_magic_quotes_exists = true;
}
foreach ($_POST as $key => $value) {
if($get_magic_quotes_exists == true && get_magic_quotes_gpc() == 1) {
$value = urlencode(stripslashes($value));
} else {
$value = urlencode($value);
}
$req .= "&$key=$value";
}
// Initial cURL
$ch = curl_init();
// Set opt
curl_setopt($ch, CURLOPT_URL,"https://www.paypal.com/cgi-bin/webscr");
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_FORBID_REUSE, 1);
// Return result
$result = curl_exec($ch);
// Close cURL connection
curl_close($ch);
// If condition
if($result == "VERIFIED"){
// perform database update
}
?>
如何防止买家多次付款?您提供的代码是针对PayPal IPN的,我认为这对避免重复付款没有什么帮助。相反,我建议您将发票添加到付款数据中。由于PayPal系统默认阻止使用相同发票ID的付款,我希望这可以帮助您避免您的客户错误地支付两次 如果您正在整合PayPal支付标准,请查看下页的变量列表 如果您正在集成PayPal Express结账,请查看以下页面
我之所以这样问,是因为我在某个地方读到,我可以阻止使用txn\u id进行两次付款和脚本运行。你认为上面的代码工作正常吗?我不认为上面的代码用于txn\u id检查,或者实际上我没有听说如何防止使用txn\u id重复付款。在我看来,发票id是实现这一点的更好方法。嗨,伙计们。我刚刚了解到txn_id将阻止两次更新您的数据库,但不会阻止付款。我刚知道。