0.1.4 • Published 6 years ago

soofa v0.1.4

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

node-soofa

This package is aimed at simplifying the process of integrating soofapay payment solution in your Nodejs application. You can check our website for more information.

Installation

 $ npm i soofa

Usage

1. Checking for a transaction
const soofa = require('soofa');

// Initialize
soofa.init("you_soofa_till_number", "your_client_secret_here");

async getTransaction(transactionId, callback) => {
  if (transactionId) {
    let transaction = await soofa.find(transactionId);

    if (
      transaction.hasOwnProperty("tid") &&
      transaction.tid === transactionId
    ) {
          callback(200, { transaction: transaction });

    }else{
        callback(404, { error: "no such transaction" });
    }
  }
};

The expected response for transaction check is a JSON object as shown below.

{
    "status": "SUCCESSFUL",
    "sender_currency": "KES",
    "receiver_currency": "KES",
    "tid": "QTMB3",
    "reference": "T5004",
    "receipt_no": "NFQ6U45W28",
    "timestamp": 1561499777.715254,
    "gross_amount": 5,
    "net_amount": 4.8605,
    "transacted_via": "mpesa",
    "is_money_in": true,
    "sender": "+25470123456",
    "receiver": "Dev Market"
}

The table below describes all the attributes of the transaction object.

KeyDescription
statusThe state of the transaction, either SUCCESSFUL or PENDING
sender_currencyThe currency of the person who performed the transaction
receiver_currencyThe currency of the business, if the transaction was Money in for the business
referenceThe transaction reference passed when making a transaction
timestampUnix timestamp for the transaction
gross_amountThe amount of the transaction
net_amountThe amount received after deducting soofa
transacted_viaThe service provider which facilitated the transaction eg. mpesa, visa, airtelmoney, mastercard, tkash ...
is_money_inA boolean indicating if the money was to the business or out of the business
senderThe performer of transaction
receiverThe receiver of the transaction which is the business if the transaction was inbound
2. Checking your soofa business account balance
const soofa = require('soofa');

// Initialize
soofa.init("you_soofa_till_number", "your_client_secret_here");

const balance = soofa.getBalance()
print(balance)

The expected response for checking balance is a JSON with three fields:

{
    "balance": "1587.49",
    "currency": "KES",
    "timestamp": 1561820831.623298
}
0.1.4

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago