Skip to content

Commit

Permalink
Merge pull request #24 from cashfree/3.0.5
Browse files Browse the repository at this point in the history
3.0.5
  • Loading branch information
suhas-cashfree authored Nov 28, 2023
2 parents d7aef8f + 543fa10 commit 3607fa1
Show file tree
Hide file tree
Showing 8 changed files with 231 additions and 116 deletions.
9 changes: 2 additions & 7 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,15 @@ jobs:

steps:
- uses: actions/checkout@v4
- uses: mskelton/setup-yarn@v1
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '21.x'
- name: Install dependencies
run: npm install
run: npm install && npm install coveralls --save-dev
- name: Run Tests
run: CLIENT_ID=$PG_CLIENT_ID SECRET_KEY=$PG_CLIENT_SECRET npm test
- name: Coveralls
run: yarn report && yarn coveralls
run: CLIENT_ID=$PG_CLIENT_ID SECRET_KEY=$PG_CLIENT_SECRET npm test && cd coverage && ls && cd .. && cat coverage/lcov.info | npx coveralls
env:
PG_CLIENT_ID: ${{ secrets.XCLIENTIDSANDBOX }}
PG_CLIENT_SECRET: ${{ secrets.XCLIENTSECRETSANDBOX }}
GITHUB_TOKEN: ${{ secrets.TOKEN_GITHUB }}
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}

