Skip to content

Approval flag for send money #9

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## Installation

yarn install intasend-node
yarn add intasend-node

or using NPM

Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "intasend-node",
"description": "IntaSend official NodeJS SDK",
"version": "1.0.8",
"version": "1.1.2",
"main": "./dist/intasend.js",
"types": "./dist/intasend.d.ts",
"files": [
Expand All @@ -11,7 +11,10 @@
"build": "tsc"
},
"license": "GNU Affero General Public License v3.0",
"repository": "https://github.com/IntaSend/intasend-node.git",
"repository": {
"type": "git",
"url": "git+https://github.com/IntaSend/intasend-node.git"
},
"devDependencies": {
"@types/node": "^18.7.18",
"typescript": "^5.4.5"
Expand Down
20 changes: 12 additions & 8 deletions src/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,12 @@ wallets
// How to send money M-PESA (B2C, B2B, BANK, INTASEND P2P)
// Learn more from our API reference on provider types and fields here - https://developers.intasend.com/reference/send-money_initiate_create
let payouts = intasend.payouts();
var req_approval = "YES"
payouts
.initiate({
provider: 'MPESA-B2B',
currency: 'KES',
requires_approval: req_approval, // Set to 'NO' if you want the transaction to go through without calling the approve method
transactions: [
{
name: 'ABC',
Expand All @@ -84,14 +86,16 @@ payouts
.then((resp) => {
console.log(`Payouts response: ${JSON.stringify(resp)}`);
// Approve payouts
payouts
.approve(resp)
.then((resp) => {
console.log(`Payouts approve: ${JSON.stringify(resp)}`);
})
.catch((err) => {
console.error(`Payouts approve error: ${err}`);
});
// if (req_approval === 'YES'){
// payouts
// .approve(resp)
// .then((resp) => {
// console.log(`Payouts approve: ${JSON.stringify(resp)}`);
// })
// .catch((err) => {
// console.error(`Payouts approve error: ${err}`);
// });
// }
})
.catch((err) => {
console.error(`Payouts error: ${err}`);
Expand Down