bitpesa-sdk

Client library for BitPesa API

Usage no npm install needed!

<script type="module">
  import bitpesaSdk from 'https://cdn.skypack.dev/bitpesa-sdk';
</script>

README

bitpesa-sdk

BitpesaSdk - JavaScript client for bitpesa-sdk Reference documentation for the BitPesa API V1

For more information, please visit:

Automatically generated by the OpenAPI Generator

Installation

For Node.js

npm

Install the API client library as a dependency in your Node project via:

npm install bitpesa-sdk --save

Getting Started

Please follow the installation instruction.

You can find examples in the examples directory on the features required by the Onboarding documentation

Webhooks

To parse webhooks you can use the following snippet:

const webhookContent = '{ (...) }'; // The string received through the webhook callback url

const webhook = apiClient.parseResponseString(webhookContent, Webhook);
if (webhook.event.startsWith('transaction')) {
  const transactionWebhook = apiClient.parseResponseString(
    webhookContent,
    TransactionWebhook
  );
  console.log(transactionWebhook);
} else if (webhook.event.startsWith('recipient')) {
  const recipientWebhook = apiClient.parseResponseString(
    webhookContent,
    RecipientWebhook
  );
  console.log(recipientWebhook);
} else if (webhook.event.startsWith('payout_method')) {
  const payoutMethodWebhook = apiClient.parseResponseString(
    webhookContent,
    PayoutMethodWebhook
  );
  console.log(payoutMethodWebhook);
} else if (webhook.event.startsWith('sender')) {
  const senderWebhook = apiClient.parseResponseString(
    webhookContent,
    SenderWebhook
  );
  console.log(senderWebhook);
} else if (webhook.event.startsWith('document')) {
  const documentWebhook = apiClient.parseResponseString(
    webhookContent,
    DocumentWebhook
  );
  console.log(documentWebhook);
}

Documentation for API Endpoints

All URIs are relative to https://api-sandbox.bitpesa.co/v1

Class Method HTTP request Description
BitpesaSdk.APILogsApi getApiLog GET /api_logs/{API Log ID} Fetch an individual API log
BitpesaSdk.APILogsApi getApiLogs GET /api_logs Fetch a list of API logs
BitpesaSdk.AccountDebitsApi getAccountsDebit GET /accounts/debits/{Account Debit ID} Fetching an account debit
BitpesaSdk.AccountDebitsApi getAccountsDebits GET /accounts/debits Listing Accounts debits
BitpesaSdk.AccountDebitsApi postAccountsDebits POST /accounts/debits Creating an account debit
BitpesaSdk.AccountValidationApi postAccountValidations POST /account_validations Validates the existence of a bank account
BitpesaSdk.AccountsApi getAccount GET /accounts/{Currency} Fetches account balance for specified currrency
BitpesaSdk.AccountsApi getAccounts GET /accounts Fetches account balances for all currencies
BitpesaSdk.CurrencyInfoApi infoCurrencies GET /info/currencies Getting a list of possible requested currencies
BitpesaSdk.CurrencyInfoApi infoCurrenciesIn GET /info/currencies/in Getting a list of possible input currencies
BitpesaSdk.CurrencyInfoApi infoCurrenciesOut GET /info/currencies/out Getting a list of possible output currencies
BitpesaSdk.DocumentsApi getDocument GET /documents/{Document ID} Fetching a document
BitpesaSdk.DocumentsApi getDocuments GET /documents Getting a list of documents
BitpesaSdk.DocumentsApi postDocuments POST /documents Creating a document
BitpesaSdk.LogsApi getWebhookLog GET /logs/{Webhook Log ID} Fetch an individual webhook log
BitpesaSdk.LogsApi getWebhookLogs GET /logs/webhooks Fetch a list of webhook logs
BitpesaSdk.PaymentMethodsApi paymentMethodsIn GET /info/payment_methods/in This method returns possible payin methods.
BitpesaSdk.PaymentMethodsApi paymentMethodsOut GET /info/payment_methods/out This method returns possible payout methods.
BitpesaSdk.PayoutMethodsApi deletePayoutMethod DELETE /payout_methods/{Payout Method ID} Deleting a payout method
BitpesaSdk.PayoutMethodsApi getPayoutMethod GET /payout_methods/{Payout Method ID} Fetching a payout method
BitpesaSdk.PayoutMethodsApi getPayoutMethods GET /payout_methods Listing payout methods
BitpesaSdk.PayoutMethodsApi patchPayoutMethod PATCH /payout_methods/{Payout Method ID} Updating a payout method
BitpesaSdk.PayoutMethodsApi postPayoutMethods POST /payout_methods Creating a payout method
BitpesaSdk.RecipientsApi deleteRecipient DELETE /recipients/{Recipient ID} Cancelling a recipient
BitpesaSdk.RecipientsApi getRecipients GET /recipients Getting a list of recipients with filtering
BitpesaSdk.RecipientsApi patchRecipient PATCH /recipients/{Recipient ID} Updating a recipient
BitpesaSdk.SendersApi deleteSender DELETE /senders/{Sender ID} Deleting a sender
BitpesaSdk.SendersApi getSender GET /senders/{Sender ID} Fetching a sender
BitpesaSdk.SendersApi getSenders GET /senders Listing senders
BitpesaSdk.SendersApi patchSender PATCH /senders/{Sender ID} Updating a sender
BitpesaSdk.SendersApi postSenders POST /senders Creating a sender
BitpesaSdk.TransactionsApi calculateTransactions POST /transactions/calculate Calculates transaction amounts for a transaction payload
BitpesaSdk.TransactionsApi getTransaction GET /transactions/{Transaction ID} Fetch a single transaction
BitpesaSdk.TransactionsApi getTransactions GET /transactions Get a list of transactions
BitpesaSdk.TransactionsApi payinTransaction POST /transactions/{Transaction ID}/payin Creates a fake payin for transaction
BitpesaSdk.TransactionsApi payoutTransaction POST /transactions/{Transaction ID}/payout Creates a fake payout for transaction
BitpesaSdk.TransactionsApi postTransactions POST /transactions Creates a new transaction
BitpesaSdk.TransactionsApi validateTransactions POST /transactions/validate Validates a transaction payload
BitpesaSdk.WebhooksApi deleteWebhook DELETE /webhooks/{Webhook ID} Unsubscribing from a webhook
BitpesaSdk.WebhooksApi getWebhook GET /webhooks/{Webhook ID} Find a webhook's details
BitpesaSdk.WebhooksApi getWebhookEvents GET /webhooks/events Find possible webhook events
BitpesaSdk.WebhooksApi getWebhooks GET /webhooks Listing webhooks
BitpesaSdk.WebhooksApi postWebhooks POST /webhooks Creating a webhook

Documentation for Models

Documentation for Authorization

You can set the API Key and Secret by passing a config object when creating an ApiClient:

const apiClient = new ApiClient({
  apiKey: '<key>',
  apiSecret: '<secret>',
  basePath: 'https://api-sandbox.bitpesa.co/v1'
});

Or by setting the properties on an ApiClient instance:

const apiClient = new ApiClient();
apiClient.apiKey = '<key>';
apiClient.apiSecret = '<secret>';
apiClient.basePath = 'https://api-sandbox.bitpesa.co/v1';

Author

  • API version: 1.0
  • Package version: 0.2.0
  • Build package: org.openapitools.codegen.languages.JavascriptClientCodegen