npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

authorize-net-arb

v0.0.4

Published

Authorize.net Automated Recurring Billing (ARB)

Downloads

16

Readme

authorize-net-arb

Build Status

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 = require("authorize-net-arb");
var arbClient = arb.client("my-api-login-id", "my-transaction-key");

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 = require("authorize-net-arb");
arb.useSandbox();

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 = require("authorize-net-arb");
var arbClient = arb.client("my-api-login-id", "my-transaction-key");

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: 19.99,
        trialAmount: 0,
        payment: {
            creditCard: {
                cardNumber: "4111111111111111",
                expirationDate: "2020-01",
                cardCode: "111"
            }
        },
        customer: {
            id: "abc123",
            email: "[email protected]",
            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.createSubscription(request, function(error, response) {
    if (error) {
        // handle error response
    } else {
        // handle success
    }
});

If the call succeeds, the response object will have the format:

{
    refId: "my-ref",
    subscriptionId: "1234567890"
}

Update Subscription

var arb = require("authorize-net-arb");
var arbClient = arb.client("my-api-login-id", "my-transaction-key");

var request = {
    refId: "my-ref",
    subscriptionId: "1234567890",
    subscription: {
        name: "my-subscription",
        paymentSchedule: {
            startDate: "2015-01-31",
            totalOccurrences: 9999,
            trialOccurrences: 1
        },
        amount: 19.99,
        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.updateSubscription(request, function(error, response) {
    if (error) {
        // handle error response
    } else {
        // handle success
    }
});

If the call succeeds, the response object will have the format:

{
    refId: "my-ref"
}

Get Subscription Status

var arb = require("authorize-net-arb");
var arbClient = arb.client("my-api-login-id", "my-transaction-key");

var request = {
    refId: "my-ref",
    subscriptionId: "1234567890"
};

arbClient.getSubscriptionStatus(request, function(error, response) {
    if (error) {
        // handle error response
    } else {
        // handle success
    }
});

If the call succeeds, the response object will have the format:

{
    refId: "my-ref",
    status: "active|expired|suspended|canceled|terminated"
}

Cancel Subscription

var arb = require("authorize-net-arb");
var arbClient = arb.client("my-api-login-id", "my-transaction-key");

var request = {
    refId: "my-ref",
    subscriptionId: "1234567890"
};

arbClient.cancelSubscription(request, function(error, response) {
    if (error) {
        // handle error response
    } else {
        // handle success
    }
});

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.