0.1.7 • Published 1 year ago

@giropay/node-sdk v0.1.7

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Giro Node.js SDK

Giro SDK is a comprehensive Node.js SDK designed to simplify the integration with Giro’s powerful API. It provides developers with an easy-to-use interface for accessing core Giro services, such as initiating transactions, retrieving account balances, and more.

Installation

To install the Giro SDK, run:

npm install @giropay/node-sdk
# or
yarn add @giropay/node-sdk

Initialization

The SDK must be initialized using your API secret key. This key is used for authorization.

import { initializeGiroPaySDK } from '@giropay/node-sdk';

// Replace 'your-secret-key' with an actual API secret key
const sdk = initializeGiroPaySDK('your-secret-key');

Methods

1. findAccounts

Fetches all accounts associated with the API key.

ParameterTypeRequiredDescription
namestringNoFilter accounts by name
isDefaultbooleanNoFilter accounts marked as default
livebooleanNoFilter accounts that are live

The parameters when provided, should be passed inside a configuration object. If no configuration is required, the object can be omitted entirely.

Returns: Promise<FindAccountsResponse>

2. updateAccount

Updates the details of a specific account.

ParameterTypeRequiredDescription
accountIdstringYesThe publicId of the account to update
payloadobjectYesThe account details to update
payload.livebooleanNoSet to update account mode
payload.webhooksarrayNoValue should contain the webhook url(s). This should be an array of string(s)
Returns: Promise<UpdateAccountResponse>

3. createWallet

Creates a new wallet.

ParameterTypeRequiredDescription
accountNamestringYesThe name of the new wallet
categorystringYesThe wallet category (e.g., primary or secondary)
currencystringYesThe currency for the new wallet. Value should be NGN
emailAddressstringNoThis should be provided only when wallet category is secondary
mobileobjectNoThis should be provided only when wallet category is secondary.
mobile.phoneNumberstringYesThe mobile number of the customer
mobile.isoCodestringYesValue should be NG

The parameters should be passed inside a configuration object.

Returns: Promise<CreateWalletResponse>

4. findWallets

Fetches wallets based on filters.

ParameterTypeRequiredDescription
categorystringNoThe wallet category (e.g., primary)
livebooleanNoFilter wallets that are live
isFavouritebooleanNoFilter favourite wallets. By default, these are your primary wallets

The parameters when provided, should be passed inside a configuration object. If no configuration is required, the object can be omitted entirely.

Returns: Promise<FindWalletsResponse>

5. getOneWallet

Fetches details of a specific wallet by its ID.

ParameterTypeRequiredDescription
walletIdstringYesThe publicId of the wallet to retrieve
Returns: Promise<GetWalletResponse>

6. getAllBalances

Fetches balances of all wallets associated with the API key.

Parameters: None
Returns: Promise<GetAllBalancesResponse>

7. getBalance

Fetches the balance of a specific wallet by its ID.

ParameterTypeRequiredDescription
walletIdstringYesThe publicId of the wallet to retrieve
Returns: Promise<GetBalanceResponse>

8. createDisposableCollectionWallet

Creates a disposable collection wallet.

ParameterTypeRequiredDescription
accountNamestringYesThe name of the collection wallet
destinationstringYesThe value should be the publicId of the wallet where you want incoming transactions to be settled
amountnumberYesThe amount for the collection. Value should be in kobo
expireInnumberYesRange is 10 mins - 30mins. Value should be in seconds.
referencestringNoWhen provided, this should be unique and minimum length should be 5.

The parameters should be passed inside a configuration object.

Returns: Promise<DisposableCollectionWalletResponse>

9. createTransitCollectionWallet

Creates a new transit collection wallet.

ParameterTypeRequiredDescription
accountNamestringYesThe name of the collection wallet
settlementAccountstringYesThe value should be the publicId of the wallet where you want incoming transactions to be settled
currencystringYesThe currency for the new wallet. Value should be NGN
emailAddressstringNoThe value should be a valid email address
mobileobjectNoThe value should be a valid mobile number
mobile.phoneNumberstringYes
mobile.isoCodestringYesValue should be NG

The parameters should be passed inside a configuration object.

Returns: Promise<TransitCollectionWalletResponse>

10. closeWallet

Closes a wallet by its ID.

ParameterTypeRequiredDescription
walletIdstringYesThe publicId of the wallet to close
Returns: Promise<CloseWalletResponse>

11. findTransactions

Fetches transactions based on filters.

