PHP Class For Authorize.net Automated Recurring Billing Payments API


‘m still testing and could find some small bugs which need to some polish, I’ll update this post and code if needed.

You will need to have an ARB enabled Authorize.net account, of course.

You can test the class with the following sample code:

<?php
  require_once("AuthnetARB.class.php");

$login = ‘cnpdev4289’; $transkey = ‘SR2P8g4jdEn7vFLQ’; $test = TRUE;

$arb = new AuthnetARB($login, $transkey, $test);

$arb->setParameter(‘interval_length’, 1); $arb->setParameter(‘interval_unit’, ‘months’); $arb->setParameter(‘startDate’, date(“Y-m-d”)); $arb->setParameter(‘totalOccurrences’, 12); $arb->setParameter(‘trialOccurrences’, 0); $arb->setParameter(‘trialAmount’, 0.00);

$arb->setParameter(‘amount’, 1.00); $arb->setParameter(‘refId’, 15); $arb->setParameter(‘cardNumber’, ‘5424000000000015’); $arb->setParameter(‘expirationDate’, ‘2009-05’);

$arb->setParameter(‘firstName’, ‘Joe’); $arb->setParameter(‘lastName’, ‘Doe’); $arb->setParameter(‘address’, ‘Casa 1872’); $arb->setParameter(‘city’, ‘City’); $arb->setParameter(‘state’, ‘FL’); $arb->setParameter(‘zip’, ‘33619’); $arb->setParameter(‘country’, ‘us’);

$arb->setParameter(‘subscrName’, ‘The Test Account’); $arb->createAccount();

echo ‘isSuccessful: ‘ .$arb->isSuccessful() . ‘<br />’;

if ($arb->isSuccessful()) { echo ‘cool, it worked! <br />’; } else { echo ‘error in payment <br />’; }

echo ‘isError: ‘ .$arb->isError() . ‘<br />’; echo ‘getSubscriberID: ‘ .$arb->getSubscriberID() . ‘<br />’; echo ‘getResponse: ‘ .$arb->getResponse() . ‘<br />’; echo ‘getResultCode:’ .$arb->getResultCode() . ‘<br />’; echo ‘getString: ‘ .$arb->getString() . ‘<br />’; echo ‘getRawResponse: ‘ .$arb->getRawResponse() . ‘<br />’; ?>

download class AuthnetARB.class.php

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s