2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
wwwroot/*.js
node_modules
coverage
typings
dist
coverage
package-lock.json
test-results
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Cashfree.XClientSecret = "<x-client-secret>";
Cashfree.XEnvironment = Cashfree.Environment.SANDBOX;
```

Generate your API keys (x-client-id , x-secret-key) from [Cashfree Merchant Dashboard](https://merchant.cashfree.com/merchants/login)
Generate your API keys (x-client-id , x-client-secret) from [Cashfree Merchant Dashboard](https://merchant.cashfree.com/merchants/login)

### Basic Usage
Create Order
Expand Down
225 changes: 131 additions & 94 deletions api.ts

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module.exports = {
preset: "ts-jest",
testEnvironment: "node",
};
coverageReporters: ["lcov"],
};
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cashfree-pg",
"version": "3.0.1",
"version": "3.0.5",
"description": "Cashfree client for cashfree-pg",
"author": "Cashfree Payments",
"repository": {
Expand All @@ -14,19 +14,19 @@
"openapi-generator",
"cashfree-pg"
],
"license": "MIT",
"license": "Apache",
"main": "./dist/index.js",
"typings": "./dist/index.d.ts",
"module": "./dist/esm/index.js",
"sideEffects": false,
"scripts": {
"build": "tsc && tsc -p tsconfig.esm.json",
"prepare": "npm run build",
"test": "jest --coverage"
"test": "jest --coverage && coveralls < coverage/lcov.info"
},
"dependencies": {
"@sentry/node": "^7.73.0",
"axios": "1.5.1"
"axios": "1.5.1",
"@sentry/node": "^7.73.0"
},
"devDependencies": {
"@types/chai": "^4.3.10",
Expand Down
90 changes: 86 additions & 4 deletions tests/orders.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ import { expect, jest, test } from '@jest/globals';
import { Cashfree, UpiChannelEnum, AppProviderEnum, CardChannelEnum, OfferTncOfferTncTypeEnum, OfferType, DiscountDetailsDiscountTypeEnum } from "../api";
const { execSync } = require('child_process');

Cashfree.XClientId = process.env.CLIENT_ID;
Cashfree.XClientSecret = process.env.SECRET_KEY;
Cashfree.XEnvironment = Cashfree.Environment.SANDBOX;

var orderId = ''
var paymentSessionId = ''
var orderAmount = 3000;
Expand All @@ -25,6 +21,11 @@ function setOrderDetails(order_id: string, payment_session_id: string) {
}

it('Create Order Test', function (done) {
Cashfree.XClientId = process.env.CLIENT_ID;
Cashfree.XClientSecret = process.env.SECRET_KEY;
Cashfree.XEnvironment = Cashfree.Environment.SANDBOX;
console.log("process.env.PG_CLIENT_ID");
console.log(process.env.PG_CLIENT_ID);
var blah = 'foo';
var request = {
"order_amount": orderAmount,
Expand Down Expand Up @@ -61,6 +62,9 @@ it('Create Order Test', function (done) {


it('Create Order with Invalid Currency Test', function (done) {
Cashfree.XClientId = process.env.CLIENT_ID;
Cashfree.XClientSecret = process.env.SECRET_KEY;
Cashfree.XEnvironment = Cashfree.Environment.SANDBOX;
var currency = 'INaR';
var request = {
"order_amount": orderAmount,
Expand Down Expand Up @@ -91,6 +95,9 @@ it('Create Order with Invalid Currency Test', function (done) {
});

it('Create Order with Invalid Amount Test', function (done) {
Cashfree.XClientId = process.env.CLIENT_ID;
Cashfree.XClientSecret = process.env.SECRET_KEY;
Cashfree.XEnvironment = Cashfree.Environment.SANDBOX;
var request = {
"order_amount": -3005,
"order_currency": "INR",
Expand Down Expand Up @@ -120,6 +127,9 @@ it('Create Order with Invalid Amount Test', function (done) {
});

it('Create Order with Empty Customer Phone Test', function (done) {
Cashfree.XClientId = process.env.CLIENT_ID;
Cashfree.XClientSecret = process.env.SECRET_KEY;
Cashfree.XEnvironment = Cashfree.Environment.SANDBOX;
var request = {
"order_amount": orderAmount,
"order_currency": "INR",
Expand Down Expand Up @@ -149,6 +159,9 @@ it('Create Order with Empty Customer Phone Test', function (done) {
});

it('Order Pay Net Banking Test', function (done) {
Cashfree.XClientId = process.env.CLIENT_ID;
Cashfree.XClientSecret = process.env.SECRET_KEY;
Cashfree.XEnvironment = Cashfree.Environment.SANDBOX;
var request = {
"payment_session_id": paymentSessionId,
"payment_method": {
Expand All @@ -170,6 +183,9 @@ it('Order Pay Net Banking Test', function (done) {
});

it('Order Pay Card payment Test', function (done) {
Cashfree.XClientId = process.env.CLIENT_ID;
Cashfree.XClientSecret = process.env.SECRET_KEY;
Cashfree.XEnvironment = Cashfree.Environment.SANDBOX;
var request = {
"payment_session_id": paymentSessionId,
"payment_method": {
Expand All @@ -195,6 +211,9 @@ it('Order Pay Card payment Test', function (done) {
});

it('Order Pay Card payment with empty cvv Test', function (done) {
Cashfree.XClientId = process.env.CLIENT_ID;
Cashfree.XClientSecret = process.env.SECRET_KEY;
Cashfree.XEnvironment = Cashfree.Environment.SANDBOX;
var request = {
"payment_session_id": paymentSessionId,
"payment_method": {
Expand All @@ -220,6 +239,9 @@ it('Order Pay Card payment with empty cvv Test', function (done) {
});

it('Order Pay Wallet Test', function (done) {
Cashfree.XClientId = process.env.CLIENT_ID;
Cashfree.XClientSecret = process.env.SECRET_KEY;
Cashfree.XEnvironment = Cashfree.Environment.SANDBOX;
var request = {
"payment_session_id": paymentSessionId,
"payment_method": {
Expand All @@ -239,6 +261,9 @@ it('Order Pay Wallet Test', function (done) {
});

it('Get Order Test', function (done) {
Cashfree.XClientId = process.env.CLIENT_ID;
Cashfree.XClientSecret = process.env.SECRET_KEY;
Cashfree.XEnvironment = Cashfree.Environment.SANDBOX;
Cashfree.PGFetchOrder("2022-09-01", "order_4175412YWdHafgWZLFYcyTKkzIqu9QJvI").then((response) => {
assert.equal(response.data.order_currency, "INR")
done()
Expand All @@ -250,6 +275,9 @@ it('Get Order Test', function (done) {
});

it('Get Payments For an Order Test', function (done) {
Cashfree.XClientId = process.env.CLIENT_ID;
Cashfree.XClientSecret = process.env.SECRET_KEY;
Cashfree.XEnvironment = Cashfree.Environment.SANDBOX;
Cashfree.PGOrderFetchPayments("2022-09-01", "order_4175412YWdHafgWZLFYcyTKkzIqu9QJvI").then((response) => {
done()
}).catch((error) => {
Expand All @@ -261,6 +289,9 @@ it('Get Payments For an Order Test', function (done) {
});

it('Create Refund Test', function (done) {
Cashfree.XClientId = process.env.CLIENT_ID;
Cashfree.XClientSecret = process.env.SECRET_KEY;
Cashfree.XEnvironment = Cashfree.Environment.SANDBOX;
var request = {
"refund_amount": 1,
"refund_id": "Refund_id_" + getCurrentTimeStamp(),
Expand All @@ -276,6 +307,9 @@ it('Create Refund Test', function (done) {
});

it('Create Refund with negative refund amount Test', function (done) {
Cashfree.XClientId = process.env.CLIENT_ID;
Cashfree.XClientSecret = process.env.SECRET_KEY;
Cashfree.XEnvironment = Cashfree.Environment.SANDBOX;
var request = {
"refund_amount": -1,
"refund_id": "Refund_id_" + getCurrentTimeStamp(),
Expand All @@ -294,6 +328,9 @@ it('Create Refund with negative refund amount Test', function (done) {
});

it('Create Refund with invalid order id Test', function (done) {
Cashfree.XClientId = process.env.CLIENT_ID;
Cashfree.XClientSecret = process.env.SECRET_KEY;
Cashfree.XEnvironment = Cashfree.Environment.SANDBOX;
var request = {
"refund_amount": 1,
"refund_id": "Refund_id_" + getCurrentTimeStamp(),
Expand All @@ -312,6 +349,9 @@ it('Create Refund with invalid order id Test', function (done) {
});

it('Fetch All Refunds Test', function (done) {
Cashfree.XClientId = process.env.CLIENT_ID;
Cashfree.XClientSecret = process.env.SECRET_KEY;
Cashfree.XEnvironment = Cashfree.Environment.SANDBOX;
var order_id = "Order_" + getCurrentTimeStamp()
Cashfree.PGOrderFetchRefunds("2022-09-01", "order_4175412YWdHafgWZLFYcyTKkzIqu9QJvI").then((response) => {
done()
Expand All @@ -323,6 +363,9 @@ it('Fetch All Refunds Test', function (done) {
});

it('Fetch Refund Test', function (done) {
Cashfree.XClientId = process.env.CLIENT_ID;
Cashfree.XClientSecret = process.env.SECRET_KEY;
Cashfree.XEnvironment = Cashfree.Environment.SANDBOX;
var order_id = "Order_" + getCurrentTimeStamp()
Cashfree.PGOrderFetchRefund("2022-09-01", "order_4175412YWdHafgWZLFYcyTKkzIqu9QJvI", "Refund_id_2060112241827").then((response) => {
done()
Expand All @@ -336,6 +379,9 @@ it('Fetch Refund Test', function (done) {


it('Create Payment Link Test', function (done) {
Cashfree.XClientId = process.env.CLIENT_ID;
Cashfree.XClientSecret = process.env.SECRET_KEY;
Cashfree.XEnvironment = Cashfree.Environment.SANDBOX;
var link_id = "Automated_Test_" + getCurrentTimeStamp()
var request = {
"link_amount": 1,
Expand Down Expand Up @@ -375,6 +421,9 @@ it('Create Payment Link Test', function (done) {


it('Fetch Payment Link Test', function (done) {
Cashfree.XClientId = process.env.CLIENT_ID;
Cashfree.XClientSecret = process.env.SECRET_KEY;
Cashfree.XEnvironment = Cashfree.Environment.SANDBOX;
var link_id = "Automated_Test_188181"
Cashfree.PGFetchLink("2022-09-01", link_id).then((response) => {
done()
Expand All @@ -386,6 +435,9 @@ it('Fetch Payment Link Test', function (done) {
});

it('Cancel Payment Link Test', function (done) {
Cashfree.XClientId = process.env.CLIENT_ID;
Cashfree.XClientSecret = process.env.SECRET_KEY;
Cashfree.XEnvironment = Cashfree.Environment.SANDBOX;
var link_id = "Automated_Test_188181"
Cashfree.PGCancelLink("2022-09-01", link_id).then((response) => {
assert.fail("Fail error message")
Expand All @@ -399,6 +451,9 @@ it('Cancel Payment Link Test', function (done) {
});

it('Fetch Payment Link with Invalid link id Test', function (done) {
Cashfree.XClientId = process.env.CLIENT_ID;
Cashfree.XClientSecret = process.env.SECRET_KEY;
Cashfree.XEnvironment = Cashfree.Environment.SANDBOX;
var link_id = "jahha" + getCurrentTimeStamp()
Cashfree.PGFetchLink("2022-09-01", link_id).then((response) => {
assert.fail("Fail error message")
Expand All @@ -412,6 +467,9 @@ it('Fetch Payment Link with Invalid link id Test', function (done) {
});

it('Fetch Link Orders Test', function (done) {
Cashfree.XClientId = process.env.CLIENT_ID;
Cashfree.XClientSecret = process.env.SECRET_KEY;
Cashfree.XEnvironment = Cashfree.Environment.SANDBOX;
var link_id = "Automated_Test_188181"
Cashfree.PGLinkFetchOrders("2022-09-01", link_id).then((response) => {
done()
Expand All @@ -423,6 +481,9 @@ it('Fetch Link Orders Test', function (done) {
});

it('Fetch Link Orders with invalid link id Test', function (done) {
Cashfree.XClientId = process.env.CLIENT_ID;
Cashfree.XClientSecret = process.env.SECRET_KEY;
Cashfree.XEnvironment = Cashfree.Environment.SANDBOX;
var link_id = "jajqq"
Cashfree.PGLinkFetchOrders("2022-09-01", link_id).then((response) => {
assert.fail("Fail error message")
Expand All @@ -437,6 +498,9 @@ it('Fetch Link Orders with invalid link id Test', function (done) {


it('Create Offer Test', function (done) {
Cashfree.XClientId = process.env.CLIENT_ID;
Cashfree.XClientSecret = process.env.SECRET_KEY;
Cashfree.XEnvironment = Cashfree.Environment.SANDBOX;
var request = {
"offer_meta": {
"offer_title": "bat mann",
Expand Down Expand Up @@ -477,6 +541,9 @@ it('Create Offer Test', function (done) {
});

it('Get Offer Test', function (done) {
Cashfree.XClientId = process.env.CLIENT_ID;
Cashfree.XClientSecret = process.env.SECRET_KEY;
Cashfree.XEnvironment = Cashfree.Environment.SANDBOX;
Cashfree.PGFetchOffer("2022-09-01", "a189050b-8f7e-4f1c-be5f-ba4bf58bdd6b").then((response) => {
done()
}).catch((error) => {
Expand All @@ -486,6 +553,9 @@ it('Get Offer Test', function (done) {
});

it('Fetch Eligibility Payment Methods Test', function (done) {
Cashfree.XClientId = process.env.CLIENT_ID;
Cashfree.XClientSecret = process.env.SECRET_KEY;
Cashfree.XEnvironment = Cashfree.Environment.SANDBOX;
var request = {
"queries": {
"amount": 100
Expand All @@ -500,6 +570,9 @@ it('Fetch Eligibility Payment Methods Test', function (done) {
});

it('Fetch Eligibility Payment Methods With invalid amount Test', function (done) {
Cashfree.XClientId = process.env.CLIENT_ID;
Cashfree.XClientSecret = process.env.SECRET_KEY;
Cashfree.XEnvironment = Cashfree.Environment.SANDBOX;
var request = {
"queries": {
"amount": -100
Expand All @@ -517,6 +590,9 @@ it('Fetch Eligibility Payment Methods With invalid amount Test', function (done)
});

it('Settlement Reconcilation Test', function (done) {
Cashfree.XClientId = process.env.CLIENT_ID;
Cashfree.XClientSecret = process.env.SECRET_KEY;
Cashfree.XEnvironment = Cashfree.Environment.SANDBOX;
var request = {
"pagination": {
"limit": 10
Expand All @@ -536,6 +612,9 @@ it('Settlement Reconcilation Test', function (done) {


it('PG Reconcilation Test', function (done) {
Cashfree.XClientId = process.env.CLIENT_ID;
Cashfree.XClientSecret = process.env.SECRET_KEY;
Cashfree.XEnvironment = Cashfree.Environment.SANDBOX;
var request = {
"pagination": {
"limit": 10
Expand All @@ -554,6 +633,9 @@ it('PG Reconcilation Test', function (done) {
});

it('Get Instrument By Id Test', function (done) {
Cashfree.XClientId = process.env.CLIENT_ID;
Cashfree.XClientSecret = process.env.SECRET_KEY;
Cashfree.XEnvironment = Cashfree.Environment.SANDBOX;
var instrumemtId = "9f9477b7-61ea-4baa-b878-a7e63d978034"
var customerId = "iij"
Cashfree.PGCustomerFetchInstrument("2022-09-01", customerId, instrumemtId).then((response) => {
Expand Down
6 changes: 3 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"ignoreDeprecations": "5.0",
"exclude": [
"dist",
"tests",
"node_modules"
"node_modules",
"tests"
]
}
}

0 comments on commit 3607fa1

Please sign in to comment.