Skip to content

List All Refunds

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

Parameters

Filter and Sort Refunds

ParameterTypeDescription
sort_fieldenum optionalField you want to sort by. Accepted values: amount (string), status (integer), reason (string), created_at (string).
sort_orderstring optionalSorting order, can either be asc or desc.
limitinteger optionalLimit query result (when working with pagination).
filtersarray optionalAn array of filter criteria where each entry has the following keys:
filters[].fieldenumField you want to filter by. Accepted values: amount (string), status (integer), reason (string), created_at (timestamp).
filters[].valuestringThe value to compare by.
filters[].operatorstringComparison operator (=: default, !=, >, <, =>, <=, is, is_not, in).

Returns

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

Request

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

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

Request with Filters

bash
$ curl --location -g --request GET 'https://api.youcanpay.com/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
{
  "data": [
    {
      "object": "refunds",
      "id": "83cd9f6d-481a-49c4-9cc1-954c065e6063",
      "transaction_id": "10e7691c-14a2-4936-833b-ec154c817ce9",
      "amount": {
        "amount": "6000",
        "currency": "MAD"
      },
      "currency": "MAD",
      "amount_in_mad": {
        "amount": "6000",
        "currency": "MAD"
      },
      "status": 1,
      "status_text": "succeeded",
      "reason": 1,
      "reason_text": "duplicate",
      "created_at": 1706534112,
      "transaction": {
        "data": {
          "object": "transaction",
          "id": "10e7691c-14a2-4936-833b-ec154c817ce9",
          "created_at": 1706515890,
          "paid_at": 1706515899,
          "status": 1,
          "status_text": "paid",
          "customer": "38678dea-d23a-4388-bb78-648892bce85b",
          "order_id": "inv_028ef20c-5065-4515-a0d6-a1c17ff0d53e",
          "payment_method": {
            "type": "credit_card",
            "id": "0fd9bb2c-f14b-411c-bc90-deb73ddaf9ff"
          },
          "amount": {
            "amount": "10000",
            "currency": "MAD",
            "localized": "MAD 100.00"
          },
          "fees": {
            "amount": "690",
            "currency": "MAD",
            "localized": "MAD 6.90"
          },
          "metadata": {
            "type": "youcan_pay.invoice"
          },
          "customer_ip": "192.168.65.1"
        }
      }
    },
    {...}
  ],
  "meta": {
    "pagination": {
      "total": 6,
      "count": 6,
      "per_page": 10,
      "current_page": 1,
      "total_pages": 1,
      "links": {}
    }
  }
}