Skip to content
This repository was archived by the owner on Jun 26, 2025. It is now read-only.
Open
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
171 changes: 75 additions & 96 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "moyasar",
"version": "0.5.1",
"version": "0.6.0",
"description": "Moyasar node SDK",
"main": "lib/moyasar.js",
"scripts": {
Expand Down Expand Up @@ -32,5 +32,6 @@
"dependencies": {
"request": "^2.88.0",
"request-promise": "^4.2.2"
}
},
"resolutions": { "**/lodash": "^4.17.15" }
}
30 changes: 30 additions & 0 deletions src/payment.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,34 @@ export default class extends Service {
return res;
})
}

capture(payment, option){
let id;
let params = {};
if (typeof payment == "object" && payment.id)
id = payment.id;
else if (typeof payment == "string")
id = payment;
else
throw new Error("Please provide a valid payment object or payment id");
if (option && option.amount) {
if (!isNaN(parseFloat(option.amount)) && isFinite(option.amount)) {
params = {
amount: option.amount,
};
} else {
throw new Error("Please provide a valid amount");
}
}
return this.sendRequest('payments/'+id+'/capture','POST', params);
}

void(payment){
if (typeof payment.id != "string") {
throw new Error('Payment object does not have id');
}
return this.sendRequest('payments/'+ payment.id +'/void','POST',payment).then(res=>{
return res;
})
}
}
Loading