Giter VIP home page Giter VIP logo

cashfree-sdk-nodejs's Introduction

Cashfree libraries are released in Beta. This is work in progress and we are continuously working on improving various aspects of it. It is released as a learning aid and an example kit for the API integrators.

This is not recommended by Cashfree for direct use in production code. Please report any bugs to Cashfree at [email protected].

cashfree-sdk-nodejs

The official Cashfree SDK for JavaScript, available for Node.js backends. Node version 10.9.0 was used for this SDK.

Get started quickly using Cashfree with the Cashfree SDK for JavaScript in Node.js. The SDK helps take the complexity out of coding by providing JavaScript objects for Cashfree services including Payouts, Payment Gateway, Marketplace and Autocollect. The single, downloadable package includes the Cashfree JavaScript Library and documentation.

API Documentation

Please refer to the Cashfree Docs for the complete API reference.

Installation

In Node.js

The preferred way to install the Cashfree SDK for Node.js is to use the npm package manager for Node.js. Simply type the following into a terminal window:

npm i https://github.com/cashfree/cashfree-sdk-nodejs.git

Getting Started

Pre-requisites

IP Whitelisting and dynamic IPs

Your IP has to be whitelisted to hit Cashfree's server. Or if you have a dynamic IP please pass in the public key parameter during the init method as shown below. For more information please go here.

Usage

Payouts

The package needs to be configured with your account's secret key which is available in your Cashfree Dashboard.

In case of static IP (Your IP is whitelisted)

const { Payouts } = require('cashfree-sdk');

// Instantiate Cashfree Payouts
const payoutsInstance = new Payouts({
  env: 'TEST',
  clientId: '<CLIENT_ID>',
  clientSecret: '<CLIENT_SECRET>',
});
In case of dynamic IP you will need a public key to generate a signature(which will be done by sdk itself)

const { Payouts } = require('cashfree-sdk');

// Instantiate Cashfree Payouts
const payoutsInstance = new Payouts({
  env: 'TEST',
  clientId: '<CLIENT_ID>',
  clientSecret: '<CLIENT_SECRET>',
  pathToPublicKey: '/path/to/your/public/key/file.pem',
  //"publicKey": "ALTERNATIVE TO SPECIFYING PATH (DIRECTLY PASTE PublicKey)"
});
Option Default Description
env TEST Environment to be initialized. Can be set to TEST or PRODUCTION
clientId `` clientId which can be generated on cashfree dashboard.
clientSecret `` clientSecret which can be found alongside generated ClientId.
pathToPublicKey `` Either specify the path to your .pem public key file or use publicKey Param and pass the key there.
publicKey `` Pass your Public Key to this parameter as an alternative to pathToPublicKey.

WebHook Verification

To verify the webhook received from Cashfree for different events and accept the webhook only when it returns true.

Usage

Pass the webhook received along with the payload type.

Payouts.verifySignature(webhookPostDataJson); // returns true or false

Using Promises

Every method returns a promise which can be used:

payoutsInstance.beneficiary
  .add({
    beneId: 'JOHN18012',
    name: 'john doe',
    email: '[email protected]',
    phone: '9876543210',
    bankAccount: '00001111222233',
    ifsc: 'HDFC0000001',
    address1: 'ABC Street',
    city: 'Bangalore',
    state: 'Karnataka',
    pincode: '560001',
  })
  .then(function (response) {
    console.log(response);
  });

Using Async/Await

async function addBeneficiary() {
  try {
    const response = await payoutsInstance.beneficiary.add({
      beneId: 'JOHN18012',
      name: 'john doe',
      email: '[email protected]',
      phone: '9876543210',
      bankAccount: '00001111222233',
      ifsc: 'HDFC0000001',
      address1: 'ABC Street',
      city: 'Bangalore',
      state: 'Karnataka',
      pincode: '560001',
    });

    console.log(response);
  } catch (e) {
    console.error(e);
  }
}
  • For more information about the APIs go to Payouts.
  • Complete list of APIs

Payment Gateway

TODO

  • Market Place

  • Autocollect

cashfree-sdk-nodejs's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.