我正在尝试为我的live auth.net电子商务购物车设置静音响应。来自Auth.net的Silent Post正在发生,但我没有得到任何数据。我写了一个快速脚本,只是为了记录交易的响应,所以我可以看到auth.net正在发送的内容。
$f = fopen('log.txt', 'a');
fwrite($f, 'new request: ');
fwrite($f, date('Y-m-d H:i'));
fwrite($f, ' ' . $_SERVER['REQUEST_METHOD']. ' ');
fwrite($f, ' ' . $_SERVER['QUERY_STRING']. ' ');
fwrite($f, ' ' . $_SERVER['REQUEST_URI']. ' ');
fwrite($f, print_r(http_get_request_headers(),1));
fwrite($f, print_r($_GET,1));
简单的甜蜜,应该给我一个结果吧?请注意我添加的GET打印,因为这是结果集:
new request: 2011-12-06 14:54 GET /authSilentResponse/ Array (
[Accept] => */*
[Host] => myhost.mydomain.com
[Connection] => Close ) Array ( )
所以,而不是邮件,一切都告诉我它应该是,我得到一个GET请求......
任何人都知道为什么这不会作为带有数据的POST来实现?
答案 0 :(得分:0)
我认为你在某处做错了,因为Silent Post总是使用POST请求提交交易结果。 Try the code I have written并查看它是否适合您。如果是,您可以将代码与其进行比较,并查看潜在问题所在。
以下是可用于测试的修改版本:
<?php
// Get the subscription ID if it is available.
// Otherwise $subscription_id will be set to zero.
$subscription_id = (int) $_POST['x_subscription_id'];
// Check to see if we got a valid subscription ID.
// If so, do something with it.
if ($subscription_id)
{
// Get the response code. 1 is success, 2 is decline, 3 is error
$response_code = (int) $_POST['x_response_code'];
// Get the reason code. 8 is expired card.
$reason_code = (int) $_POST['x_response_reason_code'];
if ($response_code == 1)
{
// Approved!
// Some useful fields might include:
// $authorization_code = $_POST['x_auth_code'];
// $avs_verify_result = $_POST['x_avs_code'];
// $transaction_id = $_POST['x_trans_id'];
// $customer_id = $_POST['x_cust_id'];
$result = 'approved';
}
else if ($response_code == 2)
{
// Declined
$result = 'declined';
}
else if ($response_code == 3 && $reason_code == 8)
{
// An expired card
$result = 'expired';
}
else
{
// Other error
$result = 'error';
}
$f = fopen('log.txt', 'a');
fwrite($f, 'new request: ');
fwrite($f, date('Y-m-d H:i'));
fwrite($f, ' ' . $_SERVER['REQUEST_METHOD']. "\n\n");
fwrite($f, ' ' . $_SERVER['QUERY_STRING']. "\n\n");
fwrite($f, ' ' . $_SERVER['REQUEST_URI']. "\n\n");
fwrite($f, ' ' . $result. "\n\n");
fwrite($f, print_r(http_get_request_headers(),1));
fwrite($f, print_r($_REQUEST,1));
}
?>
您可以使用this form
进行测试<form action="http://www.yourdomain.com/silent-post.php" method="post">
<input type="hidden" name="x_response_code" value="1"/>
<input type="hidden" name="x_response_subcode" value="1"/>
<input type="hidden" name="x_response_reason_code" value="1"/>
<input type="hidden" name="x_response_reason_text" value="This transaction has been approved."/>
<input type="hidden" name="x_auth_code" value=""/>
<input type="hidden" name="x_avs_code" value="P"/>
<input type="hidden" name="x_trans_id" value="1821199455"/>
<input type="hidden" name="x_invoice_num" value=""/>
<input type="hidden" name="x_description" value=""/>
<input type="hidden" name="x_amount" value="9.95"/>
<input type="hidden" name="x_method" value="CC"/>
<input type="hidden" name="x_type" value="auth_capture"/>
<input type="hidden" name="x_cust_id" value="1"/>
<input type="hidden" name="x_first_name" value="John"/>
<input type="hidden" name="x_last_name" value="Smith"/>
<input type="hidden" name="x_company" value=""/>
<input type="hidden" name="x_address" value=""/>
<input type="hidden" name="x_city" value=""/>
<input type="hidden" name="x_state" value=""/>
<input type="hidden" name="x_zip" value=""/>
<input type="hidden" name="x_country" value=""/>
<input type="hidden" name="x_phone" value=""/>
<input type="hidden" name="x_fax" value=""/>
<input type="hidden" name="x_email" value=""/>
<input type="hidden" name="x_ship_to_first_name" value=""/>
<input type="hidden" name="x_ship_to_last_name" value=""/>
<input type="hidden" name="x_ship_to_company" value=""/>
<input type="hidden" name="x_ship_to_address" value=""/>
<input type="hidden" name="x_ship_to_city" value=""/>
<input type="hidden" name="x_ship_to_state" value=""/>
<input type="hidden" name="x_ship_to_zip" value=""/>
<input type="hidden" name="x_ship_to_country" value=""/>
<input type="hidden" name="x_tax" value="0.0000"/>
<input type="hidden" name="x_duty" value="0.0000"/>
<input type="hidden" name="x_freight" value="0.0000"/>
<input type="hidden" name="x_tax_exempt" value="FALSE"/>
<input type="hidden" name="x_po_num" value=""/>
<input type="hidden" name="x_MD5_Hash" value="A375D35004547A91EE3B7AFA40B1E727"/>
<input type="hidden" name="x_cavv_response" value=""/>
<input type="hidden" name="x_test_request" value="false"/>
<input type="hidden" name="x_subscription_id" value="365314"/>
<input type="hidden" name="x_subscription_paynum" value="1"/>
<input type="submit"/>
</form>
答案 1 :(得分:0)
您的帐户中必定存在一些错误配置。 Silent Post不会向您发送获取数据。按照指示张贴。您可能已经检查过,但以防万一: