[PHP]: Authorize.net支付成功后如何将交易明细存入数据库
[PHP]: How to save transaction details into database after successful payment in Authorize.net
我正在使用 Authorize.Net 集成在线信用卡 Processing.I 我正在使用单击提交按钮后将重定向到 Authorize.net hosted form 的表单。我的示例代码如下
<?PHP
$loginID = "My_LOGIN_ID";// login id
$transactionKey = "MY_TRANS_KEY";//transaction key
$amount = "19.99";
$description = "SAMPLE TRANSACTION";
$label = "Submit Payment";//label for submit button
$testMode = "false";
$url = "https://test.authorize.net/gateway/transact.dll";
$invoice = date(YmdHis);
$sequence = rand(1, 1000);
$timeStamp = time ();
if( phpversion() >= '5.1.2' )
{ $fingerprint = hash_hmac("md5", $loginID . "^" . $sequence . "^" . $timeStamp . "^" . $amount . "^", $transactionKey); }
else
{ $fingerprint = bin2hex(mhash(MHASH_MD5, $loginID . "^" . $sequence . "^" . $timeStamp . "^" . $amount . "^", $transactionKey)); }
?>
<form method='post' action='<?php echo $url; ?>' >
<input type='hidden' name='x_login' value='<?php echo $loginID; ?>' />
<input type='hidden' name='x_amount' value='<?php echo $amount; ?>' />
<input type='hidden' name='x_description' value='<?php echo $description; ?>' />
<input type='hidden' name='x_invoice_num' value='<?php echo $invoice; ?>' />
<input type='hidden' name='x_fp_sequence' value='<?php echo $sequence; ?>' />
<input type='hidden' name='x_fp_timestamp' value='<?php echo $timeStamp; ?>' />
<input type='hidden' name='x_fp_hash' value='<?php echo $fingerprint; ?>' />
<input type='hidden' name='x_test_request' value='<?php echo $testMode; ?>' />
<input type='hidden' name='x_show_form' value='<?php echo PAYMENT_FORM; ?>' />
<input type='submit' value='<?php echo $label; ?>' />
</form>
提交 Authorize.net hosted form 正确的信用卡和个人详细信息后,我收到如下交易成功消息
我也收到了包含交易详情的电子邮件。现在我想在交易成功后在我的数据库中保存交易详细信息,如交易 ID、发票号码、信用卡类型和客户详细信息。是否有任何后台进程将信息保存到数据库中?提前致谢。
您可以在 x_receipt_link_url 的 return URL 处理这些东西。您可以查看 How to configure 页面。
如果您使用 Receipt Link(并将 x_relay_response 设置为 false),则意味着您希望 Authorize.Net 简单地显示我们自己的收据页面并将定义的收据 link 放在页面底部。
您还必须在控制面板中配置 URL 才能成功将其指定为值。这是来自控制面板的文本(设置 -> 事务格式设置 -> 事务响应设置 -> Response/Receipt URL's)
我正在使用 Authorize.Net 集成在线信用卡 Processing.I 我正在使用单击提交按钮后将重定向到 Authorize.net hosted form 的表单。我的示例代码如下
<?PHP
$loginID = "My_LOGIN_ID";// login id
$transactionKey = "MY_TRANS_KEY";//transaction key
$amount = "19.99";
$description = "SAMPLE TRANSACTION";
$label = "Submit Payment";//label for submit button
$testMode = "false";
$url = "https://test.authorize.net/gateway/transact.dll";
$invoice = date(YmdHis);
$sequence = rand(1, 1000);
$timeStamp = time ();
if( phpversion() >= '5.1.2' )
{ $fingerprint = hash_hmac("md5", $loginID . "^" . $sequence . "^" . $timeStamp . "^" . $amount . "^", $transactionKey); }
else
{ $fingerprint = bin2hex(mhash(MHASH_MD5, $loginID . "^" . $sequence . "^" . $timeStamp . "^" . $amount . "^", $transactionKey)); }
?>
<form method='post' action='<?php echo $url; ?>' >
<input type='hidden' name='x_login' value='<?php echo $loginID; ?>' />
<input type='hidden' name='x_amount' value='<?php echo $amount; ?>' />
<input type='hidden' name='x_description' value='<?php echo $description; ?>' />
<input type='hidden' name='x_invoice_num' value='<?php echo $invoice; ?>' />
<input type='hidden' name='x_fp_sequence' value='<?php echo $sequence; ?>' />
<input type='hidden' name='x_fp_timestamp' value='<?php echo $timeStamp; ?>' />
<input type='hidden' name='x_fp_hash' value='<?php echo $fingerprint; ?>' />
<input type='hidden' name='x_test_request' value='<?php echo $testMode; ?>' />
<input type='hidden' name='x_show_form' value='<?php echo PAYMENT_FORM; ?>' />
<input type='submit' value='<?php echo $label; ?>' />
</form>
提交 Authorize.net hosted form 正确的信用卡和个人详细信息后,我收到如下交易成功消息
我也收到了包含交易详情的电子邮件。现在我想在交易成功后在我的数据库中保存交易详细信息,如交易 ID、发票号码、信用卡类型和客户详细信息。是否有任何后台进程将信息保存到数据库中?提前致谢。
您可以在 x_receipt_link_url 的 return URL 处理这些东西。您可以查看 How to configure 页面。
如果您使用 Receipt Link(并将 x_relay_response 设置为 false),则意味着您希望 Authorize.Net 简单地显示我们自己的收据页面并将定义的收据 link 放在页面底部。
您还必须在控制面板中配置 URL 才能成功将其指定为值。这是来自控制面板的文本(设置 -> 事务格式设置 -> 事务响应设置 -> Response/Receipt URL's)