Refunds
Just like Payment & Checkout Intents, refunds work on the basis of a promise: when you create a refund it is possible that it does not get completed straight away, this is a gateway-specific behaviour.
You will need a Payment Intent ID to initiate a refund.
Workflow
- Create a refund using the Refund API and store the Refund ID. If the refund has an immutable success/failure status, your workflow ends here.
- Listen for refund updates by webhook.
Validation Errors
Because each gateway may have different refund limitations, you may get various error codes when initiating a refund. However, you will always have a human readable message when an error occures, in the message property. You can safely display this error message in your front-end.
Timeouts
You can specify a timeout after which the Refund will be considered failed if it did not succeed beforehand.
Lifecycle
You can see the entire lifecycle of a refund and their status in Lifecycle.