How to integrate Authorization.net for payment in nodejs

Posted By : Mayank Tyagi | 26-Jun-2015

In order to integrate payment gateway using Authorization.net we need to install the authorization.net module of node npm install node-authorize-net .To create subscription using authorization.net we need to create account on authorization.net and for testing purpose create sandbox account on developer authorization.net create the Automated Recurring Billing client

var arbClient = arb.client(configurationHolder.config.payment.loginId, configurationHolder.config.payment.loginKey);
    arb.useSandbox();//add this when using the testing account 

 

Now, create subscription from following method

arbClient.createSubscription(paymentDetails, function (error, response) { if (error) { //do something on error } else { //do something on success }

use the following JSON to make payment

{"refId": "197s8",
    "subscription": {
        "name": "plan2",
        "order": {
            "invoiceNumber": "inv-034989",
            "description": "enterprise"
        },
        "paymentSchedule": {
            "interval": {
                "length": 1,
                "unit": "months"
            },
            "startDate": "2015-06-25",
            "totalOccurrences": "9999",
            "trialOccurrences": "1"
        },
        "amount": "19.99",
        "trialAmount": "0",
        "payment": {
            "creditCard": {
                "cardNumber": "4007000000027",
                "expirationDate": "2018-12",
                "cardCode": "111"
            }
        },
        "billTo": {
            "firstName": "Jane",
            "lastName": "Doe"
            
        }
    }
}

 

If you get subscription id and refId in the response it means your payment method is working properly for checking the subscription validation use

arbClient.getSubscriptionStatus(request, function (error, response) {
            if (error) {
           //do something
}
else{
//you will get the status active or inactive
}
 

I hope you will find this blog useful.

Thanks

 

About Author

Author Image
Mayank Tyagi

Mayank is a bright Web Developer with expertise in Java language.

Request for Proposal

Name is required

Comment is required

Sending message..