Method signature
Parameters
The transaction ID of the original charge or capture to refund.
Partial refund amount in smallest currency unit. Omit to refund the full transaction amount.
Human-readable reason for the refund, forwarded to the payment provider.
Unique key to prevent duplicate refunds when retrying the same request.
Returns
Normalized refund result containing refund details and status.
Error handling
Therefund() method may throw the following errors:
VaultIdempotencyConflictError
VaultIdempotencyConflictError
Thrown when an idempotency key is reused with different request data.
VaultRoutingError
VaultRoutingError
Thrown when the provider for the original transaction cannot be found.
Provider-specific errors
Provider-specific errors
The provider may return errors such as:
- Transaction not found
- Transaction not refundable (e.g., already fully refunded)
- Refund amount exceeds original transaction amount
- Refund window expired
Example
Implementation details
The refund operation (src/client/vault-client.ts:247-272):
- Looks up the provider that handled the original transaction using the transaction index
- Executes the refund through the provider adapter
- Returns a
RefundResultwith refund details (not a fullPaymentResult) - Queues transaction report to the platform for analytics
Refunds are processed through the same provider that handled the original transaction. You cannot refund a Stripe charge through Adyen, for example.
Refund status lifecycle
Provider processing
The payment provider processes the refund and initiates the transfer back to the customer.