Merchant Account Services

Archive for the 'Programmers Toolbox' Category

Building a Recurring Billing System

Wednesday, May 2nd, 2023

Ever since Authorize.Net released the Automated Recurring Billing API we have had the fortunate experience of integrating quite a few gateways that utilize this new functionality. As we have delved further into the needs of each client it became apparent just how much thought must go into a recurring billing system.

At first glance the ARB API seems to be very sparse in terms of functionality and you would be right. They limit the calls to their system to:

  • Creating new ARB subscriptions
  • Editing existing subscriptions
  • Deleting existing ARB subscriptions

So why is this new API considered so useful? Because those three ARB functions allow us to do everything we need when combined with our own recurring billing system.

So what would our recurring billing system need to do? It would need to:

  1. Manage our subscription IDs
  2. Track customer credit card expiration dates
  3. Notify customers of their credit card’s expiration date
  4. Allow customers to change the credit card associated with their subscription
  5. Alter the amount of a recurring billing subscription
  6. Delete a subscription

Over the next few blog posts we will explore the needs of our recurring billing subscription system and how we will use the Authorize.Net ARB API along with our own subscription tracking system to make a robust subscription application.

Authorize.Net Launches Recurring Billing API

Thursday, February 8th, 2023

Today Authorize.Net released their API for their recurring billing feature of their payment gateway. This feature has been eagerly awaited by businesses who wish to automate the process of establishing recurring billing accounts without having to manually set up each account or, even more importantly, did not want to store credit card information of their customers until they had an opportunity to establish their recurring billing account.

Examples of businesses you could take advantage of this are:

  • Webhosting
  • Subscription based websites

Naturally we wasted no time and created our own class to access their API. Here is an example of how to use this class to create a recurring billing account. It should be noted that this class defaults to monthly recurring billing that starts one month from when the recurring billing account is created and will run for three years. You can change this by passing different values to the class before creating the account.


try
{
require_once("AuthnetARB.class.php");

$arb = new AuthnetARB();
$arb -> setParameter(’amount’, 1.00);
$arb -> setParameter(’refId’, 1242);
$arb -> setParameter(’cardNumber’, ‘5424000000000015′);
$arb -> setParameter(’expirationDate’, ‘ 2024 -05′);
$arb -> setParameter(’firstName’, ‘Jim’);
$arb -> setParameter(’lastName’, ‘Conners’);
$arb -> setParameter(’subscrName’, ‘Test Account’);
$arb -> createAccount();

echo $arb -> getResponse();
}
catch (AuthnetARBException $e)
{
$debug = $e->getTrace();
die(”Exception occurred: ” . $e->getMessage() . “. File: ” .
$debug[0][’file’] . ” on line ” . $debug[0][’line’]);
}

Hopefully this is enough to get you started in accessing the Authorize.Net Recurring Billing API. You can be sure an article will follow that will go into further detail about using this feature and API.

You can download the PDFPDF of their integration guide from your control panel.

You can download a beta version of our Authorize.Net Recurring Billing Class here. It is written in PHP 5 but can easily be converted to PHP 4.

Technorati Tags: , , , , , ,

New Article: Integrate the Authorize.net Payment Gateway with PHP

Tuesday, November 21st, 2023

It is our pleasure to announce our first article aimed directly at web developers. Integrate the Authorize.net Payment Gateway with PHP walks developers through the process of identifying the steps of an online credit card process both from a programmatic point of view as well as a technical point of view (from web page to processor and back again). It then explains how credit card related data should be validated before being used for payment.

The heart of the article lies in the PHP code that is developed along the way. A class is created that handles everything from sending the data to the Authorize.net API to receiving and handling the response. The client side code can be as little a just a few lines of code to successfully process a transaction. Because the code is designed to be modular it can be easily reused in any web application without having to rewrite any portion of it.

So check out Integrate the Authorize.net Payment Gateway with PHP and let us know what you think.

