-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from razorpay/fix/version-bump
Adds dist folder in source repo , to prevent accidental publishing to…
- Loading branch information
Showing
14 changed files
with
1,128 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
node_modules/ | ||
dist/ | ||
|
||
*.orig | ||
*.log | ||
|
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,78 @@ | ||
'use strict'; | ||
|
||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
|
||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
|
||
var request = require('request-promise'); | ||
var nodeify = require('./utils/nodeify'); | ||
|
||
function normalizeError(err) { | ||
throw { | ||
statusCode: err.statusCode, | ||
error: err.error.error | ||
}; | ||
} | ||
|
||
var API = function () { | ||
function API(options) { | ||
_classCallCheck(this, API); | ||
|
||
this.rq = request.defaults({ | ||
baseUrl: options.hostUrl, | ||
json: true, | ||
auth: { | ||
user: options.key_id, | ||
pass: options.key_secret | ||
}, | ||
headers: { | ||
'User-Agent': options.ua | ||
} | ||
}); | ||
} | ||
|
||
_createClass(API, [{ | ||
key: 'get', | ||
value: function get(params, cb) { | ||
return nodeify(this.rq.get({ | ||
url: params.url, | ||
qs: params.data | ||
}).catch(normalizeError), cb); | ||
} | ||
}, { | ||
key: 'post', | ||
value: function post(params, cb) { | ||
return nodeify(this.rq.post({ | ||
url: params.url, | ||
form: params.data | ||
}).catch(normalizeError), cb); | ||
} | ||
}, { | ||
key: 'put', | ||
value: function put(params, cb) { | ||
return nodeify(this.rq.put({ | ||
url: params.url, | ||
form: params.data | ||
}).catch(normalizeError), cb); | ||
} | ||
}, { | ||
key: 'patch', | ||
value: function patch(params, cb) { | ||
return nodeify(this.rq.patch({ | ||
url: params.url, | ||
form: params.data | ||
}).catch(normalizeError), cb); | ||
} | ||
}, { | ||
key: 'delete', | ||
value: function _delete(params, cb) { | ||
return nodeify(this.rq.delete({ | ||
url: params.url | ||
}).catch(normalizeError), cb); | ||
} | ||
}]); | ||
|
||
return API; | ||
}(); | ||
|
||
module.exports = API; |
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,61 @@ | ||
'use strict'; | ||
|
||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
|
||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
|
||
var API = require('./api'); | ||
var pkg = require('../package.json'); | ||
|
||
var Razorpay = function () { | ||
function Razorpay() { | ||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
|
||
_classCallCheck(this, Razorpay); | ||
|
||
var key_id = options.key_id, | ||
key_secret = options.key_secret; | ||
|
||
|
||
if (!key_id) { | ||
throw new Error('`key_id` is mandatory'); | ||
} | ||
|
||
if (!key_secret) { | ||
throw new Error('`key_secret` is mandatory'); | ||
} | ||
|
||
this.key_id = key_id; | ||
this.key_secret = key_secret; | ||
|
||
this.api = new API({ | ||
hostUrl: 'https://api.razorpay.com/v1/', | ||
ua: 'razorpay-node@' + Razorpay.VERSION, | ||
key_id: key_id, | ||
key_secret: key_secret | ||
}); | ||
this.addResources(); | ||
} | ||
|
||
_createClass(Razorpay, [{ | ||
key: 'addResources', | ||
value: function addResources() { | ||
Object.assign(this, { | ||
payments: require('./resources/payments')(this.api), | ||
refunds: require('./resources/refunds')(this.api), | ||
orders: require('./resources/orders')(this.api), | ||
customers: require('./resources/customers')(this.api), | ||
transfers: require('./resources/transfers')(this.api), | ||
virtualAccounts: require('./resources/virtualAccounts')(this.api), | ||
invoices: require('./resources/invoices')(this.api) | ||
}); | ||
} | ||
}]); | ||
|
||
return Razorpay; | ||
}(); | ||
|
||
Razorpay.VERSION = pkg.version; | ||
|
||
|
||
module.exports = Razorpay; |
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,53 @@ | ||
'use strict'; | ||
|
||
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } | ||
|
||
var _require = require('../utils/razorpay-utils'), | ||
normalizeNotes = _require.normalizeNotes; | ||
|
||
module.exports = function (api) { | ||
return { | ||
create: function create(params, callback) { | ||
var notes = params.notes, | ||
rest = _objectWithoutProperties(params, ['notes']); | ||
|
||
var data = Object.assign(rest, normalizeNotes(notes)); | ||
|
||
return api.post({ | ||
url: '/customers', | ||
data: data | ||
}, callback); | ||
}, | ||
edit: function edit(customerId, params, callback) { | ||
var notes = params.notes, | ||
rest = _objectWithoutProperties(params, ['notes']); | ||
|
||
var data = Object.assign(rest, normalizeNotes(notes)); | ||
|
||
return api.put({ | ||
url: '/customers/' + customerId, | ||
data: data | ||
}, callback); | ||
}, | ||
fetch: function fetch(customerId, callback) { | ||
return api.get({ | ||
url: '/customers/' + customerId | ||
}, callback); | ||
}, | ||
fetchTokens: function fetchTokens(customerId, callback) { | ||
return api.get({ | ||
url: '/customers/' + customerId + '/tokens' | ||
}, callback); | ||
}, | ||
fetchToken: function fetchToken(customerId, tokenId, callback) { | ||
return api.get({ | ||
url: '/customers/' + customerId + '/tokens/' + tokenId | ||
}, callback); | ||
}, | ||
deleteToken: function deleteToken(customerId, tokenId, callback) { | ||
return api.delete({ | ||
url: '/customers/' + customerId + '/tokens/' + tokenId | ||
}, callback); | ||
} | ||
}; | ||
}; |
Oops, something went wrong.