Authorize a payment by placing a hold on funds without immediately capturing them. This is useful for pre-authorizations in scenarios like hotel reservations or rental deposits. Use capture() to complete the payment later.
Unique key to prevent duplicate authorizations when retrying the same request. If the same key is used with different request data, a VaultIdempotencyConflictError will be thrown.
The authorize() method may throw the following errors:
VaultIdempotencyConflictError
Thrown when an idempotency key is reused with different request data.
if (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.
Provider-specific errors
Provider errors are caught and wrapped in VaultError instances with provider context.
The authorize operation follows the same flow as charge() (src/client/vault-client.ts:175-208):
Checks for idempotency key and returns cached result if the same request was made previously
Resolves the appropriate payment provider using the same routing logic as charges
Executes the authorization through the selected provider adapter
Normalizes the provider response into a standard PaymentResult format
Records the transaction in the provider index for future capture() or void() calls
Queues transaction report to the platform for analytics
Authorizations typically expire after 7 days, though this varies by provider. Capture the authorization before it expires or the funds will be automatically released. Use void() to explicitly release the hold.
Store the authorization.id to use with capture() for completing the payment or void() for canceling the authorization.