💸Refunds

Introduction

Refunds can be created through our API, and you can retrieve, update, and delete refunds as needed. With our refund feature, you can easily process refunds for transactions made through the Sonic Payment Gateway platform.

Create a refund

To create a refund, make a POST request to the following endpoint: https://api.sonicpay.org/api/v1/refunds Include the following information in the request body:

Property
Type
Description

transaction_id

string

The unique identifier of the transaction to be refunded

amount

number

The amount of the refund in the currency of the original transaction

reason

string

A short explanation for the refund

metadata

object

Additional information associated with the refund, in key-value pairs

Example curl request:

curl -X POST https://api.sonicpay.org/api/v1/refunds -H 'Content-Type: application/json' -d '{
  "transaction_id": "trx_12345",
  "amount": 10,
  "reason": "Return policy",
  "metadata": {
    "order_number": "12345"
  }
}'

Get a refund

To retrieve a specific refund, make a GET request to the following endpoint: https://api.sonicpay.org/api/v1/refunds/:id The API will return a 200 OK response if the request is successful, with an object of the refund in the response body.

Example curl request:

curl -X GET https://api.sonicpay.org/api/v1/refunds/ref_12345

Get all Refunds

To retrieve all refunds, make a GET request to the following endpoint: https://api.sonicpay.org/api/v1/refunds The API will return a 200 OK response if the request is successful, with an array of refund objects in the response body.

Example curl request:

curl -X GET https://api.sonicpay.org/api/v1/refunds

Update a Refund

To update an existing refund, make a PUT request to the following endpoint: https://api.sonicpay.org/api/v1/refunds/:id Include the updated information in the request body.

Example curl request:

curl -X PUT https://api.sonicpay.org/api/v1/refunds/ref_12345 -H 'Content-Type: application/json' -d '{
  "amount": 15,
  "reason": "Return policy updated"
}'

Delete a Refund

To delete a refund, make a DELETE request to the following endpoint: https://api.sonicpay.org/api/v1/refunds/:id

Example curl request:

curl -X DELETE https://api.sonicpay.org/api/v1/refunds/:id \
-H 'Authorization: Bearer YOUR_SECRET_KEY'

The API will return a 200 OK response if the request is successful, with a message confirming the deletion of the refund. If the refund does not exist or has already been deleted, the API will return a 404 Not Found error.

Note: Once a refund has been deleted, it cannot be restored. Make sure to double-check the refund ID before making a DELETE request.

Last updated