Verifying CVV2 Numbers

Monday, July 31st, 2023

When accepting credit cards through a website, collecting the CVV2 number is essential. (If you don’t know what CVV2 is, read the blog entry “What is CVV2?“). In the ecommerce world it is an important indicator as to the potential for fraud for a transaction.

As covered in our previous blog entry, this value may be three or four digits depending on which credit card the customer is using. So how do we validate it? By checking to see which credit card the customer is using and then looking for the correct amount of digits. We’ll find out which credit card the customer is using by looking at the first number of the credit card. We’ll specifically look for American Express cards as they are the odd balls and have a four digits CVV2 number. Visa, MasterCard, and Discover Card each have a three digit CVV2 number.

We’ll take the first digit of the credit card number and then check to see if it is a three. (We didn’t do it here but you should first validate that you do indeed have a valid credit card number. See “Verifying Credit Cards Numbers Are Valid” and “Verifying Credit Cards Numbers Are Valid (Part 2)” for how you can do this). If it is a three, check to see if the CVV2 code is four digits long. Otherwise, check to see if the CVV2 code is three digits long.

Below is some sample code in PHP:


$cc_number = $_POST['cc_number'];
$cvv2 = $_POST['cc_cvv'];
$first_number = substr($cc_number, 0, 1);
if ($first_number == 3)
{
if (!preg_match("/^\d{4}$/", $cvv2))
{
// It's an American Express card but its
// CVV2 code is not four digits long.
}
}
else
{
if (!preg_match("/^\d{3}$/", $cvv2))
{
// It's not three digits long.
}
}

Integrating the Authorize.net Payment Gateway

Friday, July 7th, 2023

The Authorize.net gateway is so popular that every major shopping cart, and minor ones, too, offer built in support for its services. But not every ecommerce solution uses an out-of-the-box solution. In these cases their developer coding the project will need to write their own code to interact with Authorize.net’s API. Typically interacting with any API is moderately difficult to do and can be above the technical capabilities of some coders.

Fortunately, the process of interacting with the API offered by Authorize.net can be greatly simplified and the learning curve shortened thanks to the great support offered by Authorize.net. Outlined below are the tools offered by Authorize.net to developers to make integrating their gateway as simple as possible.

Step 1 - Request a Test Account

Naturally it is very difficult to develop any application without having all of the necessary components available for testing. A web developer who is integrating the Authorize.net gateway into an existing merchant account can use their instance of the merchant’s gateway and turn on test mode to test their application. But if you are a web developer who is developing your own software that will need to integrate with Authorize.net gateway, like a shopping cart, or wish to get into the ecommerce development arena, you will not have an Authorize.net account to test your code on.

Fortunately the developers at Authorize.net had the foresight to understand that not every developer will have an Authorize.net account to test on and will not want to wait until they have a customer to start writing their code. (Plus having a testing environment available for developers allows more applications to be certified thus potentially growing their marketshare). For these developers Authorize.net has a system in place for allowing developers to have fully functional test accounts to test their integration code.

You can request a test account by going to http://developer.authorize.net/testaccount/ and completing their short application. It takes about one business day to receive your account credentials which is why I recommend doing this step first. While you wait you can start writing your code using what can be found on step 2…

Step 2 - Download the Implementation Guide

While you wait for your test account credentials to be provided to you by Authorize.net, you should download the documentation which explains how to communicate with their API. Their documentation is in pdf format and can be downloaded here: Advanced Integration Method Integration Guide. It offers a clear explanation of all of their API calls and should explain what you need to do to communicate successfully.

Step 3 - Sample Code

If reading boring documentation is not the best way for you learn, Authorize.net offers yet another way to learn more about their API. You may request sample code to demonstrate how to connect successfully to their API. They offer sample code for ASP (VBScript), ASP.Net (Using C# or VB.NET), Cold Fusion, Java, Perl, and PHP. The code samples work so writing code to work with their API can be as simple as modifying their code.