Skip to content

List All Refunds

Returns a paginated list of refund objects related to the current authenticated account. The list is sorted, with the most recent refunds appearing first by default.

Required scope: view-refunds

Parameters

Filter and Sort Refunds

ParameterTypeDescription
sort_fieldstring optionalField you want to sort by. Defaults to created_at.
sort_orderstring optionalSorting order, asc or desc. Defaults to desc.
pageinteger optionalPage number. Defaults to 1.
limitinteger optionalPage size. Defaults to 10, capped at 50.
qstring optionalFree-text search term.
filtersarray optionalAn array of filter criteria where each entry has the following keys:
filters[].fieldstringField you want to filter by.
filters[].valuestringThe value to compare by.
filters[].operatorstringComparison operator. Accepted values: = (default), is, is_not, !=, <, <=, >, >=, in, like, not like.

Returns

Returns a paginated collection of refund objects. If no refunds are found, returns an empty collection.

Request

Endpoint: https://youcanpay.com/api/v2/refundsMethod: GET

bash
$ curl --location -g --request GET 'https://youcanpay.com/api/v2/refunds' \
  --header 'Accept: application/json' \
  --header 'Authorization: Bearer YOUR_TOKEN_eyJpc3...'

Request with Filters

bash
$ curl --location -g --request GET 'https://youcanpay.com/api/v2/refunds?sort_field=amount&sort_order=asc&filters[0][field]=amount&filters[0][value]=10000' \
  --header 'Accept: application/json' \
  --header 'Authorization: Bearer YOUR_TOKEN_eyJpc3...'

Response

json
{
  "object": "v2.refund",
  "data": [
    {
      "object": "v2.refund",
      "id": "83cd9f6d-481a-49c4-9cc1-954c065e6063",
      "transaction_id": "10e7691c-14a2-4936-833b-ec154c817ce9",
      "amount": {
        "amount": "60.00",
        "currency": "MAD",
        "localized": "MAD 60.00"
      },
      "status": "succeeded",
      "is_processed": true,
      "reason": "duplicate",
      "note": null,
      "processed_at": "2024-01-29 15:15:12"
    }
  ],
  "pagination": {
    "current_page": 1,
    "per_page": 10,
    "total": 6,
    "last_page": 1
  }
}

See the Refund object for a description of each field.