Refunds
Just like Payment 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.
To initiate a refund you need the numerical transaction ID of the successful
payment you want to refund. You receive it in your payment webhooks (as
transaction_id) and when you query a payment's status. It is a plain number,
not a pi_ value.
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.