Socket
Socket
Sign inDemoInstall

node-kash

Package Overview
Dependencies
49
Maintainers
3
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    node-kash

Kash API Node.js Client


Version published
Maintainers
3
Install size
11.1 MB
Created

Readme

Source

Installation

npm install node-kash

Documentation

Documentation is available at http://docs.withkash.com.

Tutorial

Note that each function call returns a promise. To charge a customer, remember that you need to follow a 2-step process: First authorize the amount, then create a transaction for the final amount you want to charge.

For authorizing an amount you want to charge:

var kash = require('node-kash')('<Your Server Key>');
kash.authorizeAmount('<Customer ID>', amount)
    .then(function(result) {
        // Now use result.authorization_id with either cancelAuthorization() or
        // createTransaction()
        console.log(result.authorization_id);
    })
    .catch(function(err) {
        if (err.statusCode === 410) {
            // Customer needs to relink their bank account
            console.log(err.error);
        }
        else if (err.statusCode === 402) {
            // Customer has insufficient funds and Kash determines we won't be
            // able to retrieve the amount
            console.log(err.error);
        }
        else {
            // Any other error conditions
            console.log(err.error);
        }
    });

To cancel an authorized amount:

var kash = require('node-kash')('<Your Server Key>');
// Using the authorizationId collected from authorizeAmount()
kash.cancelAuthorization(authorizationId)
    .then(function() {
        // Success!
    })
    .catch(function(err) {
        // Any other error conditions
        console.log(err.error);
    });

To actually charge the customer:

var kash = require('node-kash')('<Your Server Key>');
// Using the authorizationId collected from authorizeAmount()
kash.createTransaction(authorizationId, amount)
    .then(function(result) {
        // Success!
        console.log(result.transaction_id);
    })
    .catch(function(err) {
        // Any other error conditions
        console.log(err.error);
    });

To do refunds:

var kash = require('node-kash')('<Your Server Key>');
// Using the transactionId collected from createTransaction()
kash.refundTransaction(transactionId, amount)
    .then(function(result) {
        // Success!
    })
    .catch(function(err) {
        // Any other error conditions
        console.log(err.error);
    });

FAQs

Last updated on 13 Sep 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc