Overview
ThePaymentAdapter interface defines the contract that all payment provider implementations must follow. It provides a unified API for payment operations across different payment providers like Stripe, dLocal, and Paystack.
Interface Definition
Properties
The unique identifier for the payment adapter (e.g.,
"stripe", "dlocal", "paystack").Static provider capability declaration used by routing validation.
Methods
charge
Process a direct charge (immediate payment capture).The payment charge request details including amount, currency, payment method, and customer information.
Promise<PaymentResult> - The result of the charge operation.
authorize
Authorize a payment without capturing funds immediately.The authorization request details. Similar to ChargeRequest but does not capture funds.
Promise<PaymentResult> - The result of the authorization with status "authorized".
capture
Capture funds from a previously authorized payment.The capture request containing the transaction ID and optional amount to capture.
Promise<PaymentResult> - The result of the capture operation.
refund
Refund a completed payment either fully or partially.The refund request containing transaction ID, optional amount, and reason.
Promise<RefundResult> - The result of the refund operation.
void
Cancel an authorized payment before capture.The void request containing the transaction ID to cancel.
Promise<VoidResult> - The result of the void operation.
getStatus
Retrieve the current status of a transaction.The unique identifier of the transaction to query.
Promise<TransactionStatus> - Current transaction status including history.
listPaymentMethods
Get available payment methods for a specific country and currency combination.ISO 3166-1 alpha-2 country code (e.g.,
"US", "BR").ISO 4217 currency code (e.g.,
"USD", "BRL").Promise<PaymentMethodInfo[]> - Array of available payment methods.
handleWebhook (Optional)
Process and verify incoming webhook events from the payment provider.The raw webhook payload received from the provider.
HTTP headers from the webhook request, used for signature verification.
Promise<VaultEvent> | VaultEvent - Normalized webhook event.
Throws: WebhookVerificationError if signature validation fails.
Adapter Constructor
All adapter classes must implement thePaymentAdapterConstructor interface:
Implementation Examples
StripeAdapter
Stripe payment adapter implementation
DLocalAdapter
dLocal payment adapter for Latin America
PaystackAdapter
Paystack payment adapter for Africa
Related Types
ChargeRequest- Request structure for direct chargesAuthorizeRequest- Request structure for payment authorizationCaptureRequest- Request structure for capturing authorized paymentsRefundRequest- Request structure for refundsVoidRequest- Request structure for voiding authorizationsPaymentResult- Standard payment operation resultRefundResult- Refund operation resultVoidResult- Void operation resultTransactionStatus- Transaction status query resultPaymentMethodInfo- Payment method informationVaultEvent- Normalized webhook event