4.1.2 • Published 1 month ago

cashfree-pg v4.1.2

Weekly downloads
-
License
Apache
Repository
github
Last release
1 month ago

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

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("2022-09-01", request).then((response) => {
    console.log('Order Created successfully:',response.data)
}).catch((error) => {
    console.error('Error:', error.response.data.message);
});

Get Order

Cashfree.PGFetchOrder("2022-09-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

4.1.2

1 month ago

4.0.9

2 months ago

4.0.10

2 months ago

4.0.7

3 months ago

3.2.15

3 months ago

3.2.14

3 months ago

4.0.5

3 months ago

4.0.4

3 months ago

3.2.12

3 months ago

4.0.3

3 months ago

3.2.7

4 months ago

3.2.1

4 months ago

3.2.3

4 months ago

3.2.0

4 months ago

4.0.2

4 months ago

4.0.0

4 months ago

3.1.4

4 months ago

3.1.3

4 months ago

3.1.1

4 months ago

3.1.0

4 months ago

3.0.8

5 months ago

3.0.6

5 months ago

3.0.5

6 months ago

3.0.1

6 months ago

3.0.0

6 months ago