gpt4 book ai didi

php - Authorize.net SIM 接收数据并更新数据库

转载 作者:行者123 更新时间:2023-11-29 06:58:45 25 4
gpt4 key购买 nike

我已经注册了 Authorize.net 并且成功了:

  1. 将我的购物车转换为发送到 Authorize.net 并对其进行处理的数据。
  2. 使用中继响应,将用户发送到我的感谢页面。

一旦交易完成,我无法思考如何实际更新我的数据库。我要搜索什么术语来解决这个问题?几乎所有文档都显示了解决方案的一部分,但实际上并未说明将其放置在何处以及如何将其取回。

在我的购物车页面上,我有一个 Authorize.net 提供的隐藏输入字段列表。我输入了我的美元金额、描述等。我假设我放置了另一个名为“x_po_num”的隐藏字段,并将该值作为我在数据库中的动态 PO#。

没有办法在感谢页面上实际检索它,所以我交叉引用数据库并简单地添加一个“已确认”或其他值吗?

如何检索发送到 Authorize.net 的值?

最佳答案

您获得的数据只是在一个$_POST 数组中,您可以通过var_dump() 查看它包含的值。

这是一个用 PHP 编写的示例中继响应脚本:

<?php

// Retrieving and defining Form Data from Post command body from Authorize.Net
$ResponseCode = trim($_POST["x_response_code"]);
$ResponseReasonText = trim($_POST["x_response_reason_text"]);
$ResponseReasonCode = trim($_POST["x_response_reason_code"]);
$AVS = trim($_POST["x_avs_code"]);
$TransID = trim($_POST["x_trans_id"]);
$AuthCode = trim($_POST["x_auth_code"]);
$Amount = trim($_POST["x_amount"]);

?>

<html>
<head>
<title>Transaction Receipt Page</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head>
<body bgcolor="#FFFFFF">

<?php
// Test to see if this is a test transaction.
if ($TransID === 0 && $ResponseCode === 1)
{
// If so, print it to the screen, so we know that the transaction will not be processed.
?>

<table align="center">
<tr>
<th><font size="5" color="red" face="arial">TEST MODE</font></th>
<tr>
<th valign="top"><font size="1" color="black" face="arial">This transaction will <u>NOT</u> be processed because your account is in Test Mode.</font></th>
</tr>
</table>

<?php
}
?>

<br>
<br>

<?php
// Test to see if the transaction resulted in Approvavl, Decline or Error
if ($ResponseCode === 1)
{
?>

<table align="center">
<tr>
<th><font size="3" color="#000000" face="Verdana, Arial, Helvetica, sans-serif">This transaction has been approved.</font></th>
</tr>
</table>

<?php
}
else if ($ResponseCode === 2)
{
?>

<table align="center">
<tr>
<th width="312"><font size="3" color="#000000" face="Verdana, Arial, Helvetica, sans-serif">This transaction has been declined.</font></th>
</tr>
</table>

<?php
}
else if ($ResponseCode === 3)
{
?>

<table align="center">
<tr>
<th colspan="2"><font size="3" color="Red" face="Verdana, Arial, Helvetica, sans-serif">There was an error processing this transaction.</font></th>
</tr>
</table>

<?php
}
?>

<br>
<br>
<table align="center" width="60%">
<tr>
<td align="right" width=175 valign=top><font size="2" color="black" face="arial"><b>Amount:</b></font></td>
<td align="left"><font size="2" color="black" face="arial">$<?php echo $Amount; ?></td>
</tr>

<tr>
<td align="right" width=175 valign=top><font size="2" color="black" face="arial"><b>Transaction ID:</b></font></td><td align="left"><font size="2" color="black" face="arial">

<?php
if ($TransID === 0)
{
echo 'Not Applicable.';
}
else
{
echo $TransID;
}
?>

</td></tr>

<tr>
<td align="right" width=175 valign=top><font size="2" color="black" face="arial"><b>Authorization Code:</b></font></td><td align="left"><font size="2" color="black" face="arial">

<?php
if ($AuthCode === "000000")
{
echo 'Not Applicable.';
}
else
{
echo $AuthCode;
}
?>

</td></tr>
<tr>
<td align="right" width=175 valign=top><font size="2" color="black" face="arial"><b>Response Reason:</b></font></td><td align="left"><font size="2" color="black" face="arial">(<?php echo $ResponseReasonCode; ?>)&nbsp;<?php echo $ResponseReasonText; ?></font><font size="1" color="black" face="arial"></td></tr>
<tr>

<td align="right" width=175 valign=top><font size="2" color="black" face="arial"><b>Address Verification:</b></font></td><td align="left"><font size="2" color="black" face="arial">

<?php
// Turn the AVS code into the corresponding text string.
switch ($AVS)
{
case "A":
echo "Address (Street) matches, ZIP does not.";
break;
case "B":
echo "Address Information Not Provided for AVS Check.";
break;
case "C":
echo "Street address and Postal Code not verified for international transaction due to incompatible formats. (Acquirer sent both street address and Postal Code.)";
break;
case "D":
echo "International Transaction: Street address and Postal Code match.";
break;
case "E":
echo "AVS Error.";
break;
case "G":
echo "Non U.S. Card Issuing Bank.";
break;
case "N":
echo "No Match on Address (Street) or ZIP.";
break;
case "P":
echo "AVS not applicable for this transaction.";
break;
case "R":
echo "Retry. System unavailable or timed out.";
break;
case "S":
echo "Service not supported by issuer.";
break;
case "U":
echo "Address information is unavailable.";
break;
case "W":
echo "9 digit ZIP matches, Address (Street) does not.";
break;
case "X":
echo "Address (Street) and 9 digit ZIP match.";
break;
case "Y":
echo "Address (Street) and 5 digit ZIP match.";
break;
case "Z":
echo "5 digit ZIP matches, Address (Street) does not.";
break;
default:
echo "The address verification system returned an unknown value.";
break;
}
?>

</td>
</tr>
</table>
</body>
</html>

您还可以使用 Silent Post .这是一个 PHP tutorial这显示了如何使用它。

关于php - Authorize.net SIM 接收数据并更新数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11260472/

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