authorize-net-arb
Authorize.net Automated Recurring Billing (ARB) support for nodejs. Check out Authorize.net's ARB page for more info about their service. You will need to be familiar with the ARB XML API (PDF) in order to know what fields are appropriate to use and when to use them.
Usage
First off, you will need to create an ARB client object with your API login ID and transaction key.
var arb = ;var arbClient = arb;
You can also use ARB in sandbox mode. All requests will go to Authorize.net's sandbox server after this mode is enabled.
var arb = ;arb;
Methods
All methods take two parameters. The first is an object whose properties closely mirror the nodes of the "request" XML documents of each API call described in Authorize.net's documentation. The second is a callback that receives two parameters: an error object and a response object. If the operation was successful, the error parameter will have a value of undefined
. The response parameter will contain any non-error related info returned by the API call.
This library makes no effort to make sure the values you specify in your request are well formed before sending it. You must adhere to the rules outlined in Authorize.net's documentation.
Create Subscription
var arb = ;var arbClient = arb; var request = refId: "my-ref" subscription: name: "my-subscription" order: invoiceNumber: "inv-0001" description: "My Subscription" paymentSchedule: interval: length: 1 unit: "months" startDate: "2015-01-31" totalOccurrences: 9999 trialOccurrences: 1 amount: 1999 trialAmount: 0 payment: creditCard: cardNumber: "4111111111111111" expirationDate: "2020-01" cardCode: "111" customer: id: "abc123" email: "jane.doe@example.com" phoneNumber: "555-555-5555" faxNumber: "555-555-5555" billTo: firstName: "Jane" lastName: "Doe" address: "123 Main St" city: "Anytown" state: "CA" zip: "11111" country: "US" shipTo: firstName: "Jane" lastName: "Doe" address: "123 Main St" city: "Anytown" state: "CA" zip: "11111" country: "US" ; arbClient;
If the call succeeds, the response
object will have the format:
refId: "my-ref" subscriptionId: "1234567890"
Update Subscription
var arb = ;var arbClient = arb; var request = refId: "my-ref" subscriptionId: "1234567890" subscription: name: "my-subscription" paymentSchedule: startDate: "2015-01-31" totalOccurrences: 9999 trialOccurrences: 1 amount: 1999 trialAmount: 0 payment: creditCard: cardNumber: "4111111111111111" expirationDate: "2020-01" cardCode: "111" customer: id: "abc123" billTo: firstName: "Jane" lastName: "Doe" address: "123 Main St" shipTo: firstName: "Jane" lastName: "Doe" address: "123 Main St" ; arbClient;
If the call succeeds, the response
object will have the format:
refId: "my-ref"
Get Subscription Status
var arb = ;var arbClient = arb; var request = refId: "my-ref" subscriptionId: "1234567890"; arbClient;
If the call succeeds, the response
object will have the format:
refId: "my-ref" status: "active|expired|suspended|canceled|terminated"
Cancel Subscription
var arb = ;var arbClient = arb; var request = refId: "my-ref" subscriptionId: "1234567890"; arbClient;
If the call succeeds, the response
object will have the format:
refId: "my-ref"
Errors
Error objects returned by method calls will generally have source
, refId
, and message
properties. If the error was returned by Authorize.net, it will usually have a code
property as well. If an unexpected response was received from the API server, a response
property with the entire response text should be present.