0.2.0 • Published 5 years ago

bitpesa-sdk v0.2.0

Weekly downloads
8
License
MIT
Repository
github
Last release
5 years ago

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

ClassMethodHTTP requestDescription
BitpesaSdk.APILogsApigetApiLogGET /api_logs/{API Log ID}Fetch an individual API log
BitpesaSdk.APILogsApigetApiLogsGET /api_logsFetch a list of API logs
BitpesaSdk.AccountDebitsApigetAccountsDebitGET /accounts/debits/{Account Debit ID}Fetching an account debit
BitpesaSdk.AccountDebitsApigetAccountsDebitsGET /accounts/debitsListing Accounts debits
BitpesaSdk.AccountDebitsApipostAccountsDebitsPOST /accounts/debitsCreating an account debit
BitpesaSdk.AccountValidationApipostAccountValidationsPOST /account_validationsValidates the existence of a bank account
BitpesaSdk.AccountsApigetAccountGET /accounts/{Currency}Fetches account balance for specified currrency
BitpesaSdk.AccountsApigetAccountsGET /accountsFetches account balances for all currencies
BitpesaSdk.CurrencyInfoApiinfoCurrenciesGET /info/currenciesGetting a list of possible requested currencies
BitpesaSdk.CurrencyInfoApiinfoCurrenciesInGET /info/currencies/inGetting a list of possible input currencies
BitpesaSdk.CurrencyInfoApiinfoCurrenciesOutGET /info/currencies/outGetting a list of possible output currencies
BitpesaSdk.DocumentsApigetDocumentGET /documents/{Document ID}Fetching a document
BitpesaSdk.DocumentsApigetDocumentsGET /documentsGetting a list of documents
BitpesaSdk.DocumentsApipostDocumentsPOST /documentsCreating a document
BitpesaSdk.LogsApigetWebhookLogGET /logs/{Webhook Log ID}Fetch an individual webhook log
BitpesaSdk.LogsApigetWebhookLogsGET /logs/webhooksFetch a list of webhook logs
BitpesaSdk.PaymentMethodsApipaymentMethodsInGET /info/payment_methods/inThis method returns possible payin methods.
BitpesaSdk.PaymentMethodsApipaymentMethodsOutGET /info/payment_methods/outThis method returns possible payout methods.
BitpesaSdk.PayoutMethodsApideletePayoutMethodDELETE /payout_methods/{Payout Method ID}Deleting a payout method
BitpesaSdk.PayoutMethodsApigetPayoutMethodGET /payout_methods/{Payout Method ID}Fetching a payout method
BitpesaSdk.PayoutMethodsApigetPayoutMethodsGET /payout_methodsListing payout methods
BitpesaSdk.PayoutMethodsApipatchPayoutMethodPATCH /payout_methods/{Payout Method ID}Updating a payout method
BitpesaSdk.PayoutMethodsApipostPayoutMethodsPOST /payout_methodsCreating a payout method
BitpesaSdk.RecipientsApideleteRecipientDELETE /recipients/{Recipient ID}Cancelling a recipient
BitpesaSdk.RecipientsApigetRecipientsGET /recipientsGetting a list of recipients with filtering
BitpesaSdk.RecipientsApipatchRecipientPATCH /recipients/{Recipient ID}Updating a recipient
BitpesaSdk.SendersApideleteSenderDELETE /senders/{Sender ID}Deleting a sender
BitpesaSdk.SendersApigetSenderGET /senders/{Sender ID}Fetching a sender
BitpesaSdk.SendersApigetSendersGET /sendersListing senders
BitpesaSdk.SendersApipatchSenderPATCH /senders/{Sender ID}Updating a sender
BitpesaSdk.SendersApipostSendersPOST /sendersCreating a sender
BitpesaSdk.TransactionsApicalculateTransactionsPOST /transactions/calculateCalculates transaction amounts for a transaction payload
BitpesaSdk.TransactionsApigetTransactionGET /transactions/{Transaction ID}Fetch a single transaction
BitpesaSdk.TransactionsApigetTransactionsGET /transactionsGet a list of transactions
BitpesaSdk.TransactionsApipayinTransactionPOST /transactions/{Transaction ID}/payinCreates a fake payin for transaction
BitpesaSdk.TransactionsApipayoutTransactionPOST /transactions/{Transaction ID}/payoutCreates a fake payout for transaction
BitpesaSdk.TransactionsApipostTransactionsPOST /transactionsCreates a new transaction
BitpesaSdk.TransactionsApivalidateTransactionsPOST /transactions/validateValidates a transaction payload
BitpesaSdk.WebhooksApideleteWebhookDELETE /webhooks/{Webhook ID}Unsubscribing from a webhook
BitpesaSdk.WebhooksApigetWebhookGET /webhooks/{Webhook ID}Find a webhook's details
BitpesaSdk.WebhooksApigetWebhookEventsGET /webhooks/eventsFind possible webhook events
BitpesaSdk.WebhooksApigetWebhooksGET /webhooksListing webhooks
BitpesaSdk.WebhooksApipostWebhooksPOST /webhooksCreating 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