PaymentClient API Reference
ThePaymentClient is the main entry point for FundKit integration. It provides a unified interface to interact with multiple payment providers.
Constructor
new PaymentClient(config)
Creates a new PaymentClient instance with provider configurations.
Parameters:
config(PaymentClientConfig): Configuration object
Methods
collect(request)
Initiates a payment collection request using the best available provider.
Parameters:
request(CollectionRequest): Payment collection details
Promise<PayClientCollectionResponse>
Example:
amount: Must be positive integercurrency: Must be supported by at least one providerphoneNumber: Must be valid international formatreason: Required, minimum 3 characters
checkTransactionStatus(transactionId, provider?)
Checks the current status of a transaction.
Parameters:
transactionId(string): Transaction ID to checkprovider(string, optional): Specific provider to query
Promise<PayClientTransactionResponse>
Example:
getAvailableProviders()
Returns list of configured and available providers.
Returns: string[]
Example:
getProviderCurrencies(provider?)
Returns supported currencies for a provider or all providers.
Parameters:
provider(string, optional): Specific provider name
string[] | Record<string, string[]>
Example:
validateRequest(request)
Validates a collection request without executing it.
Parameters:
request(CollectionRequest): Request to validate
ValidationResult
Example:
Events
The PaymentClient extends EventEmitter and emits various events during operation.Event: transaction:created
Emitted when a new transaction is created.
Event: transaction:updated
Emitted when a transaction status changes.
Event: provider:selected
Emitted when a provider is selected for a transaction.
Event: error
Emitted when an error occurs.
Webhook Configuration
Webhooks are configured at thePaymentClient level, providing a unified webhook endpoint for all providers.
Webhook Configuration
Webhook Event Structure
All webhook events follow this unified structure:Webhook Headers
Webhook requests include the following headers:X-Webhook-Signature: HMAC-SHA256 signatureX-Webhook-Timestamp: Unix timestamp for replay attack prevention