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

840 views Asked by At

I am trying to set up silent response for my live auth.net e-commerce carts. The Silent Post from Auth.net is happening, but I am getting no data whatsoever. I wrote a quick script, just to log the responses from the transactions so I could see what auth.net was sending.

$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));

Simple sweet, should get me a result right? Note the printing of GET that I added, because this is the result set:

 new request: 2011-12-06 14:54 GET      /authSilentResponse/ Array (
     [Accept] => */*
     [Host] => myhost.mydomain.com
     [Connection] => Close ) Array ( )

So instead of the Post that everything tells me it should be, I am getting a GET request...

Anyone have any idea why this would not be coming through as a POST with data?

2

There are 2 answers

0
John Conde On

I think you're doing something wrong somewhere as Silent Post always submits transaction results using a POST request. Try the code I have written and see if it works better for you. If it does you can compare your code to it and see where the potential issue lies.

Here is a modified version you can use for testing:

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

You can test it out using 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>
0
Alexey Gerasimov On

There must be some misconfiguration in your account. Silent Post DOES NOT send you Get data. Just Post as indicated. You probably already checked but just in case:

  1. Check that Default Relay Response URL is not set if you're not using the feature
  2. Check to make sure that your log entries correspond to actual transactions. We've had 'bad people' ping our silent post urls at times. For that reason, we add a check for GET requests and drop them
  3. Try to post to your silent url yourself and print_r($_POST). Make sure that works.
  4. Add MD5 hash in Auth.net interface, run a transaction, and see if you're getting the value.