Interface: PesaPlugin
Defined in: packages/pesa/src/plugins/types.ts:36
Plugin lifecycle hooks.
Plugins are plain objects passed in the plugins array of PesaConfig.
They are composed in order at createPesa() time. No class inheritance.
Properties
| Property | Type | Description | Defined in |
|---|---|---|---|
afterResponse? | (ctx) => Promise<ResponseContext> | Called after each response from a payment provider. Plugins can inspect the response and set ctx.retry = true to trigger a retry (handled by the retry plugin). | packages/pesa/src/plugins/types.ts:51 |
beforeRequest? | (ctx) => Promise<RequestContext> | Called before each outgoing request to a payment provider. Plugins can modify the request context (e.g., add idempotency keys). | packages/pesa/src/plugins/types.ts:44 |
init? | (pesa) => void | Called once at startup. Receives the pesa instance for extension. | packages/pesa/src/plugins/types.ts:80 |
name | string | Unique plugin name (used for logging and debugging). | packages/pesa/src/plugins/types.ts:38 |
onError? | (error, ctx) => Promise<ResponseContext | undefined> | Called when a provider request throws an error. Plugins can inspect the error and set ctx.retry = true + a delay in ctx.metadata.retryDelayMs to trigger a retry. If no plugin sets retry = true, the error is re-thrown. Since 0.6.0 | packages/pesa/src/plugins/types.ts:62 |
onPaymentEvent? | (event) => Promise<void> | Called before a verified PaymentEvent is persisted to the event store. Throw to reject the event — it will bubble up as a webhook error and the event will not be saved. Do not query the event store for this event here — it hasn't been persisted yet. Use for: webhook deduplication, custom verification, spam filtering. For side effects after persistence, register a PesaInstance.on handler instead. | packages/pesa/src/plugins/types.ts:75 |