-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ae75d79
commit 2d8a742
Showing
4 changed files
with
190 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
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 test_prod | ||
env: | ||
API_KEY: ${{ secrets.API_KEY }} | ||
API_SECRET: ${{ secrets.API_SECRET }} | ||
PRODUCT_API_KEY: ${{ secrets.PRODUCT_API_KEY }} | ||
PRODUCT_API_SECRET: ${{ secrets.PRODUCT_API_SECRET }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
'use strict'; | ||
|
||
const Razorpay = require("../dist/razorpay"); | ||
|
||
module.exports = new Razorpay({ | ||
key_id: process.env.PRODUCT_API_KEY || "", | ||
key_secret: process.env.PRODUCT_API_SECRET || "" | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
'use strict' | ||
|
||
var assert = require('assert'); | ||
const rzpInstance = require('../product') | ||
const path = require('path') | ||
const fs = require('fs'); | ||
const crpyto = require('crypto') | ||
let skipDoc = true; | ||
|
||
let accountId = null; | ||
let webhookId = null; | ||
|
||
let setAccount = { | ||
"email": `gauriagain.${crpyto.randomBytes(4).toString('hex')}@example.org`, | ||
"phone": "9000090000", | ||
"legal_business_name": "Acme Corp", | ||
"business_type": "partnership", | ||
"customer_facing_business_name": "Example", | ||
"profile": { | ||
"category": "healthcare", | ||
"subcategory": "clinic", | ||
"description": "Healthcare E-commerce platform", | ||
"addresses": { | ||
"operation": { | ||
"street1": "507, Koramangala 6th block", | ||
"street2": "Kormanagala", | ||
"city": "Bengaluru", | ||
"state": "Karnataka", | ||
"postal_code": 560047, | ||
"country": "IN" | ||
}, | ||
"registered": { | ||
"street1": "507, Koramangala 1st block", | ||
"street2": "MG Road", | ||
"city": "Bengaluru", | ||
"state": "Karnataka", | ||
"postal_code": 560034, | ||
"country": "IN" | ||
} | ||
}, | ||
"business_model": "Online Clothing ( men, women, ethnic, modern ) fashion and lifestyle, accessories, t-shirt, shirt, track pant, shoes." | ||
}, | ||
"legal_info": { | ||
"pan": "AAACL1234C", | ||
"gst": "18AABCU9603R1ZM" | ||
}, | ||
"brand": { | ||
"color": "FFFFFF" | ||
}, | ||
"notes": { | ||
"internal_ref_id": "123123" | ||
}, | ||
"contact_name": "Gaurav Kumar", | ||
"contact_info": { | ||
"chargeback": { | ||
"email": "cb@example.org" | ||
}, | ||
"refund": { | ||
"email": "cb@example.org" | ||
}, | ||
"support": { | ||
"email": "support@example.org", | ||
"phone": "9999999998", | ||
"policy_url": "https://www.google.com" | ||
} | ||
}, | ||
"apps": { | ||
"websites": [ | ||
"https://www.example.org" | ||
], | ||
"android": [ | ||
{ | ||
"url": "playstore.example.org", | ||
"name": "Example" | ||
} | ||
], | ||
"ios": [ | ||
{ | ||
"url": "appstore.example.org", | ||
"name": "Example" | ||
} | ||
] | ||
} | ||
} | ||
|
||
|
||
describe('WEBHOOK', () => { | ||
|
||
it('create webhook account', (done) => { | ||
|
||
rzpInstance.accounts.create(setAccount) | ||
.then((response) => { | ||
accountId = response.id | ||
console.log(`created account id: ${accountId}`) | ||
return accountId | ||
}) | ||
.then((id) => { | ||
console.log('created id',accountId) | ||
rzpInstance.webhooks.create({ | ||
"url": "https://google.com", | ||
"alert_email": "gaurav.kumar@example.com", | ||
"secret": "12345", | ||
"events": [ | ||
"payment.authorized", | ||
"payment.failed", | ||
"payment.captured", | ||
"payment.dispute.created", | ||
"refund.failed", | ||
"refund.created" | ||
] | ||
},id) | ||
.then((response)=>{ | ||
webhookId = response.id | ||
assert.ok(response.hasOwnProperty('id')) | ||
assert.ok(response.hasOwnProperty('owner_type')) | ||
done() | ||
}).catch(err => console.log(err)) | ||
}).catch(err => console.log(err)) | ||
|
||
}) | ||
|
||
it('fetch webhook by id', (done) => { | ||
rzpInstance.webhooks.fetch(webhookId, accountId).then((response) => { | ||
assert.ok(response.hasOwnProperty('id')) | ||
assert.ok((response.id === webhookId)) | ||
done() | ||
}).catch(err => console.log(err)) | ||
}) | ||
|
||
it('fetch all webhooks', (done) => { | ||
rzpInstance.webhooks.all(accountId).then((response) => { | ||
assert.ok(response.hasOwnProperty('entity')) | ||
assert.ok(response.hasOwnProperty('items')) | ||
done() | ||
}).catch(err => console.log(err)) | ||
}) | ||
|
||
it('delete account', (done) => { | ||
rzpInstance.accounts.delete(accountId).then((response) => { | ||
console.log(`deleted account id: ${accountId}`) | ||
assert.ok((response.id === accountId)) | ||
assert.ok(response.hasOwnProperty('id')) | ||
done() | ||
}).catch(err => console.log(err)) | ||
}) | ||
}) |