diff --git a/dist/resources/orders.js b/dist/resources/orders.js index 9bf5b24f..daa4670d 100644 --- a/dist/resources/orders.js +++ b/dist/resources/orders.js @@ -64,11 +64,12 @@ module.exports = function (api) { receipt = params.receipt, payment_capture = params.payment_capture, notes = params.notes, - otherParams = _objectWithoutProperties(params, ['amount', 'currency', 'receipt', 'payment_capture', 'notes']); + method = params.method, + otherParams = _objectWithoutProperties(params, ['amount', 'currency', 'receipt', 'payment_capture', 'notes', 'method']); currency = currency || 'INR'; - if (!amount) { + if (!(amount || method === 'emandate' && amount === 0)) { throw new Error('`amount` is mandatory'); } @@ -80,6 +81,7 @@ module.exports = function (api) { amount: amount, currency: currency, receipt: receipt, + method: method, payment_capture: normalizeBoolean(payment_capture) }, otherParams), normalizeNotes(notes)); diff --git a/lib/resources/orders.js b/lib/resources/orders.js index 8e2bc155..30afc140 100644 --- a/lib/resources/orders.js +++ b/lib/resources/orders.js @@ -43,11 +43,11 @@ module.exports = function (api) { }, create(params = {}, callback) { - let { amount, currency, receipt, payment_capture, notes, + let { amount, currency, receipt, payment_capture, notes, method, ...otherParams } = params currency = currency || 'INR' - if (!amount) { + if (!(amount || (method === 'emandate' && amount === 0))) { throw new Error('`amount` is mandatory') } @@ -59,6 +59,7 @@ module.exports = function (api) { amount, currency, receipt, + method, payment_capture: normalizeBoolean(payment_capture), ...otherParams }, normalizeNotes(notes)) diff --git a/test/resources/orders.spec.js b/test/resources/orders.spec.js index 021f83d5..1c66542c 100644 --- a/test/resources/orders.spec.js +++ b/test/resources/orders.spec.js @@ -104,6 +104,18 @@ describe('ORDERS', () => { 'Should throw exception when amount is not provided' ) + try { + rzpInstance.orders.create({ + method: 'emandate', + }) + } catch (e) { + assert.equal( + e.message, + '`amount` is mandatory', + 'Should throw exception when amount is not provided with emandate method' + ) + } + try { rzpInstance.orders.create({ amount: 100