Skip to content

Commit

Permalink
Paymentlink fix (#366)
Browse files Browse the repository at this point in the history
  • Loading branch information
ankitdas13 authored Jul 18, 2023
1 parent d447ddf commit 9e36e95
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 26 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 2.9.1 - 2023-07-13

fix: Create paymentLink request

## 2.9.0 - 2023-06-30

feat: Added new API endpoints
Expand Down
39 changes: 23 additions & 16 deletions lib/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,19 @@ class API {
form: params.data
};

if(params.hasOwnProperty('formData')){
delete request['form'];
request.formData = params.formData;
}
if (params.hasOwnProperty('formData')) {
delete request['form'];
request.formData = params.formData;
}
return nodeify(this.rq.post(request).catch(normalizeError), cb);
}

return nodeify(this.rq.post(request).catch(normalizeError), cb);
postBody(params, cb) {
let request = {
url: this.getEntityUrl(params),
body: params.data
};
return nodeify(this.rq.post(request).catch(normalizeError), cb);
}

put(params, cb) {
Expand All @@ -90,18 +97,18 @@ class API {

patch(params, cb) {
let request = {
url: this.getEntityUrl(params),
form: params.data
};

if(params.data.hasOwnProperty("isbody")) {
delete request['form'];
delete params.data.isbody;
request.body = params.data;
}
return nodeify(this.rq.patch(request).catch(normalizeError), cb);
url: this.getEntityUrl(params),
form: params.data
};

if(params.data.hasOwnProperty("isbody")) {
delete request['form'];
delete params.data.isbody;
request.body = params.data;
}

return nodeify(this.rq.patch(request).catch(normalizeError), cb);
}

delete(params, cb) {
return nodeify(this.rq.delete({
url: this.getEntityUrl(params)
Expand Down
13 changes: 5 additions & 8 deletions lib/resources/paymentLink.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module.exports = function paymentLinkApi (api) {

return {

create (params={}, callback) {
create (params, callback) {

/*
* Creates Payment Link.
Expand All @@ -25,14 +25,11 @@ module.exports = function paymentLinkApi (api) {
* @return {Promise}
*/

let url = BASE_URL,
{ notes, ...rest } = params,
data = Object.assign(params);

return api.post({
let url = BASE_URL;
return api.postBody({
url,
data
}, callback,true)
data: params
}, callback)
},
cancel (paymentLinkId, callback) {

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "razorpay",
"version": "2.9.0",
"version": "2.9.1",
"description": "Official Node SDK for Razorpay API",
"main": "dist/razorpay",
"typings": "dist/razorpay",
Expand Down
3 changes: 2 additions & 1 deletion test/resources/paymentLink.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ describe("PAYMENTLINK", () => {
};
mocker.mock({
url: `/payment_links`,
method: 'POST'
method: 'POST',
ignoreParseBody: true
})

rzpInstance.paymentLink.create(params).then((response) => {
Expand Down

0 comments on commit 9e36e95

Please sign in to comment.