授权.网络沉默的帖子没有响应预期-没有数据


Authorize.Net Silent Post not Responding as expected - no data at all

我正在尝试为我的live auth.net电子商务购物车设置静音响应。来自Auth.net的沉默帖子正在发生,但我没有得到任何数据。我写了一个快速的脚本,只是为了记录交易的响应,这样我就可以看到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…

有人知道为什么这不会通过POST与数据?

您的帐户一定是配置错误。Silent Post不发送Get数据。按指示发布即可。你可能已经检查过了,但以防万一:

  1. 检查默认中继响应URL没有设置,如果你不使用的功能
  2. 检查以确保日志条目与实际事务相对应。有时会有"坏人"ping我们的静默帖子url。出于这个原因,我们为GET请求添加一个检查并删除它们
  3. 尝试自己发送到您的静默url并打印t_r($_POST)。
  4. 在Auth.net接口中添加MD5哈希值,运行一个交易,看看你是否得到了值。

我认为你在某个地方做错了,因为Silent Post总是使用Post请求提交交易结果。试试我写的代码,看看它是否更适合你。如果是,你可以比较你的代码和它,看看潜在的问题在哪里。

这是一个修改后的版本,你可以用于测试:

<?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));
}
?>

您可以使用下面的表单进行测试:

<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>