ParameterTypeRequiredDescription
entrystringNoFilter transactions by entry type (e.g., credit)
livebooleanNoFilter transactions that are live
statusstringNoFilter transactions by status (e.g., success)
amountnumberNoFilter transactions by amount. Value should be in kobo
createdAtobjectNoFilter transactions by date-range. Value should be an object containing a date string in this format: {"startDate": "2024-01-01", "endDate": "2024-03-30"}

The parameters when provided, should be passed inside a configuration object. If no configuration is required, the object can be omitted entirely.

Returns: Promise<FindTransactionsResponse>

12. getOneTransaction

Fetches details of a specific transaction by its ID.

ParameterTypeRequiredDescription
transactionIdstringYesThe publicId of the transaction to retrieve
Returns: Promise<GetOneTransactionResponse>

13. findBanks

Fetches a list of supported banks.

Parameters: None

Returns: Promise<FindBanksResponse>

14. initiateWalletTransfer

Initiates a transfer between own wallets.

ParameterTypeRequiredDescription
sourcestringYesThe source wallet publicId
sourceTypestringYesThe type of source (e.g., VirtualAccount)
destinationstringYesThe destination wallet publicId
destinationTypestringYesThe type of destination (e.g., VirtualAccount)
currencystringYesThe currency for the transfer. Value should be NGN
amountnumberYesThe amount to transfer. Value should be in kobo. Minimum transfer is 100 naira
narrationstringYesThe narration for the transfer
referencestringNoOptional reference for the transfer
nameEnquiryRefstringNoOptional name enquiry reference

The parameters should be passed inside a configuration object.

Returns: Promise<InitiateWalletTransferResponse>

15. initiateBankTransfer

Initiates a transfer to a bank account.

ParameterTypeRequiredDescription
sourcestringYesThe source wallet publicId
accountNumberstringYesThe destination bank account number
bankCodestringYesThe bank code of the destination bank
currencystringYesThe currency for the transfer. Value should be NGN
amountnumberYesThe amount to transfer. Value should be in kobo. Minimum transfer is 100 naira
narrationstringYesThe narration for the transfer
referencestringNoOptional reference for the transfer
saveBeneficiarybooleanNoWhether to save the beneficiary details
metadataobjectNoAdditional data to attach to the transaction

The parameters should be passed inside a configuration object.

Returns: Promise<InitiateBankTransferResponse>

16. verifyTransaction

Verifies a transaction by its reference.

ParameterTypeRequiredDescription
referencestringYesThe reference of the transaction to verify
Returns: Promise<VerifyTransactionResponse>

17. findBankAccounts

Fetches bank accounts based on filters.

ParameterTypeRequiredDescription
beneficiaryTypestringNoThe type of beneficiary (e.g., personal)
accountNamestringNoFilter by account name
livebooleanNoFilter bank accounts that are live

The parameters when provided, should be passed inside a configuration object. If no configuration is required, the object can be omitted entirely.

Returns: Promise<FindBankAccountsResponse>

18. getOneBankAccount

Fetches details of a specific bank account by its ID.

ParameterTypeRequiredDescription
bankAccountIdstringYesThe publicId of the bank account to retrieve
Returns: Promise<GetOneBankAccountResponse>

19. validateBankAccount

Validates a bank account.

ParameterTypeRequiredDescription
bankCodestringYesThe bank code of the bank
accountNumberstringYesThe account number to validate

The parameters should be passed inside a configuration object.

Returns: Promise<ValidateBankAccountResponse>

20. addBankAccount

Adds a new bank account.

ParameterTypeRequiredDescription
accountNamestringYesThe name of the bank account holder
accountNumberstringYesThe bank account number
bankCodestringYesThe bank code of the bank
bankNamestringYesThe name of the bank
beneficiaryTypestringNoThe beneficiary type. Value should be 'personal', 'vba', or'external'. Default is personal

The parameters should be passed inside a configuration object.

Returns: Promise<AddBankAccountResponse>

Example

Here is an example of how to use the initiateWalletTransfer method:

await sdk.initiateWalletTransfer({
  source: 'vba-cafdd935-9e82-4e2c-85fdd-d1ff1f43c5b53',
  sourceType: 'VirtualAccount',
  destination: 'vba-5d44d6d1-e2ed-4f83-9704-d956td50eb792',
  destinationType: 'VirtualAccount',
  currency: 'NGN',
  amount: 55000,
  narration: 'giro sdk wallet transfer',
});

In this example, we initiated a transfer of NGN550 from one wallet to another.


For further reference, please refer to the Giro Documentation.

0.1.7

1 year ago

0.1.6

1 year ago

0.1.5

1 year ago

0.1.4

1 year ago

0.1.3

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago