Home
Softono

Cashfree Pg Sdk Nodejs

Open source Apache-2.0 TypeScript
24
Stars
7
Forks
9
Issues
4
Watchers
2 months
Last Commit

 About Cashfree Pg Sdk Nodejs

Cashfree Nodejs Plugin

Platforms

Web Self-hosted

Languages

TypeScript

Need Help Installing Cashfree Pg Sdk Nodejs?

We provide expert installation service for this software. Our team will install, configure, and secure Cashfree Pg Sdk Nodejs on your server. plans start at just $30.

Cashfree Pg Sdk Nodejs

View on GitHub

Cashfree PG Node SDK

GitHub Discord GitHub last commit (branch) GitHub release (with filter) npm GitHub forks Coverage Status

The Cashfree PG Node SDK offers a convenient solution to access Cashfree PG APIs from a server-side JavaScript applications.

Documentation

Cashfree's PG API Documentation - https://docs.cashfree.com/reference/pg-new-apis-endpoint

Learn and understand payment gateway workflows at Cashfree Payments here

Try out our interactive guides at Cashfree Dev Studio !

Getting Started

Installation

npm i cashfree-pg

Configuration

Version >=5

import { Cashfree } from "cashfree-pg"; 

var cashfree = new Cashfree(Cashfree.SANDBOX, "<x-client-id>", "<x-client-secret>")

Generate your API keys (x-client-id , x-client-secret) from Cashfree Merchant Dashboard

Basic Usage

Create Order

var request = {
    "order_amount": 1,
    "order_currency": "INR",
    "order_id": "order_34692745",
    "customer_details": {
        "customer_id": "walterwNrcMi",
        "customer_phone": "9999999999"
    },
    "order_meta": {
        "return_url": "https://www.cashfree.com/devstudio/preview/pg/web/checkout?order_id={order_id}"
    }
};
Cashfree.PGCreateOrder(request).then((response) => {
    console.log('Order Created successfully:',response.data)
}).catch((error) => {
    console.error('Error:', error.response.data.message);
});

Get Order

Cashfree.PGFetchOrder("<order_id>").then((response) => {
    console.log('Order fetched successfully:', response.data);
}).catch((error) => {
    console.error('Error:', error.response.data.message);
});

Version <5

import { Cashfree } from "cashfree-pg"; 

Cashfree.XClientId = "<x-client-id>";
Cashfree.XClientSecret = "<x-client-secret>";
Cashfree.XEnvironment = Cashfree.Environment.SANDBOX;

Generate your API keys (x-client-id , x-client-secret) from Cashfree Merchant Dashboard

Basic Usage

Create Order

var request = {
    "order_amount": 1,
    "order_currency": "INR",
    "order_id": "order_34692745",
    "customer_details": {
        "customer_id": "walterwNrcMi",
        "customer_phone": "9999999999"
    },
    "order_meta": {
        "return_url": "https://www.cashfree.com/devstudio/preview/pg/web/checkout?order_id={order_id}"
    }
};
Cashfree.PGCreateOrder("2023-08-01", request).then((response) => {
    console.log('Order Created successfully:',response.data)
}).catch((error) => {
    console.error('Error:', error.response.data.message);
});

Get Order

Cashfree.PGFetchOrder("2023-08-01", "<order_id>").then((response) => {
    console.log('Order fetched successfully:', response.data);
}).catch((error) => {
    console.error('Error:', error.response.data.message);
});

Validate Webhook

app.post('/webhook', function (req, res) {
    try {
        Cashfree.PGVerifyWebhookSignature(req.headers["x-webhook-signature"], req.rawBody, req.headers["x-webhook-timestamp"]);
    } catch (err) {
        console.log(err.message)
    }
})

Supported Resources

Licence

Apache Licensed. See LICENSE.md for more details