Cancel Order

PATCH/orders/{orderIdOrNumber}/cancel

The PATCH /orders/{orderIdOrNumber}/cancel endpoint is used to cancel a specific order by updating its status to CANCELLED. This endpoint is typically used when an order needs to be stopped before it is fulfilled or processed. Write access is required to use this endpoint.

Request Method: PATCH

Endpoint URL: https://api.fungies.io/v0/orders/{orderIdOrNumber}/cancel

Headers:

x-fngs-public-key: <api-key>

x-fngs-secret-key: <api-key>

Example:

Authorization: x-fngs-public-key: <api-key>
Authorization: x-fngs-secret-key: <api-key>

Note: This endpoint requires an API key for authentication. Refer to this guide to generate your API key.

Path Parameters

The Path Parameters are required to specify the order that needs to be canceled.

  • orderIdOrNumber (string) required: Identifies the specific order to cancel. This parameter accepts either the unique order ID (Option 1) or the order number (Option 2) to process the cancellation request.

Request Body

The request body for the Cancel Order API is of type object. This body structure allows the system to process the order cancellation request, ensuring the specified order is updated accordingly.

Responses Body

Response (200) - Success

The response confirms that the order cancellation request was successfully processed.

  1. status (string) required: Indicates the outcome of the API request. The allowed value is success, confirming that the cancellation was applied.

  2. data (object) required: The data object contains details related to the canceled order. It includes the following children:

— data.order (object) required: This object holds the details of the order and other relevant information. It includes the following children:

  • data.order.id (string) required: A unique identifier assigned to the order.

  • data.order.number (string) required: The order number is used for reference and tracking.

  • data.order.status (enum) required: Represents the current status of the order. Available options: PENDING, PAID, FAILED, UNPAID, CANCELLED, REFUNDED, PARTIALLY_REFUNDED, EXPIRED.

  • data.order.createdAt (integer) required: The timestamp represents when the order was created. Required range: 0 <= x <= 9007199254740991

  • data.order.userId (string) required: The unique identifier of the user associated with the order.

  • data.order.orderNumber (string) required: The reference number assigned to the order for tracking purposes.

  • data.order.object (enum) default: order: Represents the type of object. Available options: order

  • data.order.value (integer | null) default: 0: Represents the monetary value of the order. Required range: -9007199254740991 <= x <= 9007199254740991

  • data.order.tax (integer | null) default: 0: The amount of tax applied to the order. Required range: -9007199254740991 <= x <= 9007199254740991

  • data.order.fee (integer | null) default: 0: The additional fee associated with the order, such as processing or service fees. Required range: -9007199254740991 <= x <= 9007199254740991

  • data.order.totalItems (integer | null) default: 0: The total number of items included in the order. Required range: 0 <= x <= 9007199254740991

  • data.order.country (string | null): The country associated with the order, typically where it was placed or where it will be delivered.

  • data.order.currency (enum | null): The currency used for the order transaction. Available options: AFN (Afghanistan), ALL (Albania), DZD (Algeria), AOA (Angola), ARS (Argentina), AMD (Armenia), AWG (Aruba), AUD (Australia), AZN (Azerbaijan), BSD (Bahamas), BDT (Bangladesh), BBD (Barbados), BZD (Belize), BMD (Bermuda), BOB (Bolivia), BAM (Bosnia and Herzegovina), BWP (Botswana), BRL (Brazil), BHD (Bahrain), GBP (United Kingdom), BND (Brunei), BGN (Bulgaria), BIF (Burundi), BYN (Belarus), KHR (Cambodia), CAD (Canada), CVE (Cape Verde), KYD (Cayman Islands), KWD (Kuwait), XAF (Central African CFA), XPF (CFP Franc), CLP (Chile), CNY (China), COP (Colombia), KMF (Comoros), CDF (Congo - Kinshasa), CRC (Costa Rica), HRK (Croatia), CZK (Czech Republic), DKK (Denmark), DJF (Djibouti), DOP (Dominican Republic), XCD (East Caribbean Dollar), EGP (Egypt), ETB (Ethiopia), EUR (Eurozone), FKP (Falkland Islands), FJD (Fiji), GMD (Gambia), GEL (Georgia), GIP (Gibraltar), GTQ (Guatemala), GNF (Guinea), GYD (Guyana), HTG (Haiti), HNL (Honduras), HKD (Hong Kong), HUF (Hungary), ISK (Iceland), INR (India), IDR (Indonesia), ILS (Israel), JMD (Jamaica), JPY (Japan), JOD (Jordan), KZT (Kazakhstan), KES (Kenya), KGS (Kyrgyzstan), LAK (Laos), LBP ( Lebanon), LSL (Lesotho), LRD (Liberia), MOP (Macau), MKD (North Macedonia), MGA (Madagascar), MWK (Malawi), MYR (Malaysia), MVR (Maldives), MRO (Mauritania), MUR (Mauritius), MXN (Mexico), MDL (Moldova), MNT (Mongolia), MAD (Morocco), MZN (Mozambique), MMK (Myanmar), NAD (Namibia), NPR (Nepal), ANG (Netherlands Antilles), TWD (Taiwan), NZD (New Zealand), NIO (Nicaragua), NGN (Nigeria), NOK (Norway), OMR (Oman), PKR (Pakistan), PAB (Panama), PGK (Papua New Guinea), PYG (Paraguay), PEN (Peru), PHP (Philippines), PLN (Poland), QAR (Qatar), RON (Romania), RUB (Russia), RWF (Rwanda), SHP (Saint Helena), SVC (El Salvador), WST (Samoa), STD (São Tomé and Príncipe), SAR (Saudi Arabia), RSD (Serbia), SCR (Seychelles), SLL (Sierra Leone), SGD (Singapore), SBD (Solomon Islands), SOS (Somalia), ZAR (South Africa), KRW (South Korea), LKR (Sri Lanka), SRD (Suriname), SZL (Eswatini), SEK (Sweden), CHF (Switzerland), TJS (Tajikistan), TZS ( Tanzania), THB( Thailand), TND (Tunisia), TOP (Tonga), TTD (Trinidad and Tobago), TRY (Turkey), UGX (Uganda), UAH (Ukraine), AED (United Arab Emirates), UYU (Uruguay), USD (United States), UZS (Uzbekistan), VUV (Vanuatu), VEF (Venezuela), VND (Vietnam), XOF (West African CFA), YER (Yemen), ZMW (Zambia), SLE (Sierra Leone).

  • data.order.currencyDecimals (integer | null): Specifies the number of decimal places used in the currency format for the order. Required range: -9007199254740991 <= x <= 9007199254740991

  • data.order.user (object | null): Contains user-related details associated with the order. It includes the following children:

    • data.order.user.id (string) required: A unique identifier is assigned to the user.

    • data.order.user.object (enum) default: user: Specifies the type of object. The available option is user

    • data.order.user.username (string | null): The username of the user associated with the order.

