Execute a one-step payment charge with immediate capture
Execute a one-step payment charge that immediately captures funds from the customer’s payment method. The charge is routed to the appropriate payment provider based on your configured routing rules.
Unique key to prevent duplicate charges when retrying the same request. If the same key is used with different request data, a VaultIdempotencyConflictError will be thrown.
The charge() method may throw the following errors:
VaultIdempotencyConflictError
Thrown when an idempotency key is reused with different request data.
// src/client/vault-client.ts:612-619if (existingRecord.payloadHash !== payloadHash) { throw new VaultIdempotencyConflictError( 'Idempotency key was reused with a different payload.', { operation, key } );}
VaultRoutingError
Thrown when no eligible provider is found or when routing configuration is invalid.
// src/client/vault-client.ts:428-430throw new VaultRoutingError( 'No eligible provider found after exclusions.');
Provider-specific errors
Provider errors are caught and wrapped in VaultError instances with provider context. See src/client/vault-client.ts:636-652.
Checks for idempotency key and returns cached result if the same request was made previously
Resolves the appropriate payment provider using routing rules (src/client/vault-client.ts:375-437)
Executes the charge through the selected provider adapter
Normalizes the provider response into a standard PaymentResult format
Records the transaction in the provider index for future lookups
Queues transaction report to the platform for analytics (if configured)
The charge method supports automatic idempotency to safely retry failed requests. Store the id from the response to reference this transaction in future operations like refunds.