Method signature
Parameters
The transaction ID of the authorization to void.
Unique key to prevent duplicate void operations when retrying the same request.
Returns
Normalized void result containing cancellation details.
Error handling
Thevoid() 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:
- Authorization not found
- Authorization already captured (cannot void a completed charge)
- Authorization already voided
- Authorization expired
Example
Implementation details
The void operation (src/client/vault-client.ts:274-295):
- Looks up the provider that handled the original authorization using the transaction index
- Executes the void operation through the provider adapter
- Returns a
VoidResultwith minimal details (void operations don’t have amounts) - Queues transaction report to the platform with amount set to 0
Void operations are processed through the same provider that handled the original authorization. The operation is immediate and releases the hold on funds.
When to use void vs refund
Use void()
- Transaction is authorized but not captured
- Customer cancels before service/delivery
- Want to release hold immediately
- No funds have been transferred
Use refund()
- Transaction is already captured/charged
- Customer returns product after delivery
- Need to return funds to customer
- Funds have been transferred
Authorization lifecycle
Decision point
You can either:
- Call
capture()to complete the charge - Call
void()to cancel and release the hold - Wait for automatic expiration (typically 7 days)