# Order Reversal

> For the complete documentation index, see [llms.txt](https://docs.fondy.io/llms.txt).

This endpoint allows merchants to reverse an order by sending a host-to-host request. 
The request can be made in JSON, XML, or HTML FORM format, and the response will be returned in the same format.

**POST** `/reverse/order_id`

Base URL: `https://pay.fondy.eu/api`

This endpoint allows merchants to reverse an order by sending a host-to-host request. 
The request can be made in JSON, XML, or HTML FORM format, and the response will be returned in the same format.

## Header parameters

- `Content-Type` (string, required)
  Specifies the format for the request. Response will be in the same format.

## Body

Content type: `application/json`

- `request` (object)
  - `order_id` (string, required)
    A unique identifier for the order. This can be any value defined by the merchant, allowing you to use any internal order identification system your business employs.
  - `merchant_id` (integer, required)
    A unique identifier assigned to the merchant by Fondy upon account registration. This ID is required for authenticating requests and associating transactions with the merchant's account.
  - `signature` (string, required)
    Signature for request verification, generated according to Fondy’s algorithm. Required to verify merchant request consistency and authenticity.
    Learn how to use Fondy’s algorithm at the [Signature Generation for Request and Response](doc:signatures) page.
  - `version` (string)
    Specifies the protocol version to use for the reversal request. Default is '1.0' for compatibility with the current API structure.
  - `amount` (integer, required)
    The total amount to be reversed, specified in minor currency units (e.g., cents). For example, 1020 in EUR represents 10 euros and 20 cents. Separators or decimal points aren't allowed.
  - `currency` ("AED" | "AFN" | "ALL" | "AMD" | "ANG" | "AOA" | "ARS" | "AUD" | "AWG" | "AZN" | "BAM" | "BBD" | "BDT" | "BGN" | "BHD" | "BIF" | "BMD" | "BND" | "BOB" | "BRL" | "BSD" | "BTN" | "BWP" | "BZD" | "CAD" | "CDF" | "CHF" | "CLP" | "CNY" | "COP" | "CRC" | "CUP" | "CVE" | "CZK" | "DJF" | "DKK" | "DOP" | "DZD" | "EGP" | "ERN" | "ETB" | "EUR" | "FJD" | "FKP" | "GBP" | "GEL" | "GHS" | "GIP" | "GMD" | "GNF" | "GTQ" | "GYD" | "HKD" | "HNL" | "HRK" | "HTG" | "HUF" | "IDR" | "ILS" | "INR" | "IQD" | "IRR" | "ISK" | "JMD" | "JOD" | "JPY" | "KES" | "KGS" | "KHR" | "KMF" | "KRW" | "KWD" | "KYD" | "KZT" | "LAK" | "LBP" | "LKR" | "LRD" | "LSL" | "LTL" | "LVL" | "LYD" | "MAD" | "MDL" | "MGA" | "MKD" | "MMK" | "MNT" | "MOP" | "MUR" | "MVR" | "MWK" | "MXN" | "MYR" | "MZN" | "NAD" | "NGN" | "NIO" | "NOK" | "NPR" | "NZD" | "OMR" | "PAB" | "PEN" | "PGK" | "PHP" | "PKR" | "PLN" | "PYG" | "QAR" | "RON" | "RSD" | "RWF" | "SAR" | "SBD" | "SCR" | "SDG" | "SEK" | "SGD" | "SHP" | "SLL" | "SOS" | "SRD" | "STD" | "SVC" | "SZL" | "THB" | "TJS" | "TMT" | "TND" | "TOP" | "TRY" | "TTD" | "TWD" | "TZS" | "UAH" | "UGX" | "USD" | "UYU" | "UZS" | "VEF" | "VND" | "VUV" | "WST" | "XAF" | "XCD" | "XOF" | "XPF" | "YER" | "ZAR" | "ZMW" | "ZWD", required)
    Currency for the transaction (e.g., GBP, EUR, USD). Refer to the [Currencies](doc:supported-currencies) page for a full list of available currencies.
  - `comment` (string)
    A comment provided by the merchant to explain the reason for the reversal. The comment must be in UTF-8 format and should describe the context of the reversal.

Example:

```json
{
  "request": {
    "order_id": "ORDER_12345678",
    "merchant_id": 1,
    "signature": "1773cf135bd89656131134b98637894dad42f808",
    "version": "1.0",
    "amount": 1020,
    "currency": "AED",
    "comment": "Customer returned product back."
  }
}
```

## Responses

### 200

Order reversal response in the requested format (JSON, XML, or HTML FORM).

- `response` (object)
  - `order_id` (string)
    A unique identifier for the order. This can be any value defined by the merchant, allowing you to use any internal order identification system your business employs.
  - `merchant_id` (integer)
    A unique identifier assigned to the merchant by Fondy upon account registration. This ID is required for authenticating requests and associating transactions with the merchant's account.
  - `revers_status` ("created" | "declined" | "approved")
    The status of the reversal processing. Indicates whether the reversal  request has been successfully created, declined, or approved.
  - `response_status` (string)
    The status of the request processing. Returns `'success'` if the request  validation passes, or `'failure'` if there are errors in the request.
  - `signature` (string)
    Signature for request verification, generated according to Fondy’s algorithm. Required to verify merchant request consistency and authenticity.
    Learn how to use Fondy’s algorithm at the [Signature Generation for Request and Response](doc:signatures) page.
  - `response_code` (integer)
    A numeric code representing the response outcome. If the request fails,  this field provides a decline code indicating the specific error.
  - `response_description` (string)
    A detailed description of the response, especially in the case of a decline.  Explains the reason for the failure or any additional details about the request outcome.

Example:

```json
{
  "response": {
    "order_id": "ORDER_12345678",
    "merchant_id": 1,
    "revers_status": "approved",
    "response_status": "success",
    "signature": "1773cf135bd89656131134b98637894dad42f808",
    "response_code": 1008,
    "response_description": "Parameter `amount` is mandatory."
  }
}
```