Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/prod_ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
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: [18.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 run env -- mocha --timeout 10000 --recursive --require babel-register test_prod/
env:
API_KEY: ${{ secrets.API_KEY }}
API_SECRET: ${{ secrets.API_SECRET }}
25 changes: 25 additions & 0 deletions test_prod/razorpay.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
'use strict';

const Razorpay = require("../dist/razorpay");
let request = require('request-promise');

class RazorpayBeta extends Razorpay {
constructor(options) {
super(options)
this.api.rq = request.defaults({
baseUrl: options.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 || "",
hostUrl : "https://api-web.dev.razorpay.in"
});
42 changes: 42 additions & 0 deletions test_prod/resources/transfers.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
'use strict'

var assert = require('assert');
const rzpInstance = require('../razorpay')

let customerId = null;
let transferId = null;

describe('TRANSFERS', () => {

it('fetch all transfers', (done) => {

rzpInstance.transfers.all()
.then((response) => {
if(response.items.length > 0){
if('id' in response.items[0]){
transferId = response.items[0].id
}
}
assert.ok(response.hasOwnProperty('count'))
assert.ok(response.hasOwnProperty('items'))
done()
}).catch(err => console.log(err))
})

it('fetch transfer', (done) => {
rzpInstance.transfers.fetch(transferId).then((response) => {
assert.ok(response.hasOwnProperty('id'))
assert.ok(response.hasOwnProperty('entity'))
assert.ok((response.id == transferId))
done()
}).catch(err => console.log(err))
})

it('fetch settlement details', (done) => {
rzpInstance.transfers.fetchSettlements().then((response) => {
assert.ok(response.hasOwnProperty('count'))
assert.ok(response.hasOwnProperty('items'))
done()
}).catch(err => console.log(err))
})
})
76 changes: 76 additions & 0 deletions test_prod/resources/virtualAccounts.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
'use strict'

var assert = require('assert');
const rzpInstance = require('../razorpay')

let customerId = null;
let virtualId = null;

describe('VIRTUAL ACCOUNTS', () => {

it('create virtual account', (done) => {

rzpInstance.customers.create({
"name": "Gaurav Kumar",
"contact": 9123456780,
"email": "gaurav.kumar@example.com",
"fail_existing": 0,
"notes": {
"notes_key_1": "Tea, Earl Grey, Hot",
"notes_key_2": "Tea, Earl Grey… decaf."
}
}).then(response=>{
customerId = response.id
return customerId
}).then((id)=>{
rzpInstance.virtualAccounts.create({
"receivers": {
"types": [
"bank_account"
]
},
"description": "Virtual Account created for Raftar Soft",
"customer_id": id,
"notes": {
"project_name": "Banking Software"
}
}).then((response) => {
virtualId = response.id
assert.ok(response.hasOwnProperty('id'))
assert.ok(response.hasOwnProperty('entity'))
done()
}).catch(err => console.log(err))
}).catch(err => console.log(err))
})

it('fetch virtualAccount', (done) => {
rzpInstance.virtualAccounts.fetch(virtualId).then((response) => {
assert.ok(response.hasOwnProperty('id'))
done()
}).catch(err => console.log(err))
})

it('fetch payments of virtualAccount', (done) => {
rzpInstance.virtualAccounts.fetchPayments(virtualId).then((response) => {
assert.ok(response.hasOwnProperty('count'))
assert.ok(response.hasOwnProperty('items'))
done()
}).catch(err => console.log(err))
})

it('fetch all virtualAccounts', (done) => {
rzpInstance.virtualAccounts.all().then((response) => {
assert.ok(response.hasOwnProperty('count'))
assert.ok(response.hasOwnProperty('items'))
done()
}).catch(err => console.log(err))
})

it('close virtualAccounts', (done) => {
rzpInstance.virtualAccounts.close(virtualId).then((response) => {
assert.ok(response.hasOwnProperty('id'))
assert.ok(response.hasOwnProperty('entity'))
done()
}).catch(err => console.log(err))
})
})