@cashfreepayments/cashfree-sdk

中文文档
0.1.7发布于 2021/09/29ISCCommonJS零依赖近 30 天下载 2128

Official Node SDK for Cashfree API

此软件包已被标记为弃用

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

原始使用文档
文档目录14 节
  1. API Documentation
  2. Installation
  3. In Node.js
  4. Getting Started
  5. Pre-requisites
  6. IP Whitelisting and dynamic IPs
  7. Usage
  8. Payouts
  9. WebHook Verification
  10. Usage
  11. Using Promises
  12. Using Async/Await
  13. Payment Gateway
  14. TODO

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 @cashfreepayments/cashfree-sdk

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('@cashfreepayments/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('@cashfreepayments/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)"
});
OptionDefaultDescription
envTESTEnvironment 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, signature, clientSecret); // 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

版本与发布记录

@cashfreepayments/cashfree-sdk 共发布 2 个版本,首次发布于 2021/09/29;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.1.7latest2021/09/295 年前
0.1.62021/09/295 年前

关于 @cashfreepayments/cashfree-sdk 的常见问题

@cashfreepayments/cashfree-sdk 是什么?

Official Node SDK for Cashfree API注意:该包已被作者标记为弃用——Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

如何安装 @cashfreepayments/cashfree-sdk?

在项目目录运行 npm install @cashfreepayments/cashfree-sdk,或使用 pnpm add / yarn add / bun add。

@cashfreepayments/cashfree-sdk 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/cashfreepayments__cashfree-sdk 是否存在。

@cashfreepayments/cashfree-sdk 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@cashfreepayments/cashfree-sdk 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=10.9.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@cashfreepayments/cashfree-sdk 可以商用吗?

@cashfreepayments/cashfree-sdk 使用 ISC 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@cashfreepayments/cashfree-sdk 的下载量有多少?

根据 npm 官方下载统计,@cashfreepayments/cashfree-sdk 在 2026/10/09 – 2026/11/07 这 30 天内被下载 2,128 次,日均约 71 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@cashfreepayments/cashfree-sdk 还在维护吗?

最新版本 0.1.7 发布于 2021/09/29(5 年前);至今共发布 2 个版本,其中过去 12 个月发布了 0 个;首次发布于 2021/09/29。作者已将其标记为弃用,新项目建议寻找替代方案。