Skip to content
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"
});
65 changes: 65 additions & 0 deletions test_prod/resources/customer.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
'use strict'

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

var customerId = null;

describe('CUSTOMERS', () => {

it('Customer create request', (done) => {

let params = {
"name": "Gaurav Kumar",
"contact": 9123456780,
"email": "[email protected]",
"fail_existing": "0",
"notes": {
"notes_key_1": "Tea, Earl Grey, Hot",
"notes_key_2": "Tea, Earl Grey… decaf."
}
}

rzpInstance.customers.create(params).then((response) => {
customerId = response.id
assert.ok(response.hasOwnProperty('id'))
assert.ok(response.hasOwnProperty('entity'))
done()
}).catch(err=>console.log(err))
})

it('fetch customers', (done) => {
rzpInstance.customers.fetch(customerId).then((response) => {
assert.ok(response.hasOwnProperty('id'))
assert.ok((response.id==customerId))
done()
})
})

it('edit customer', (done) => {
let params = {
"contact": 9123456780
}

rzpInstance.customers.edit(customerId, params).then((response) => {
assert.ok(response.hasOwnProperty('id'))
assert.ok(response.hasOwnProperty('entity'))
assert.ok((response.id==customerId))
done()
}).catch(err=>console.log(err))
})

it('fetch all customers', (done) => {
let expectedParams = {
skip: 0,
count: 10
}

rzpInstance.orders.all(expectedParams).then((response) => {
assert.ok(response.hasOwnProperty('items'))
assert.ok(response.hasOwnProperty('count'))
done()
})
})
})
53 changes: 53 additions & 0 deletions test_prod/resources/fundAccount.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
'use strict'

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

var customerId = null;

describe('FUND-ACCOUNTS', () => {

it('Fundaccount create request', (done) => {

let customerDetails = {
"name": "Gaurav Kumar",
"contact": 9123456780,
"email": "[email protected]",
"fail_existing": "0",
"notes": {
"notes_key_1": "Tea, Earl Grey, Hot",
"notes_key_2": "Tea, Earl Grey… decaf."
}
}

rzpInstance.customers.create(customerDetails)
.then(response => response.id)
.then((customer_id) => {
customerId = customer_id
rzpInstance.fundAccount.create({
"customer_id": customer_id,
"account_type": "bank_account",
"bank_account": {
"name": "Gaurav Kumar",
"account_number": "11214311215411",
"ifsc": "HDFC0000053"
}
}).then((response) => {
//fundAccountId = response.id
//console.log(response)
assert.ok(response.hasOwnProperty('id'))
assert.ok(response.hasOwnProperty('entity'))
done()
})
})
})

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