0

ライブの auth.net e コマース カートにサイレント レスポンスを設定しようとしています。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 として送信されない理由を知っている人はいますか?

4

2 に答える 2

0

アカウントに設定ミスがあるはずです。Silent Post は Get データを送信しません。示されているように投稿するだけです。おそらくすでにチェック済みですが、念のため:

  1. この機能を使用していない場合は、デフォルトのリレー応答 URL が設定されていないことを確認してください
  2. ログエントリが実際のトランザクションに対応していることを確認してください。「悪い人」がサイレント ポストの URL に ping を送信することがあります。そのため、GET リクエストのチェックを追加し、それらをドロップします。
  3. 自分でサイレント URL に投稿して、print_r($_POST) を試みます。それが機能することを確認してください。
  4. MD5 ハッシュを Auth.net インターフェイスに追加し、トランザクションを実行して、値を取得しているかどうかを確認します。
于 2011-12-06T21:57:42.977 に答える
0

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>
于 2011-12-06T21:52:55.707 に答える