cancel
Showing results for 
Search instead for 
Did you mean: 

Several problems with ARB (Automated Recurring Billing):

First of all, I've discovered that there doesn't seem to be any test mode for ARB? How am I supposed to test my code in the first place? Secondly, the ARB integration code for PHP, unlike the AIM code, seems to be organized around an XML structure, and there doesn't seem to be any PHP-specific documentation that I can find (aside from the small files that came with the PHP SDK). With those two things put together, it's very hard to figure out if I'm doing this the right way or the "best" way.

 

Here's what I did for AIM, which worked fine:

 

    $authorize = new AuthorizeNetAIM(
        $GLOBALS['_authorize_id'], $GLOBALS['_authorize_key']);
    $authorize->setSandbox(true);
        
    $fields = array(
        'first_name' => $_POST['first'],
        'last_name' => $_POST['last'],
        'company' => $_POST['company'],
        'address' => $_POST['address'],
        'city' => $_POST['city'],
        'state' => $_POST['state'],
        'zip' => $_POST['zip'],
        'country' => 'US',

        'phone' => $_POST['phone'],
        'email' => $_POST['email'],

        'customer_ip' => $_SERVER['REMOTE_ADDR'],

        'description' => 'My Description Here',
        'amount' => $_POST['amount'],

        'card_num' => $_POST['card_number'],
        'exp_date' => sprintf('%02d%02d', $_POST['card_exp_month'], ($_POST['card_exp_year'] % 1000)),
        'card_code' => $_POST['card_ccv']
    );
    $authorize->setFields($fields);    
    $authorize->setCustomField('payment_type', 'SINGLE');

    $result = $authorize->authorizeAndCapture();

    if ($result->error || $result->{'response_code'} != 1)
        print "Declined - {$result->response_reason_text}\n";
    else
        print "Success! - {$result->transaction_id}\n";

 

You will notice that all the field names are simple and can be assigned as an array. Now we come to my test code for ARB:

 

    $authorize = new AuthorizeNetARB(
        $GLOBALS['_authorize_id'], $GLOBALS['_authorize_key']);
    $authorize->setSandbox(true);

    $subscription = new AuthorizeNet_Subscription;

    $subscription->billToFirstName = $_POST['first'];
    $subscription->billToLastName = $_POST['last'];
    $subscription->billToCompany = $_POST['company'];
    $subscription->billToAddress = $_POST['address'];
    $subscription->billToCity = $_POST['city'];
    $subscription->billToState = $_POST['state'];
    $subscription->billToZip = $_POST['zip'];
    $subscription->billToCountry = 'US';

    $subscription->customerPhoneNumber = $_POST['phone'];
    $subscription->customerEmail = $_POST['email'];

    $subscription->name = 'Platinum Subscription';
    $subscription->orderDescription = 'For 123 zip codes with 45,700 total estimated population';
    $subscription->amount = $_POST['amount'];

    $subscription->startDate = '2011-07-01';
    $subscription->intervalLength = '1';
    $subscription->intervalUnit = 'months';
    $subscription->totalOccurrences = '9999';

    $subscription->creditCardCardNumber = $_POST['card_number'];
    $subscription->creditCardExpirationDate = sprintf('%04d-%02d', $_POST['card_exp_year'], $_POST['card_exp_month']);
    $subscription->creditCardCardCode = $_POST['card_ccv'];

    $result = $authorize->createSubscription($subscription);

    print_r($result);

 

As you can see, these field names are long and complicated, and the structure of certain fields (according to what examples I could find) aren't even always the same. Credit card expiration, for instance. Is there a syntax similar to AIM that I can use, and if so, where's the documentation for it? How do I test my code, aside from running through real credit card transactions on a real account? Here's what happens when I try to run this using my own credit card info:

 

.....AuthorizeNetARB_Response Object
(
    [xml] => SimpleXMLElement Object
        (
            [messages] => SimpleXMLElement Object
                (
                    [resultCode] => Error
                    [message] => SimpleXMLElement Object
                        (
                            [code] => E00009
                            [text] => The payment gateway account is in Test Mode. The request cannot be processed.
                        )

                )

        )

    [response] => ErrorE00009The payment gateway account is in Test Mode. The request cannot be processed.
    [xpath_xml] => SimpleXMLElement Object
        (
            [messages] => SimpleXMLElement Object
                (
                    [resultCode] => Error
                    [message] => SimpleXMLElement Object
                        (
                            [code] => E00009
                            [text] => The payment gateway account is in Test Mode. The request cannot be processed.
                        )

                )

        )

)

 

 

 

TJPride
Expert
1 REPLY 1

Turned the test mode setting off inside my test account, it then accepted the subscription. Now I just have to figure out how to test the response and callback. The documentation is all about XML requests and doesn't really help much with using the PHP SDK code layered on top.

TJPride
Expert