Response (400) - Error

  1. status (string) required: Represents the outcome of the API request. The allowed value is an error, indicating that the request was unsuccessful.

  2. error (object) required: Contains details about the error encountered during the request. It includes the following child attributes:

    1. error.message (string) required: A descriptive message explaining the reason for the error.

Example of Endpoint Usage

Examples of how to use the endpoint across different programming languages.

  1. cURL

curl --request PATCH \
  --url https://api.fungies.io/v0/orders/{orderIdOrNumber}/cancel \
  --header 'Content-Type: application/json' \
  --header 'x-fngs-public-key: <api-key>' \
  --header 'x-fngs-secret-key: <api-key>' \
  --data '{}'
  1. Python

import requests

url = "https://api.fungies.io/v0/orders/{orderIdOrNumber}/cancel"

payload = {}
headers = {
    "x-fngs-public-key": "<api-key>",
    "x-fngs-secret-key": "<api-key>",
    "Content-Type": "application/json"
}

response = requests.request("PATCH", url, json=payload, headers=headers)

print(response.text)
  1. JavaScript

const options = {
  method: 'PATCH',
  headers: {
    'x-fngs-public-key': '<api-key>',
    'x-fngs-secret-key': '<api-key>',
    'Content-Type': 'application/json'
  },
  body: '{}'
};

fetch('https://api.fungies.io/v0/orders/{orderIdOrNumber}/cancel', options)
  .then(response => response.json())
  .then(response => console.log(response))
  .catch(err => console.error(err));
  1. PHP

<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.fungies.io/v0/orders/{orderIdOrNumber}/cancel",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "PATCH",
  CURLOPT_POSTFIELDS => "{}",
  CURLOPT_HTTPHEADER => [
    "Content-Type: application/json",
    "x-fngs-public-key: <api-key>",
    "x-fngs-secret-key: <api-key>"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
  1. Go

package main

import (
	"fmt"
	"strings"
	"net/http"
	"io/ioutil"
)

func main() {

	url := "https://api.fungies.io/v0/orders/{orderIdOrNumber}/cancel"

	payload := strings.NewReader("{}")

	req, _ := http.NewRequest("PATCH", url, payload)

	req.Header.Add("x-fngs-public-key", "<api-key>")
	req.Header.Add("x-fngs-secret-key", "<api-key>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := ioutil.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
  1. Java

HttpResponse<String> response = Unirest.patch("https://api.fungies.io/v0/orders/{orderIdOrNumber}/cancel")
  .header("x-fngs-public-key", "<api-key>")
  .header("x-fngs-secret-key", "<api-key>")
  .header("Content-Type", "application/json")
  .body("{}")
  .asString();

Example of a Successful Response (200)

200 OK – The list of orders is successfully retrieved.

{
  "status": "<string>",
  "data": {
    "order": {
      "object": "order",
      "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
      "number": "<string>",
      "status": "PENDING",
      "value": 0,
      "tax": 0,
      "fee": 0,
      "totalItems": 0,
      "country": null,
      "currency": null,
      "currencyDecimals": null,
      "createdAt": 4503599627370495,
      "userId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
      "user": null,
      "orderNumber": "<string>"
    }
  }
}

Example of Error Response (400)

400 Bad Request – Invalid query parameters.

{
  "status": "error",
  "error": {
    "message": "Sample error message"
  }
}

Last updated