A few weeks ago I had to interface to Authorize.net’s recurring billing API. This is a new API they released early this year. Prior to this, if you wanted a recurring billing subscription setup, you had to log into their site and set it up manually.
When I went to begin coding I searched high and low for an existing custom tag or cfc, but did not find any. So now that mine is complete, I’ve posted it on RiaForge.
ColdFusion CFC for Authorize.net recurring billing API
There is a README file in the zip archive that has fairly detailed instructions, but here are the basics:
There are three methods: createSubscription(), updateSubscription(), and cancelSubscription().
First you must init the cfc, passing in your loginname, transaction key, and the mode which should be either “live” or “test”. When in test mode, requests are posted to Authorize.net’s special test server.
<cfset PaymentGateway = CreateObject("component","AuthorizeNetRecurring").init(
loginname = "AuthNetLoginName",
transactionKey = "YourTransactionKey",
mode = "live or test")>
<cfinvoke component="#PaymentGateway#" method="createSubscription" returnvariable="result">
<cfinvokeargument name="startDate" value="#DateFormat(Now(),"yyyy-mm-dd")#">
<cfinvokeargument name="customerEmail" value="#email#">
etc....
</cfinvoke>
Each method returns a structure containing the following keys:
| Key | Description |
| error | true or false. This is set internally based on what was returned from Authorize.net. Use this to see if the transaction was processed or not. |
| messagecode | Alpha-numeric code returned from Authorize.net. |
| messagetext | Message text returned from Authorize.net. Usually fairly descriptive. i.e. “The subscription cannot be found.” |
| resultcode | Usually something like “ok” or “error”. |
| returnedXml | The actual XML returned from Authorize.Net. Useful for debugging or detailed logging. |
You can download the Authorize.net recurring billing CFC from RIAForge.
And a “thanks” to my employer, CF WebTools for allowing me to give away this code.

Ian says:
Thanks for doing this. We have been using CF and Authorize for many years to do regular payments and credits.
We just recently started using Authorize for subscriptions so this will be great for integration.
11 September 2007, 1:10 pmrayrad says:
FYI: If your web server runs on Windows, my company just released a library for Authorize.Net’s recurring billing. It was built in C# on the .NET platform and you can call it as a COM or .NET object (note: if you want to call it through .NET, I believe you need CF8). It supports both AIM and ARB and is fully certified by Authorize.net.
We provide extensive documentation and code samples to aid users. It does cost $99, but that’s pretty cheap for the functionality it provides. It even has extras like line totaling, supporting MD5 Hash validation (for AIM payments), copying the billing to the shipping address, etc.
You can get more information at https://www.itdevworks.com/faq.aspx and download a trial version or the documentation from our site.
Dave Parker
30 November 2007, 4:09 pmIT DevWorks, LLC
http://www.itdevworks.com
Brian says:
Ryan, is it ok if we use this code in cfpayment with credits? http://cfpayment.riaforge.org.
22 January 2008, 5:18 pmRyan Stille says:
Yes you sure can. I meant to contact that project and point them to my cfc, but I forgot.
22 January 2008, 5:41 pmWerbeagentur says:
Thanks ryan for the great informations and for the download-page.
3 February 2008, 3:25 pmMany thanks from Germany, Werbeagentur
Rob says:
You rock! ‘Nuff said.
5 February 2008, 8:08 pmWerbeagentur says:
Again, a great Post!
7 March 2008, 1:19 amTypo3 Lambda Media says:
cool! thanks! go on!!
10 June 2008, 8:50 amLarry says:
I have the Authorize.net recurring billing API CFC working. One question.
Does authorize.net post anything back to me when the monthy subscription goes thru?
19 December 2008, 5:04 pm(Decline, expired, success, etc…)
If so
How do I capture this posted data so I can update my database?
Mary Jo Sminkey says:
@Larry – Just in case anyone else has this question, there is a setting in the AuthNet merchant area for a "silent post" URL, that is the page you would set up to receive the post back for each transaction.
11 February 2009, 2:38 pmJegan says:
Hi Ryan
Each method returns a structure containing the keys. Could you please tell how can we get these values.
16 June 2009, 2:39 amPlease send me sample code at jegan@idynamics.com
Ryan Stille says:
Jegan, just reference the keys in the returned structure. Like this:
<cfset tmp = MyObj.createSubscription(….. all your data here)>
<cfoutput>the new subscriber ID is #tmp.subscriptionId#, and the refID is #tmp.refId#</cfoutput>
If you dump the return value you can see everything that gets returned:
16 June 2009, 10:25 am<cfset tmp = MyObj.createSubscription(….. all your data here)>
<cfdump var=”#tmp#”>