Reply
Highlighted
Member
Posts: 1
Registered: ‎02-14-2012

ARB transaction and Silent Post on testing

I've searching all around this forum and documentation to find out a functional procedure on testing Silent Post sent by individual transaction generated by ARB subscription.

 

I am developing an website where users can subscribe for one of three subscription plans.

I am using ARB API from Authorize.net: so far all good.

The problems appear when I want to let users to change their subscription plan on site.
As I understand Authorize.net APIs, the ARB subscription can not be updated with interval unit and length ("The subscription interval information (subscription.paymentSchedule.interval.length and subscription.paymentSchedule.interval.unit) may not be updated.").

 

So in order to let my users to change their plan (subscription), I planned to cancel current ARB subscription and create new ARB subscription but with the start date  equal to the end date of current interval (eg, if subscription is monthly and the plan is changed in the middle of month, than the end date of current month will be the start for new plan user has selected;

 

But not this is the issue.

The main issue and reason of this post is the way I can check subscription status and transactions using APIs.

After searching the documentation and the community forum, I know that via API my application can check only ARB subscription status but  application can not check transactions status.
Also, I know that there is sent a Silent Post and my application can handle the post, providing an accessible URL.

But here comes the problem: I provided the URL and set up as indicated and via Virtual Terminal I entered a transaction with real credit card. BUT no Silent Post encountered.

 

The URL provided had been tested with a mockup form as community suggests.

My question is this

 

How can I test Silent Post on sandbox.authorize.net (developer) or even live, such way I can relay 100% on Silent Post?

As I mentioned, I had test by entering a transaction on account.authorize.net (live), so real server with real card, but with no result. So, how we can test Silent Post? How we can access via API transactions?

 

Thanks,

Highlighted
Posts: 1,609
Topics: 15
Kudos: 201
Solutions: 121
Registered: ‎06-23-2011

Re: ARB transaction and Silent Post on testing

I don't understand why you need to make a new subscription, unless the new subscription has a different interval (like 2 months instead of 1). Just set the subscription to endless (length of 9999) and keep track in your database of how many payments have been charged. Turn it off when it hits the end.

 

As for testing silent post - it's been a while, so I don't remember exactly what I did, but I believe the first step was to set up my silent post page on a developer account in live mode and run some AIM transactions through to get an idea of how the fields were arranged, logging the output to a file. Then when I figured I had the framework set up ok and the AIM transactions were being logged, I switched to my production account, set up a subscription with my credit card, and let it run one transaction. With logging, this allowed me to do the further tweaks I needed. Here's a fairly basic version you can start with, if you're using PHP:

 

<?php
// My database connection and query functions are here
require_once($_SERVER['DOCUMENT_ROOT'] . '/library/mysql.php');

$logfile = "{$_SERVER['DOCUMENT_ROOT']}/logs/callback.txt";
$handle = fopen($logfile, 'a');

// Eliminate fields you don't want to log
foreach (array('x_method', 'x_account_number', 'x_phone', 'x_fax', 'x_email', 'x_invoice_num', 'x_type', 'x_ship_to_first_name', 'x_ship_to_last_name', 'x_ship_to_company', 'x_ship_to_address', 'x_ship_to_city', 'x_ship_to_state', 'x_ship_to_zip', 'x_ship_to_country', 'x_tax', 'x_duty', 'x_freight', 'x_tax_exempt', 'x_po_num', 'x_cvv2_resp_code', 'x_cavv_response', 'x_test_request') as $key)
    unset($_POST[$key]);

fwrite($handle, print_r($_POST, true));

// --------------------------------------------

// Only my ARB subscriptions have a customer ID attached
if ($_POST['x_response_code'] == 1 && $_POST['x_cust_id']) {
    if (!$link = db_connect()) {
        fwrite($handle, "Unable to connect to database.\n");
        exit;
    }

    // Log payment entry in database
    $query = queryMysql("
    INSERT INTO payments SET company = {company}, payment = {payment}, type = 'MONTHLY', paid = NOW()",
    array(
        company => $_POST['x_cust_id'],
        payment => $_POST['x_amount']
    ));

    if (!$result = mysql_query($query, $link))
        fwrite($handle, "ERROR: Unable to add payment record to database.\n");
    else
        fwrite($handle, "Payment record added to database.\n");

    $query = queryMysql("
    UPDATE companies SET payment_due = payment_due + INTERVAL 1 MONTH WHERE idn = {company}",
    array(
        company => $_POST['x_cust_id']
    ));

    if (!$result = mysql_query($query, $link))
        fwrite($handle, "ERROR: Unable to update company expiration date.\n");
    else
        fwrite($handle, "Company expiration date updated.\n");
}
else fwrite($handle, "ERROR: Bad response code and/or missing customer ID.\n");

// So I can see if it works without syntax errors when I call it myself
print 'Ran';
?>