Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node-sdk Order #223

Merged
merged 1 commit into from
Nov 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions dist/resources/orders.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,23 @@ module.exports = function (api) {
data: data
}, callback);
},
edit: function edit(orderId) {
var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var callback = arguments[2];
var notes = params.notes;


if (!orderId) {
throw new Error('`order_id` is mandatory');
}

var data = Object.assign(normalizeNotes(notes));

return api.patch({
url: '/orders/' + orderId,
data: data
}, callback);
},
fetchPayments: function fetchPayments(orderId, callback) {
if (!orderId) {
throw new Error('`order_id` is mandatory');
Expand Down
15 changes: 15 additions & 0 deletions lib/resources/orders.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,21 @@ module.exports = function (api) {
data
}, callback)
},

edit(orderId, params = {}, callback) {
let { notes } = params

if (!orderId) {
throw new Error('`order_id` is mandatory')
}

let data = Object.assign(normalizeNotes(notes))

return api.patch({
url: `/orders/${orderId}`,
data
}, callback)
},

fetchPayments(orderId, callback) {
if (!orderId) {
Expand Down
27 changes: 27 additions & 0 deletions test/resources/orders.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,31 @@ describe('ORDERS', () => {
})
})
})

describe('edit order', () => {
it('edit order', (done) => {
let orderId = 'order_sometestId'

let params = {
notes: {
note1: 'This is note1',
note2: 'This is note2'
}
}

mocker.mock({
url: `/orders/${orderId}`,
method : 'PATCH'
})

rzpInstance.orders.edit(orderId, params).then((response) => {
assert.equal(
response.__JUST_FOR_TESTS__.url,
`/v1/orders/${orderId}`,
'Request url formed correctly'
)
done()
})
})
})
})