Bora PesaBora Pesa

@borapesa/pesa

Classes

ClassDescription
BasePaymentProviderAbstract base class every provider adapter must implement.
MemoryAdapterIn-memory event store — zero dependencies, perfect for dev and CI.
PesaErrorBase error class for all Bora Pesa errors.
PesaNetworkErrorThrown when a provider API is unreachable or returns a network error.
PesaProviderErrorThrown when the provider returns an error response (provider error).
PesaUnsupportedErrorThrown when a provider does not implement an optional operation.
PesaValidationErrorThrown when payload validation fails (client error).
PesaWebhookErrorThrown when a webhook fails signature verification.

Interfaces

InterfaceDescription
BalanceEntryA single currency balance entry.
BalanceResultResult of a balance inquiry — returns available balances across all active currencies in the provider's wallet.
CancelOrderPayloadPayload for cancelling a pending or in-progress order.
CancelOrderResultResult returned after cancelling a payment order.
CreateOrderPayloadPayload for creating a payment order.
DisbursePayloadPayload for sending a disbursement (B2C / wallet-out).
DisburseResultResult returned after initiating a disbursement.
ListOrdersParamsParameters for listing payment orders.
ListOrdersResultResult returned when listing orders.
NameLookupResultResult of a name lookup — resolves the account holder name for a phone number or bank account before disbursing.
OrderResultResult returned after initiating a payment.
PaymentEventNormalized payment event — the source of truth for all payment activity.
PesaConfigConfiguration passed to createPesa.
PesaDatabaseAdapterDatabase adapter interface for the event store.
PesaHandlerTargetMinimal interface for the pesa instance that the handler needs.
PesaInstanceFully configured payments SDK instance — returned by createPesa.
PesaPluginPlugin lifecycle hooks.
PreviewResultResult of a preview / dry-run validation before committing an action.
RefundResultResult returned after initiating a refund.
RequestContextContext passed to beforeRequest hooks. Allows plugins to inspect and modify the outgoing request.
ResponseContextContext passed to afterResponse hooks. Allows plugins to inspect the provider response and decide on retries.

Type Aliases

Type AliasDescription
CurrencySupported currencies.
MobileNetworkSupported mobile money networks for disbursement (B2C payouts).
PaymentEventTypeEvent types emitted after webhook verification and persistence.
PaymentStatusPayment lifecycle statuses.
ProviderNameAll supported payment providers.
TZSAmountTZS amount as a whole integer. 15000 = TZS 15,000.

Functions

FunctionDescription
createPesaThe single entry point for the entire Bora Pesa SDK.
createPesaWebhookHandlerCreates a webhook handler — the one route that must be publicly exposed.
normalisePhoneNormalise a Tanzania phone number to canonical MSISDN format (255XXXXXXXXX).
validateCreateOrderPayloadValidate a CreateOrderPayload before forwarding to the provider. Throws PesaValidationError on invalid input.
validateDisbursePayloadValidate a DisbursePayload before forwarding to the provider. Throws PesaValidationError on invalid input.

On this page