Skip to content
Open
Show file tree
Hide file tree
Changes from 3 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
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