bloc-nodejs v0.2.0
Bloc Nodejs SDK
A Nodejs API wrapper for Bloc banking services written in typescript
Table of content
- Prerequisites
- Getting started
- Installation
- Usage
- Available Methods exposed by the SDK
- License
Prerequisites
Node v16 and higher is required. To make sure you have them available on your machine, try running the following command.
node -vGetting Started
To get started with this SDK, create an account on Bloc if you haven't already. You can then retrieve your API keys from your Bloc dashboard.
Installation
This SDK can be installed with npm or yarn or pnpm.
# using npm
npm install bloc-nodejs
# using yarn
yarn install bloc-nodejs
# using pnpm
pnpm add bloc-nodejsUsage
Import and Initialize the library
// use modules
import { Bloc } from 'bloc-nodejs';
// use cjs
const { Bloc } = require('bloc-nodejs')
// Instantiate the bloc class
const bloc = new Bloc('SECRET_KEY, PUBLIC_KEY');Available Methods exposed by the SDK
Accounts API
Accounts API operations
Create Fixed Account
// import the accounts interfaces from the sdk
import type { ICreateFixedAccountRequest, IAccountResponse } from 'bloc-nodejs';
const payload: ICreateFixedAccountRequest = {
// payload data
}
const response = await bloc.createFixedAccount(payload)
console.log(response) // IAccountResponseFind more details about the parameters and response for the above method here
Create Collection Account
// import the accounts interfaces from the sdk
import type { ICreateCollectionAccountRequest, ICreateCollectionAccountResponse } from 'bloc-nodejs';
const payload: ICreateCollectionAccountRequest = {
// payload data
}
const response = await bloc.createCollectionAccount(payload)
console.log(response) // ICreateCollectionAccountResponseFind more details about the parameters and response for the above method here
Get Accounts
// import the accounts interfaces from the sdk
import type { IGetAccountsResponse } from 'bloc-nodejs';
const response = await bloc.getAccounts(payload)
console.log(response) // IGetAccountsResponseFind more details about the parameters and response for the above method here
Get Account By ID
// import the accounts interfaces from the sdk
import type { IAccountResponse } from 'bloc-nodejs';
const response = await bloc.getAccountById('account-id')
console.log(response) // IAccountResponseFind more details about the parameters and response for the above method here
Get Collection Account
// import the accounts interfaces from the sdk
import type { IGetCollectionAccountResponse } from 'bloc-nodejs';
const response = await bloc.getCollectionAccount()
console.log(response) // IGetCollectionAccountResponseFind more details about the parameters and response for the above method here
Get Account by Account Number
// import the accounts interfaces from the sdk
import type { IAccountResponse } from 'bloc-nodejs';
const response = await bloc.getAccountByAccountNumber('account-number')
console.log(response) // IAccountResponseFind more details about the parameters and response for the above method here
Get Customer Accounts
// import the accounts interfaces from the sdk
import type { IGetAccountsResponse } from 'bloc-nodejs';
const response = await bloc.getCustomerAccounts('customer-id')
console.log(response) // IGetAccountsResponseFind more details about the parameters and response for the above method here
Get Organisation Default Accounts
// import the accounts interfaces from the sdk
import type { IGetOrganisationDefaultAccountsResponse } from 'bloc-nodejs';
const response = await bloc.getOrganisationDefaultAccounts()
console.log(response) // IGetOrganisationDefaultAccountsResponseFind more details about the parameters and response for the above method here
Freeze Account
// import the accounts interfaces from the sdk
import type { IUpdateAccountRequest, IUpdateAccountResponse } from 'bloc-nodejs';
const payload: IUpdateAccountRequest = {
// payload data
}
const response = await bloc.freezeAccount('account-id', data)
console.log(response) // IUpdateAccountResponseFind more details about the parameters and response for the above method here
Unfreeze Account
// import the accounts interfaces from the sdk
import type { IUpdateAccountRequest, IUpdateAccountResponse } from 'bloc-nodejs';
const payload: IUpdateAccountRequest = {
// payload data
}
const response = await bloc.unfreezeAccount('account-id', data)
console.log(response) // IUpdateAccountResponseFind more details about the parameters and response for the above method here
Close Account
// import the accounts interfaces from the sdk
import type { IUpdateAccountRequest, IUpdateAccountResponse } from 'bloc-nodejs';
const payload: IUpdateAccountRequest = {
// payload data
}
const response = await bloc.closeAccount('account-id', data)
console.log(response) // IUpdateAccountResponseFind more details about the parameters and response for the above method here
Reopen Account
// import the accounts interfaces from the sdk
import type { IUpdateAccountRequest, IUpdateAccountResponse } from 'bloc-nodejs';
const payload: IUpdateAccountRequest = {
// payload data
}
const response = await bloc.reopenAccount('account-id', data)
console.log(response) // IUpdateAccountResponseFind more details about the parameters and response for the above method here
Wallets API
Wallets API operations
Create Wallet
// import the wallet interfaces from the sdk
import type { IWallet, IWalletResponse } from 'bloc-nodejs';
const payload: IWallet = {
// payload to create wallet
}
const response = await bloc.createWallet(payload)
console.log(response) // IWalletResponseFind more details about the parameters and response for the above method here
Get Wallets
// import the wallet interfaces from the sdk
import type { IGetWalletResponse } from 'bloc-nodejs';
const response = await bloc.getWallets()
console.log(response) // IGetWalletResponseFind more details about the parameters and response for the above method here
Get Wallet By ID
// import the wallet interfaces from the sdk
import type { IWalletResponse } from 'bloc-nodejs';
const response = await bloc.getWalletById('wallet-id')
console.log(response) // IWalletResponseFind more details about the parameters and response for the above method here
Get Customer Wallets
// import the wallet interfaces from the sdk
import type { IGetCustomerWalletResponse } from 'bloc-nodejs';
const response = await bloc.getCustomerWallets('customer-id')
console.log(response) // IGetCustomerWalletResponseFind more details about the parameters and response for the above method here
Debit Wallet
// import the wallet interfaces from the sdk
import type { IDebitWallet, IGetCustomerWalletResponse } from 'bloc-nodejs';
const payload: IDebitWallet = {
// payload to debit wallet
}
const response = await bloc.debitWallet(payload)
console.log(response) // IGetCustomerWalletResponseFind more details about the parameters and response for the above method here
Bills Payments API
Bills Payments API operations
Get Supported Bills
// import the bills-payments interfaces from the sdk
import type { ISupportedBillsResponse } from 'bloc-nodejs';
const response = await bloc.getSupportedBills()
console.log(response) // ISupportedBillsResponseFind more details about the parameters and response for the above method here
Get Supported Operators
// import the bills-payments interfaces from the sdk
import type { ISupportedOperatorsResponse } from 'bloc-nodejs';
const response = await bloc.getSupportedOperators()
console.log(response) // ISupportedOperatorsResponseFind more details about the parameters and response for the above method here
Get Operator Products
// import the bills-payments interfaces from the sdk
import type { IOperatorProductsResponse } from 'bloc-nodejs';
const response = await bloc.getOperatorProducts('operator-id')
console.log(response) // IOperatorProductsResponseFind more details about the parameters and response for the above method here
Customer Device Validation
// import the bills-payments interfaces from the sdk
import type { IGetCustomerWalletResponse } from 'bloc-nodejs';
const response = await bloc.customerDeviceValidation('operator-id')
console.log(response) // IGetCustomerWalletResponseFind more details about the parameters and response for the above method here
Make Payment
// import the bills-payment interfaces from the sdk
import type { IMakePaymentResponse, IMakePaymentResponse } from 'bloc-nodejs';
const payload: IMakePaymentResponse = {
// payload to make payment
}
const response = await bloc.makePayment(payload)
console.log(response) // IMakePaymentResponseFind more details about the parameters and response for the above method here
Disputes API
Disputes API operations
Get Card Dispute Reasons
// import the disputes interfaces from the sdk
import type { IGetCardDisputeReasonsResponse } from 'bloc-nodejs';
const response = await bloc.getCardDisputeReasons()
console.log(response) // IGetCardDisputeReasonsResponseFind more details about the parameters and response for the above method here
Create Card Dispute
// import the disputes interfaces from the sdk
import type { ICreateCardDisputeRequest, ICardDisputeResponse } from 'bloc-nodejs';
const payload: ICreateCardDisputeRequest = {
// payload to create card dispute
}
const response = await bloc.createCardDispute(payload)
console.log(response) // ICardDisputeResponseFind more details about the parameters and response for the above method here
Get Card Disputes
// import the disputes interfaces from the sdk
import type { IGetCardDisputesResponse } from 'bloc-nodejs';
const response = await bloc.getCardDisputes()
console.log(response) // IGetCardDisputesResponseFind more details about the parameters and response for the above method here
Get Card Dispute
// import the disputes interfaces from the sdk
import type { ICardDisputeResponse } from 'bloc-nodejs';
const response = await bloc.getCardDisputeById('dispute-id')
console.log(response) // ICardDisputeResponseFind more details about the parameters and response for the above method here
Update Card Dispute
// import the disputes interfaces from the sdk
import type { IUpdateCardDisputeRequest, ICardDisputeResponse } from 'bloc-nodejs';
const payload: IUpdateCardDisputeRequest = {
// payload to update card dispute
}
const response = await bloc.updateCardDispute('dispute-id', payload)
console.log(response) // ICardDisputeResponseFind more details about the parameters and response for the above method here
Cards API
Cards API operations
Issue Card
// import the cards interfaces from the sdk
import type { IIssueCardRequest, ICardResponse } from 'bloc-nodejs';
const payload: IIssueCardRequest = {
// payload to issue card
}
const response = await bloc.issueCard(payload)
console.log(response) // ICardResponseFind more details about the parameters and response for the above method here
Get Cards
// import the cards interfaces from the sdk
import type { IGetCardsResponse } from 'bloc-nodejs';
const response = await bloc.getCards()
console.log(response) // IGetCardsResponseFind more details about the parameters and response for the above method here
Get Card by Id
// import the cards interfaces from the sdk
import type { ICardResponse } from 'bloc-nodejs';
const response = await bloc.getCardById('card-id')
console.log(response) // ICardResponseFind more details about the parameters and response for the above method here
Get Customer Cards
// import the cards interfaces from the sdk
import type { IGetCardsResponse } from 'bloc-nodejs';
const response = await bloc.getCustomerCards('customer-id')
console.log(response) // IGetCardsResponseFind more details about the parameters and response for the above method here
Get Card Secure Data
// import the cards interfaces from the sdk
import type { ICardSecureDataResponse } from 'bloc-nodejs';
const response = await bloc.getCardSecureData('card-id')
console.log(response) // ICardSecureDataResponseFind more details about the parameters and response for the above method here
Change Card PIN
// import the cards interfaces from the sdk
import type { IChangeCardPinRequest, ICardResponse } from 'bloc-nodejs';
const payload: IChangeCardPinRequest = {
// payload to change card pin
}
const response = await bloc.changeCardPIN('card-id', payload)
console.log(response) // ICardResponseFind more details about the parameters and response for the above method here
Freeze Card
// import the cards interfaces from the sdk
import type { ICardResponse } from 'bloc-nodejs';
const response = await bloc.freezeCard('card-id')
console.log(response) // ICardResponseFind more details about the parameters and response for the above method here
Unfreeze Card
// import the cards interfaces from the sdk
import type { ICardResponse } from 'bloc-nodejs';
const response = await bloc.unfreezeCard('card-id')
console.log(response) // ICardResponseFind more details about the parameters and response for the above method here
Block Card
// import the cards interfaces from the sdk
import type { IBlockCardRequest, ICardResponse } from 'bloc-nodejs';
const payload: IBlockCardRequest = {
// payload to block card
}
const response = await bloc.blockCard('card-id', payload)
console.log(response) // ICardResponseFind more details about the parameters and response for the above method here
Link Card with Fixed Account
// import the cards interfaces from the sdk
import type { ILinkCardwithFixedAccountRequest, ICardResponse } from 'bloc-nodejs';
const payload: ILinkCardwithFixedAccountRequest = {
// payload to link card with fixed account
}
const response = await bloc.linkCardwithFixedAccount(payload)
console.log(response) // ICardResponseFind more details about the parameters and response for the above method here
Unlink Card From Fixed Account
// import the cards interfaces from the sdk
import type { ICardResponse } from 'bloc-nodejs';
const response = await bloc.unlinkCardwithFixedAccount('card-id')
console.log(response) // ICardResponseFind more details about the parameters and response for the above method here
Fund Card
// import the cards interfaces from the sdk
import type { IFundCardRequest, ICardResponse } from 'bloc-nodejs';
const payload: IFundCardRequest = {
// payload to fund card
}
const response = await bloc.fundCard('card-id', payload)
console.log(response) // ICardResponseFind more details about the parameters and response for the above method here
Withdraw From Card
// import the cards interfaces from the sdk
import type { IWithdrawFromCardRequest, ICardResponse } from 'bloc-nodejs';
const payload: IWithdrawFromCardRequest = {
// payload to withdraw from card
}
const response = await bloc.withdrawFromCard('card-id', payload)
console.log(response) // ICardResponseFind more details about the parameters and response for the above method here
Checkout API
Checkout API operations
Create Checkout
// import the create checkout interfaces from the sdk
import type { ICreateCheckout, ICheckoutResponse } from 'bloc-nodejs';
const payload: ICreateCheckout = {
// payload to create checkout
}
const response = await bloc.createCheckout(payload)
console.log(response) // ICheckoutResponseFind more details about the parameters and response for the above method here
Customers API
Customer API operations
Create Customer
// import the customer interfaces from the sdk
import type { ICreateCustomer, ICreateCustomerResponse } from 'bloc-nodejs';
const payload: ICreateCustomer = {
// payload to create checkout
}
const response = await bloc.createCustomer(payload)
console.log(response) // ICreateCustomerResponseFind more details about the parameters and response for the above method here
Get Customers
// import the message interfaces from the sdk
import type { IGetCustomerResponse } from 'bloc-nodejs';
const response = await bloc.getCustomers()
console.log(response) // IGetCustomerResponseFind more details about the parameters and response for the above method here
Upgrade Customer to KYC T1
// import the customer interfaces from the sdk
import type { IUpgradeCustomerToKYCT1, IUpgradeCustomerToKYCTierResponse } from 'bloc-nodejs';
const payload: IUpgradeCustomerToKYCT1 = {
// payload data
}
const response = await bloc.upgradeCustomerToKYCT1('customer-id', payload)
console.log(response) // IUpgradeCustomerToKYCTierResponseFind more details about the parameters and response for the above method here
Upgrade Customer to KYC T2
// import the customer interfaces from the sdk
import type { IUpgradeCustomerToKYCT2, IUpgradeCustomerToKYCTierResponse } from 'bloc-nodejs';
const payload: IUpgradeCustomerToKYCT2 = {
// payload data
}
const response = await bloc.upgradeCustomerToKYCT2('customer-id', payload)
console.log(response) // IUpgradeCustomerToKYCTierResponseFind more details about the parameters and response for the above method here
Upgrade Customer to KYC T3
// import the customer interfaces from the sdk
import type { IUpgradeCustomerToKYCT3, IUpgradeCustomerToKYCTierResponse } from 'bloc-nodejs';
const payload: IUpgradeCustomerToKYCT3 = {
// payload data
}
const response = await bloc.upgradeCustomerToKYCT3('customer-id', payload)
console.log(response) // IUpgradeCustomerToKYCTierResponseFind more details about the parameters and response for the above method here
Update Customer
// import the customer interfaces from the sdk
import type { IUpdateCustomer, IUpdateCustomerResponse } from 'bloc-nodejs';
const payload: IUpdateCustomer = {
// payload data
}
const response = await bloc.updateCustomer('customer-id', payload)
console.log(response) // IUpdateCustomerResponseFind more details about the parameters and response for the above method here
Get Customer By ID
// import the customer interfaces from the sdk
import type { IGetCustomerByIdResponse } from 'bloc-nodejs';
const response = await bloc.getCustomerById('customer-id')
console.log(response) // IGetCustomerByIdResponseFind more details about the parameters and response for the above method here
Means of Identification
// import the customer interfaces from the sdk
import type { IMeansOfIdentification } from 'bloc-nodejs';
const response = await bloc.meansOfIdentification()
console.log(response) // IMeansOfIdentificationFind more details about the parameters and response for the above method here
Revalidate Customer KYC
// import the customer interfaces from the sdk
import type { IRevalidateCustomerKYCResponse } from 'bloc-nodejs';
const response = await bloc.revalidateCustomerKYC('customer-id')
console.log(response) // IRevalidateCustomerKYCResponseFind more details about the parameters and response for the above method here
Miscellaneous API
Miscellaneous API operations
Get List of Banks
// import the miscellaneous interfaces from the sdk
import type { IListOfBanksResponse } from 'bloc-nodejs';
const response = await bloc.getListOfBanks()
console.log(response) // IListOfBanksResponseFind more details about the parameters and response for the above method here
Resolve Account
// import the miscellaneous interfaces from the sdk
import type { IResolveAccountResponse } from 'bloc-nodejs';
const response = await bloc.resolveAccount()
console.log(response) // IResolveAccountResponseFind more details about the parameters and response for the above method here
Get Exchange Rate
// import the miscellaneous interfaces from the sdk
import type { IGetExchangeRateResponse } from 'bloc-nodejs';
const response = await bloc.getExchangeRate('NGN-USD')
console.log(response) // IGetExchangeRateResponseFind more details about the parameters and response for the above method here
Simulation API
Simulation API operations
Credit Account
// import the simulation interfaces from the sdk
import type { ISimulationAccount, ICreditAccountResponse } from 'bloc-nodejs';
const payload: ISimulationAccount = {
// payload data
}
const response = await bloc.creditAccount(payload)
console.log(response) // ICreditAccountResponseFind more details about the parameters and response for the above method here
Debit Account
// import the simulation interfaces from the sdk
import type { ISimulationAccount, IDebitAccountResponse } from 'bloc-nodejs';
const payload: ISimulationAccount = {
// payload data
}
const response = await bloc.debitAccount(payload)
console.log(response) // IDebitAccountResponseFind more details about the parameters and response for the above method here
Transactions API
Transactions API operations
Get All Transactions
// import the transactions interfaces from the sdk
import type { ITransactionResponse } from 'bloc-nodejs';
const response = await bloc.getAllTransactions()
console.log(response) // ITransactionResponseFind more details about the parameters and response for the above method here
Get Transaction by Reference
// import the transactions interfaces from the sdk
import type { ITransactionByReferenceResponse } from 'bloc-nodejs';
const response = await bloc.getTransactionByReference('ref_num')
console.log(response) // ITransactionByReferenceResponseFind more details about the parameters and response for the above method here
Transfers API
Transfers API operations
Transfer From A Fixed Account
// import the transfers interfaces from the sdk
import type { ITransferFromAFixedAccountRequest, ITransferResponse } from 'bloc-nodejs';
const payload: ITransferFromAFixedAccountRequest = {
// payload data
}
const response = await bloc.transferFromAFixedAccount(payload)
console.log(response) // ITransferResponseFind more details about the parameters and response for the above method here
Transfer From Organization Balance
// import the transfers interfaces from the sdk
import type { ITransferFromOrganizationBalance, ITransferResponse } from 'bloc-nodejs';
const payload: ITransferFromOrganizationBalance = {
// payload data
}
const response = await bloc.transferFromOrganizationBalance(payload)
console.log(response) // ITransferResponseFind more details about the parameters and response for the above method here
Internal Transfer
// import the transfers interfaces from the sdk
import type { IInternalTransferRequest, ITransferResponse } from 'bloc-nodejs';
const payload: IInternalTransferRequest = {
// payload data
}
const response = await bloc.internalTransfer(payload)
console.log(response) // ITransferResponseFind more details about the parameters and response for the above method here
Bulk Transfer
// import the transfers interfaces from the sdk
import type { IBulkTransferRequest, ITransferResponse } from 'bloc-nodejs';
const payload: IBulkTransferRequest = {
// payload data
}
const response = await bloc.bulkTransfer(payload)
console.log(response) // ITransferResponseFind more details about the parameters and response for the above method here
Webhook API
Webhook API operations
Set Webhook
// import the webhook interfaces from the sdk
import type { ISetWebhook, IWebhookResponse } from 'bloc-nodejs';
const payload: ISetWebhook = {
// payload data
}
const response = await bloc.setWebhook(payload)
console.log(response) // IWebhookResponseFind more details about the parameters and response for the above method here
Get Webhook
// import the webhook interfaces from the sdk
import type { IWebhookResponse } from 'bloc-nodejs';
const response = await bloc.getWebhook()
console.log(response) // IWebhookResponseFind more details about the parameters and response for the above method here
Payment Links API
Payment Link API operations
Create Payment Link
// import the payment-links interfaces from the sdk
import type { ICreatePaymentLinkRequest, IPaymentLinkResponse } from 'bloc-nodejs';
const payload: ICreatePaymentLinkRequest = {
// payload data
}
const response = await bloc.createPaymentLink(payload)
console.log(response) // IPaymentLinkResponseFind more details about the parameters and response for the above method here
Get Payment Links
// import the payment-links interfaces from the sdk
import type { IGetPaymentLinksResponse } from 'bloc-nodejs';
const response = await bloc.getPaymentLinks()
console.log(response) // IGetPaymentLinksResponseFind more details about the parameters and response for the above method here
Get Payment Link By id
// import the payment-links interfaces from the sdk
import type { IPaymentLinkResponse } from 'bloc-nodejs';
const response = await bloc.getPaymentLinkById('link-id')
console.log(response) // IPaymentLinkResponseFind more details about the parameters and response for the above method here
Edit Payment Link
// import the payment-links interfaces from the sdk
import type { IEditPaymentLinkRequest, IPaymentLinkResponse } from 'bloc-nodejs';
const payload: IEditPaymentLinkRequest = {
// payload data
}
const response = await bloc.editPaymentLink('link-id', payload)
console.log(response) // IPaymentLinkResponseFind more details about the parameters and response for the above method here
Delete Payment Link
// import the payment-links interfaces from the sdk
import type { IDeletePaymentLinksRequest, IPaymentLinkResponse } from 'bloc-nodejs';
const payload: IDeletePaymentLinksRequest = {
// payload data
}
const response = await bloc.deletePaymentLink(payload)
console.log(response) // IPaymentLinkResponseFind more details about the parameters and response for the above method here
Beneficiaries API
Beneficiaries API operations
Create Beneficiary
// import the beneficiary interfaces from the sdk
import type { ICreateBeneficiary, IBeneficiaryResponse } from 'bloc-nodejs';
const payload: ICreateBeneficiary = {
// payload data
}
const response = await bloc.createBeneficiary(payload)
console.log(response) // IBeneficiaryResponseFind more details about the parameters and response for the above method here
Get Beneficiary by ID
// import the beneficiary interfaces from the sdk
import type { IBeneficiaryResponse } from 'bloc-nodejs';
const response = await bloc.getBeneficiaryById('beneficiary-id')
console.log(response) // IBeneficiaryResponseFind more details about the parameters and response for the above method here
Update Beneficiary
// import the beneficiary interfaces from the sdk
import type { IUpdateBeneficiary, IBeneficiaryResponse } from 'bloc-nodejs';
const payload: ICreateBeneficiary = {
// payload data
}
const response = await bloc.updateBeneficiary('beneficiary-id', payload)
console.log(response) // IBeneficiaryResponseFind more details about the parameters and response for the above method here
Delete Beneficiary
const response = await bloc.deleteBeneficiary('beneficiary-id')
console.log(response) // anyFind more details about the parameters and response for the above method here