From a35e37a069701d32010b66b6c1a902f72a721318 Mon Sep 17 00:00:00 2001 From: ankitdas13 Date: Wed, 22 Feb 2023 19:30:25 +0530 Subject: [PATCH 01/13] version bump --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ad7d6625..216e9ae9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "razorpay", - "version": "2.8.5", + "version": "2.8.6", "description": "Official Node SDK for Razorpay API", "main": "dist/razorpay", "typings": "dist/razorpay", From 56226b4a68a16a52f6e5378bb73bd7a57b5c5dc4 Mon Sep 17 00:00:00 2001 From: ankitdas13 Date: Tue, 11 Jul 2023 14:39:25 +0530 Subject: [PATCH 02/13] add e2e test cases --- package.json | 4 +++- test_prod/razorpay.js | 8 ++++++++ test_prod/resources/addon.spec.js | 32 +++++++++++++++++++++++++++++++ test_prod/resources/cards.spec.js | 17 ++++++++++++++++ 4 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 test_prod/razorpay.js create mode 100644 test_prod/resources/addon.spec.js create mode 100644 test_prod/resources/cards.spec.js diff --git a/package.json b/package.json index 03390d0a..1eeec3c5 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,8 @@ "build": "npm run clean && npm run build:commonjs && npm run cp-ts", "debug": "npm run build && node-debug examples/index.js", "test": "npm run build && mocha --recursive --require babel-register test/ && nyc --reporter=text mocha", - "coverage": "nyc report --reporter=text-lcov > coverage.lcov" + "coverage": "nyc report --reporter=text-lcov > coverage.lcov", + "test_prod": "npm run build && mocha --recursive --require babel-register test_prod/" }, "repository": { "type": "git", @@ -47,6 +48,7 @@ }, "dependencies": { "@types/request-promise": "^4.1.48", + "node-fetch": "^2.6.12", "promise": "^8.1.0", "request": "^2.88.0", "request-promise": "^4.2.6", diff --git a/test_prod/razorpay.js b/test_prod/razorpay.js new file mode 100644 index 00000000..52739e22 --- /dev/null +++ b/test_prod/razorpay.js @@ -0,0 +1,8 @@ +'use strict'; + +const Razorpay = require("../dist/razorpay"); + +module.exports = new Razorpay({ + key_id: process.env.API_KEY || "", + key_secret: process.env.API_SECRET || "" +}); diff --git a/test_prod/resources/addon.spec.js b/test_prod/resources/addon.spec.js new file mode 100644 index 00000000..a4932628 --- /dev/null +++ b/test_prod/resources/addon.spec.js @@ -0,0 +1,32 @@ +'use strict' + +var assert = require('assert'); +const rzpInstance = require('../razorpay') +const equal = require('deep-equal'); +const { items } = require('../razorpay'); + +let addonId = null; + +describe('ADDON', () => { + + it('Fetch all addons', (done) => { + + rzpInstance.addons.all({ "count": 1 }).then((response) => { + if (response.hasOwnProperty('items')) { + if ('id' in response.items[0]) { + addonId = response.items[0].id + } + } + assert.ok(response.hasOwnProperty('count')) + assert.ok(response.hasOwnProperty('items')) + done() + }).catch(err => console.log(err)) + }) + + it('fetch order\'s payments', (done) => { + rzpInstance.addons.fetch(addonId).then((response) => { + assert.ok(response.hasOwnProperty('id')) + done() + }) + }) +}) diff --git a/test_prod/resources/cards.spec.js b/test_prod/resources/cards.spec.js new file mode 100644 index 00000000..d5cbc26f --- /dev/null +++ b/test_prod/resources/cards.spec.js @@ -0,0 +1,17 @@ +'use strict' + +var assert = require('assert'); +const rzpInstance = require('../razorpay') +const equal = require('deep-equal'); +const { items } = require('../razorpay'); + +let cardId = "card_LcQgzpfvWP0UKF"; + +describe('CARDS', () => { + it('fetch order\'s payments', (done) => { + rzpInstance.cards.fetch(cardId).then((response) => { + assert.ok(response.hasOwnProperty('id')) + done() + }) + }) +}) From 88501c015d9cc33841f260c9d03cce167e7a99d8 Mon Sep 17 00:00:00 2001 From: Ankit Das <89454448+ankitdas13@users.noreply.github.com> Date: Tue, 11 Jul 2023 14:47:24 +0530 Subject: [PATCH 03/13] Create prod_ci.yml --- .github/workflows/prod_ci.yml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .github/workflows/prod_ci.yml diff --git a/.github/workflows/prod_ci.yml b/.github/workflows/prod_ci.yml new file mode 100644 index 00000000..8c50bd41 --- /dev/null +++ b/.github/workflows/prod_ci.yml @@ -0,0 +1,29 @@ +name: e2e prod test +on: + push: + branches: + - master + tags: + - v[0-9]+.[0-9]+.[0-9]+* + pull_request: + branches: + - master +jobs: + test: + name: Run tests and publish test coverage + runs-on: ubuntu-latest + strategy: + matrix: + node-version: [12.x, 14.x, 16.x, 18.x, 19,x] + # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ + steps: + - uses: actions/checkout@v2 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v2 + with: + node-version: ${{ matrix.node-version }} + cache: 'npm' + - name: Install dependencies + run: npm install + - name: Run tests + run: npm test_prod From a38bea9eca4fa900762742324a1680d6aebe3c0a Mon Sep 17 00:00:00 2001 From: Ankit Das <89454448+ankitdas13@users.noreply.github.com> Date: Tue, 11 Jul 2023 14:49:15 +0530 Subject: [PATCH 04/13] Update prod_ci.yml --- .github/workflows/prod_ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/prod_ci.yml b/.github/workflows/prod_ci.yml index 8c50bd41..ad94b813 100644 --- a/.github/workflows/prod_ci.yml +++ b/.github/workflows/prod_ci.yml @@ -26,4 +26,4 @@ jobs: - name: Install dependencies run: npm install - name: Run tests - run: npm test_prod + run: npm run test_prod From aff156590614e47316bc82350f6813d9fab3639e Mon Sep 17 00:00:00 2001 From: Ankit Das <89454448+ankitdas13@users.noreply.github.com> Date: Tue, 11 Jul 2023 14:59:39 +0530 Subject: [PATCH 05/13] Update prod_ci.yml --- .github/workflows/prod_ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/prod_ci.yml b/.github/workflows/prod_ci.yml index ad94b813..7732fff4 100644 --- a/.github/workflows/prod_ci.yml +++ b/.github/workflows/prod_ci.yml @@ -27,3 +27,6 @@ jobs: run: npm install - name: Run tests run: npm run test_prod + env: + API_KEY: ${{ secrets.API_KEY }} + API_SECRET: ${{ secrets.API_SECRET }} From d6779b2d1e76f30466fe9b6e2f06f084c240af40 Mon Sep 17 00:00:00 2001 From: Ankit Das <89454448+ankitdas13@users.noreply.github.com> Date: Tue, 11 Jul 2023 16:44:12 +0530 Subject: [PATCH 06/13] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1eeec3c5..72597c47 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "debug": "npm run build && node-debug examples/index.js", "test": "npm run build && mocha --recursive --require babel-register test/ && nyc --reporter=text mocha", "coverage": "nyc report --reporter=text-lcov > coverage.lcov", - "test_prod": "npm run build && mocha --recursive --require babel-register test_prod/" + "test_prod": "npm run build && mocha --timeout 10000 --recursive --require babel-register test_prod/" }, "repository": { "type": "git", From 493dc69edf1ace7a8d3622a38a1ef34625882c7c Mon Sep 17 00:00:00 2001 From: Ankit Das <89454448+ankitdas13@users.noreply.github.com> Date: Tue, 11 Jul 2023 16:46:28 +0530 Subject: [PATCH 07/13] Update prod_ci.yml --- .github/workflows/prod_ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/prod_ci.yml b/.github/workflows/prod_ci.yml index 7732fff4..9ed3e5e1 100644 --- a/.github/workflows/prod_ci.yml +++ b/.github/workflows/prod_ci.yml @@ -14,7 +14,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - node-version: [12.x, 14.x, 16.x, 18.x, 19,x] + node-version: [18.x] # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ steps: - uses: actions/checkout@v2 From b1e476c8e38ad8ec0ea565577dc8e8ca6a03dc85 Mon Sep 17 00:00:00 2001 From: Ankit Das <89454448+ankitdas13@users.noreply.github.com> Date: Tue, 1 Aug 2023 12:24:19 +0530 Subject: [PATCH 08/13] Update package.json --- package.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/package.json b/package.json index 369ce973..78114ecd 100644 --- a/package.json +++ b/package.json @@ -13,8 +13,7 @@ "build": "npm run clean && npm run build:commonjs && npm run cp-ts", "debug": "npm run build && node-debug examples/index.js", "test": "npm run build && mocha --recursive --require babel-register test/ && nyc --reporter=text mocha", - "coverage": "nyc report --reporter=text-lcov > coverage.lcov", - "test_prod": "npm run build && mocha --timeout 10000 --recursive --require babel-register test_prod/" + "coverage": "nyc report --reporter=text-lcov > coverage.lcov" }, "repository": { "type": "git", From 28c182275d74a762e9aca567d8cc09ac8df3b195 Mon Sep 17 00:00:00 2001 From: Ankit Das <89454448+ankitdas13@users.noreply.github.com> Date: Tue, 1 Aug 2023 12:31:52 +0530 Subject: [PATCH 09/13] Update prod_ci.yml --- .github/workflows/prod_ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/prod_ci.yml b/.github/workflows/prod_ci.yml index 9ed3e5e1..ec3f8e92 100644 --- a/.github/workflows/prod_ci.yml +++ b/.github/workflows/prod_ci.yml @@ -26,7 +26,7 @@ jobs: - name: Install dependencies run: npm install - name: Run tests - run: npm run test_prod + run: npm run env -- mocha --timeout 10000 --recursive --require babel-register test_prod/ env: API_KEY: ${{ secrets.API_KEY }} API_SECRET: ${{ secrets.API_SECRET }} From 62f166e382ddb4d9e04704798bb42ff23c9a4337 Mon Sep 17 00:00:00 2001 From: Ankit Das <89454448+ankitdas13@users.noreply.github.com> Date: Tue, 1 Aug 2023 15:25:38 +0530 Subject: [PATCH 10/13] Update razorpay.js --- test_prod/razorpay.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/test_prod/razorpay.js b/test_prod/razorpay.js index 52739e22..e6a6f69c 100644 --- a/test_prod/razorpay.js +++ b/test_prod/razorpay.js @@ -2,7 +2,23 @@ const Razorpay = require("../dist/razorpay"); -module.exports = new Razorpay({ +class RazorpayBeta extends Razorpay { + constructor(options) { + super(options) + this.api.rq = request.defaults({ + baseUrl: hostUrl, + json: true, + auth: { + user: options.key_id, + pass: options.key_secret + } + }) + } +} + + +module.exports = new RazorpayBeta({ key_id: process.env.API_KEY || "", - key_secret: process.env.API_SECRET || "" + key_secret: process.env.API_SECRET || "", + hostUrl : "https://api-web.dev.razorpay.in" }); From 51add49e13f3ac6eef0c5e95e5fdadca64a393a0 Mon Sep 17 00:00:00 2001 From: Ankit Das <89454448+ankitdas13@users.noreply.github.com> Date: Tue, 1 Aug 2023 15:27:18 +0530 Subject: [PATCH 11/13] Update razorpay.js --- test_prod/razorpay.js | 1 + 1 file changed, 1 insertion(+) diff --git a/test_prod/razorpay.js b/test_prod/razorpay.js index e6a6f69c..dec947e9 100644 --- a/test_prod/razorpay.js +++ b/test_prod/razorpay.js @@ -1,6 +1,7 @@ 'use strict'; const Razorpay = require("../dist/razorpay"); +let request = require('request-promise'); class RazorpayBeta extends Razorpay { constructor(options) { From 10aa46cb1e08338d7dcecfc9ac6eced9a9721b2f Mon Sep 17 00:00:00 2001 From: Ankit Das <89454448+ankitdas13@users.noreply.github.com> Date: Tue, 1 Aug 2023 15:29:32 +0530 Subject: [PATCH 12/13] Update razorpay.js --- test_prod/razorpay.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test_prod/razorpay.js b/test_prod/razorpay.js index dec947e9..5c2c49c4 100644 --- a/test_prod/razorpay.js +++ b/test_prod/razorpay.js @@ -7,7 +7,7 @@ class RazorpayBeta extends Razorpay { constructor(options) { super(options) this.api.rq = request.defaults({ - baseUrl: hostUrl, + baseUrl: options.hostUrl, json: true, auth: { user: options.key_id, From 2c6a21031f5a09f16a547ddcad40526a43f56654 Mon Sep 17 00:00:00 2001 From: Ankit Das <89454448+ankitdas13@users.noreply.github.com> Date: Tue, 1 Aug 2023 16:15:23 +0530 Subject: [PATCH 13/13] Update package.json --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index 78114ecd..26bd7a58 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,6 @@ }, "dependencies": { "@types/request-promise": "^4.1.48", - "node-fetch": "^2.6.12", "promise": "^8.1.0", "request": "^2.88.0", "request-promise": "^4.2.6",