@borapesa/pesa
Classes
| Class | Description |
|---|---|
| BasePaymentProvider | Abstract base class every provider adapter must implement. |
| PesaError | Base error class for all Bora Pesa errors. |
| PesaNetworkError | Thrown when a provider API is unreachable or returns a network error. |
| PesaProviderError | Thrown when the provider returns an error response (provider error). |
| PesaUnsupportedError | Thrown when a provider does not implement an optional operation. |
| PesaValidationError | Thrown when payload validation fails (client error). |
| PesaWebhookError | Thrown when a webhook fails signature verification. |
| SQLiteAdapter | SQLite event store adapter powered by better-sqlite3. |
Interfaces
| Interface | Description |
|---|---|
| CancelOrderPayload | Payload for cancelling a pending or in-progress order. |
| CancelOrderResult | Result returned after cancelling a payment order. |
| CreateOrderPayload | Payload for creating a payment order. |
| DisbursePayload | Payload for sending a disbursement (B2C / wallet-out). |
| DisburseResult | Result returned after initiating a disbursement. |
| ListOrdersParams | Parameters for listing payment orders. |
| ListOrdersResult | Result returned when listing orders. |
| NameLookupResult | Result of a name lookup — resolves the account holder name for a phone number or bank account before disbursing. |
| OrderResult | Result returned after initiating a payment. |
| PaymentEvent | Normalized payment event — the source of truth for all payment activity. |
| PesaConfig | Configuration passed to createPesa. |
| PesaDatabaseAdapter | Database adapter interface for the event store. |
| PesaHandlerTarget | Minimal interface for the pesa instance that the handler needs. Defined here (not imported from pesa.ts) to avoid circular dependencies. |
| PesaInstance | Fully configured payments SDK instance — returned by createPesa. |
| PesaPlugin | Plugin lifecycle hooks. |
| PreviewResult | Result of a preview / dry-run validation before committing an action. |
| RefundResult | Result returned after initiating a refund. |
| RequestContext | Context passed to beforeRequest hooks. Allows plugins to inspect and modify the outgoing request. |
| ResponseContext | Context passed to afterResponse hooks. Allows plugins to inspect the provider response and decide on retries. |
Type Aliases
| Type Alias | Description |
|---|---|
| Currency | Supported currencies. |
| MobileNetwork | Supported mobile money networks for disbursement (B2C payouts). |
| PaymentEventType | Event types emitted after webhook verification and persistence. |
| PaymentStatus | Payment lifecycle statuses. |
| ProviderName | All supported payment providers. |
| TZSAmount | TZS amount as a whole integer. 15000 = TZS 15,000. |
Functions
| Function | Description |
|---|---|
| createPesa | The single entry point for the entire Bora Pesa SDK. |
| createPesaHandler | Creates a generic fetch-like handler that can be mounted on any framework. |
| validateCreateOrderPayload | Validate a CreateOrderPayload before forwarding to the provider. Throws PesaValidationError on invalid input. |
| validateDisbursePayload | Validate a DisbursePayload before forwarding to the provider. Throws PesaValidationError on invalid input. |