Vesicash Node.js sdk
Nodejs API wrapper for Vesicash
Table of content
- Documentation
- Installation
- Usage
- Resources
- Note
- Auth
- Transactions
transaction.create()
create a transactiontransaction.sendTransaction()
Send a transaction to involved parties.transaction.partiesUpdate()
Update the parties involved in a transaction.transaction.acceptTransaction()
Agree to transactiontransaction.rejectTransaction()
Reject a transactiontransaction.listById()
Fetch transaction detailstransaction.listByBusiness()
List all the transaction belonging to you business or your customerstransaction.listByUser()
List all the transactions that belongs to a specific customertransaction.requestExtendDueDate()
Request transaction due date extensiontransaction.approveExtendDueDate()
Approve a transaction due date extension requesttransaction.delivered()
Mark transaction as shippedtransaction.acceptDelivery()
Accept a shipped transactiontransaction.rejectDelivery()
Reject shipped transaction
- Payment
- Admin
- Upload
- Development
- Issues
Documentation
Take a look at the API Docs here
Installation
Install the package from npm by running
$ npm install vesicash-nodejs-sdk
or
$ yarn add vesicash-nodejs-sdk
Usage
To use this sdk you need to first generate your API keys by registering as a business on Vesicash.
Sandbox API key by registering via https://sandbox.vesicash.com/signup
Live API key by registering via https://vesicash.com/signup
const Vesicash = ; const credentials = publicKey: 'VESICASH-PUBLIC-KEY' // replace with your generated PUBLIC Key privateKey: 'VESICASH-PRIVATE-KEY' // replace with your generated PRIVATE Key; const isSandbox = true; // for Sandbox, defaults to false // Initialize the class passing the configconst vesicash = credentials isSandbox; // Create a transaction try const transaction = await vesicashtransactions // do somthing with transaction responsecatch error // AxiosError
Resources
Note:
All method returns a promise that resolves into an axios response in this format
Auth
-
#####
auth.login()
login into vesicash...tryconst response = await vesicashauth;// do something with responsecatch e// -
#####
auth.signup()
Signup a new user...tryconst response = await vesicashauth;// do something with responsecatch e//
Learn more about authentication
Transactions
-
#####
transaction.create()
create a transaction...const payload =title: "Design a house plan"type: "oneoff"quantity: 1amount: 700000description: "An architectural design of a 3 bedroom apartment in lekki"parties:buyer : 'BUYER-ACCOUNT-ID'charge_bearer: 'CHARGE-BEARER-ACCOUNT-ID'sender: 'SENDER-ACCOUNT-ID'seller: 'SELLER-ACCOUNT-ID'recipient: 'RECIPIENT-ACCOUNT-ID'due_date: "2/12/2020"inspection_period: 1currency: "NGN";tryconst response = await vesicashtransactions;// do something with responsecatch e//
Learn more about transactions and how to creat different types of transactions.
-
#####
transaction.sendTransaction()
Send a transaction to involved parties....tryconst payload =transaction_id: "F2SUkXINIJ6ALjDmt3cT" // the transaction-id;const response = await vesicashtransactions;// do something with responsecatch e//
Learn more about sending transactions.
-
#####
transaction.partiesUpdate()
Update the parties involved in a transaction....tryconst payload =transaction_id:"F2SUkXINIJ6ALjDmt3cT" // the transaction-idparties:recipient:account_id: 3881795242;const response = await vesicashtransactions;// do something with responsecatch e//
Learn more about transaction parties.
-
#####
transaction.acceptTransaction()
Agree to transaction...tryconst payload =transaction_id:"F2SUkXINIJ6ALjDmt3cT" // the transaction-id;const response = await vesicashtransactions;// do something with responsecatch e//
Learn more about agreeing to a transaction.
-
#####
transaction.rejectTransaction()
Reject a transaction...tryconst payload ="transaction_id": "F2SUkXINIJ6ALjDmt3cT" // the transaction id"reason": "I am rejecting this transaction because the amount stated is not what we discussed";const response = await vesicashtransactions;// do something with responsecatch e//
Learn more about rejecting a transaction.
-
#####
transaction.listById()
Fetch transaction details...tryconst payload = "F2SUkXINIJ6ALjDmt3cT"; // the transaction idconst response = await vesicashtransactions;// do something with responsecatch e//
Learn more about fetching a transaction.
-
#####
transaction.listByBusiness()
List all the transaction belonging to you business or your customers...tryconst payload ="business_id": "ACCOUNT-ID" // the business account id;const response = await vesicashtransactions;// do something with responsecatch e//
Learn more about listing transactions.
-
#####
transaction.listByUser()
List all the transactions that belongs to a specific customer...tryconst payload ="account_id": "ACCOUNT-ID" // the account id;const response = await vesicashtransactions;// do something with responsecatch e//
Learn more about listing transactions.
-
#####
transaction.requestExtendDueDate()
Request transaction due date extension...tryconst payload =transaction_id: "F2SUkXINIJ6ALjDmt3cT" // the transaction iddue_date:"12/2/2020";const response = await vesicashtransactions;// do something with responsecatch e//
Learn more about due date extension.
-
#####
transaction.approveExtendDueDate()
Approve a transaction due date extension request...tryconst payload =transaction_id: "F2SUkXINIJ6ALjDmt3cT" // the transaction iddue_date:"12/2/2020";const response = await vesicashtransactions;// do something with responsecatch e//
Learn more about due date extension.
-
#####
transaction.delivered()
Mark transaction as shipped...tryconst payload =transaction_id: "F2SUkXINIJ6ALjDmt3cT" // the transaction id;const response = await vesicashtransactions;// do something with responsecatch e//
Learn more about transaction delivery.
-
#####
transaction.acceptDelivery()
Accept a shipped transaction...tryconst payload =transaction_id: "F2SUkXINIJ6ALjDmt3cT" // the transaction id;const response = await vesicashtransactions;// do something with responsecatch e//
Learn more accepting a shipped transaction.
-
#####
transaction.rejectDelivery()
Reject shipped transaction...tryconst payload =transaction_id: "F2SUkXINIJ6ALjDmt3cT" // the transaction idreason: "Rejection reasons";const response = await vesicashtransactions;// do something with responsecatch e//
Learn more rejecting a shipped transaction.
Payment
-
####
payment.fundTransaction()
Fund a transaction...tryconst payload =transaction_id: "F2SUkXINIJ6ALjDmt3cT" // the transaction idsuccess_page: "https://website.com/payment/success" // A URL where you want the payer to be directed after payment - optional field;const response = await vesicashpayment;// do something with responsecatch e//
Learn more funding a transaction.
-
####
payment.initiateDisbursement()
Initiate a manual disbursement...tryconst payload =recipient_id: 'ACCOUNT-ID' // your recipient account IDamount: 1000currency: "NGN"debit_currency: "NGN";const response = await vesicashpayment;// do something with responsecatch e//
Learn more initiating a manual disbursement.
Admin
-
####
admin.addBank()
Adding Bank or Mobile Money Details...tryconst payload =account_id : 6751951308 // your account idupdates:bank_id : 23account_name : "John Doe"account_no : "3012364609"mobile_money_operator: "Tigo" // (this field is only required when saving a mobile money details);const response = await vesicashadmin;// do something with responsecatch e//
Learn more adding Bank or Mobile Money Details.
-
####
admin.walletBalance()
Check wallet balance...tryconst payload =account_id : 'ACCOUNT-ID' // your account id;const response = await vesicashadmin;// do something with responsecatch e//
Learn more about wallet balance.
Upload
-
####
upload.uploadFile()
upload a file.This method expects a formdata
...tryconst FormData = ;const fs = ;const files =fsfsfs;// Add all the uploaded file to form datafor let i = 0; i < fileslength; i++FormData;const response = await vesicashupload;// do something with responsecatche//
Learn more about wallet balance.
Development
Contributing
-
clone the project
$ git clone https://github.com/vesicash/nodejs-sdk.git -
install dependencies
$ npm install -
Env
-
Get your sandbox API keys via https://sandbox.vesicash.com
-
Rename
.env.example
to.env
and update the API keys -
Please follow the eslint rules to ensure consistent code style
Tests
To run all tests
$ npm run test
Issues
If you find a bug, please file an issue on our issue tracker on GitHub