-
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.
Virtual accounts with test cases (#13)
* added virtual accounts api * Virtual Accounts unit tests * Added promise polyfill * Updated readme and wiki * Bumped the version to 1.4.0
- Loading branch information
Showing
12 changed files
with
3,743 additions
and
36 deletions.
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
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,75 @@ | ||
"use strict"; | ||
|
||
const Promise = require("promise"); | ||
const { normalizeDate, normalizeNotes } = require('../utils/razorpay-utils'); | ||
|
||
module.exports = function (api) { | ||
return { | ||
all(params = {}, callback) { | ||
let { from, to, count, skip } = params | ||
let url = '/virtual_accounts' | ||
|
||
if (from) { | ||
from = normalizeDate(from) | ||
} | ||
|
||
if (to) { | ||
to = normalizeDate(to) | ||
} | ||
|
||
count = Number(count) || 10 | ||
skip = Number(skip) || 0 | ||
|
||
return api.get({ | ||
url, | ||
data: { | ||
from, | ||
to, | ||
count, | ||
skip | ||
} | ||
}, callback) | ||
}, | ||
|
||
fetch(virtualAccountId, callback) { | ||
|
||
if (!virtualAccountId) { | ||
|
||
return Promise.reject('`virtual_account_id` is mandatory'); | ||
} | ||
|
||
let url = `/virtual_accounts/${virtualAccountId}` | ||
|
||
return api.get({ | ||
url | ||
}, callback) | ||
}, | ||
|
||
create(params, callback) { | ||
let { notes, ...rest } = params | ||
let data = Object.assign(rest, normalizeNotes(notes)) | ||
|
||
return api.post({ | ||
url: '/virtual_accounts', | ||
data | ||
}, callback) | ||
}, | ||
|
||
close(virtualAccountId, callback) { | ||
|
||
if (!virtualAccountId) { | ||
|
||
return Promise.reject('`virtual_account_id` is mandatory'); | ||
} | ||
|
||
let data = { | ||
status: 'closed' | ||
} | ||
|
||
return api.patch({ | ||
url: `/virtual_accounts/${virtualAccountId}`, | ||
data | ||
}, callback) | ||
}, | ||
} | ||
} |
Oops, something went wrong.