Cancel Refunds
There may be scenarios in which you need to cancel a refund, such as a refund issued in error or a customer decides to keep a product or service.
PublicSquare API offers the ability to cancel a refund before it is settled.
Getting Started
To get started, you will need a PublicSquare Account.
Get your Secret Key
Next you will need your Secret Key. Go to your Developers section and click Reveal for your Secret Key and copy the value.
Cancel the Refund
In order to cancel a refund, we will need the ID of a refund. Assuming you have a refund similar to:
{
"id": "rfd_2YKewBonG4tgk12MheY3PiHDy",
"account_id": "acc_B518niGwGYKzig6vtrRVZGGGV",
"environment": "test",
"status": "succeeded",
...
}
We need to make a call to Cancel Refund endpoint:
curl 'https://api.publicsquare.com/refunds/cancel' \
-X 'POST' \
-H 'X-API-KEY: <SECRET_API_KEY>' \
-H 'Content-Type: application/json' \
-d '{
"refund_id": "rfd_2YKewBonG4tgk12MheY3PiHDy"
}'
Refund Response
Given the above examples, you should see a cancelled refund result similar to:
{
"id": "rfd_2YKewBonG4tgk12MheY3PiHDy",
"account_id": "acc_B518niGwGYKzig6vtrRVZGGGV",
"environment": "test",
"status": "cancelled",
"transaction_id": "trx_95rvMJvAVeG68W4NtLdfkN3LG",
"amount": 1000,
...
"transaction": {
"id": "trx_95rvMJvAVeG68W4NtLdfkN3LG",
"account_id": "acc_B518niGwGYKzig6vtrRVZGGGV",
"environment": "test",
"status": "cancelled",
"amount": -1000,
"fee_amount": 0,
"net_amount": -1000,
...
},
...
}
Handling Cancellation Failures
If a refund cannot be cancelled because the refund has already been settled, an error response will be returned:
{
"title": "Error",
"status": 400,
"detail": "refund cancellation failed."
}
Conclusion
Following this guide, you should have been able to successfully cancel a refund. Follow these guides to learn more: