Get Cancel Reasons
curl --request GET \
--url https://www.xn--dkkango-n2a.com/api/integrations/orders/cancel-reasons \
--header 'Access-Token: <api-key>'import requests
url = "https://www.xn--dkkango-n2a.com/api/integrations/orders/cancel-reasons"
headers = {"Access-Token": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'Access-Token': '<api-key>'}};
fetch('https://www.xn--dkkango-n2a.com/api/integrations/orders/cancel-reasons', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://www.xn--dkkango-n2a.com/api/integrations/orders/cancel-reasons",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Access-Token: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://www.xn--dkkango-n2a.com/api/integrations/orders/cancel-reasons"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Access-Token", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://www.xn--dkkango-n2a.com/api/integrations/orders/cancel-reasons")
.header("Access-Token", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://www.xn--dkkango-n2a.com/api/integrations/orders/cancel-reasons")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Access-Token"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"status": true,
"data": [
{
"id": 123,
"reason": "<string>"
}
]
}Orders
Get Cancel Reasons
Retrieve list of order cancellation reasons
GET
/
orders
/
cancel-reasons
Get Cancel Reasons
curl --request GET \
--url https://www.xn--dkkango-n2a.com/api/integrations/orders/cancel-reasons \
--header 'Access-Token: <api-key>'import requests
url = "https://www.xn--dkkango-n2a.com/api/integrations/orders/cancel-reasons"
headers = {"Access-Token": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'Access-Token': '<api-key>'}};
fetch('https://www.xn--dkkango-n2a.com/api/integrations/orders/cancel-reasons', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://www.xn--dkkango-n2a.com/api/integrations/orders/cancel-reasons",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Access-Token: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://www.xn--dkkango-n2a.com/api/integrations/orders/cancel-reasons"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Access-Token", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://www.xn--dkkango-n2a.com/api/integrations/orders/cancel-reasons")
.header("Access-Token", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://www.xn--dkkango-n2a.com/api/integrations/orders/cancel-reasons")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Access-Token"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"status": true,
"data": [
{
"id": 123,
"reason": "<string>"
}
]
}Overview
Returns the list of available cancellation reasons that can be used when canceling orders.Headers
string
required
Your API access token
Response
boolean
true if successfularray
Examples
curl -X GET https://www.xn--dkkango-n2a.com/api/integrations/orders/cancel-reasons \
-H 'Access-Token: your-access-token'
const response = await fetch(
'https://www.xn--dkkango-n2a.com/api/integrations/orders/cancel-reasons',
{
headers: {
'Access-Token': 'your-access-token'
}
}
);
const data = await response.json();
console.log('Cancel reasons:', data.data);
import requests
response = requests.get(
'https://www.xn--dkkango-n2a.com/api/integrations/orders/cancel-reasons',
headers={'Access-Token': 'your-access-token'}
)
data = response.json()
print('Cancel reasons:', data['data'])
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://www.xn--dkkango-n2a.com/api/integrations/orders/cancel-reasons');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Access-Token: your-access-token'
));
$response = curl_exec($ch);
curl_close($ch);
$data = json_decode($response, true);
print_r($data['data']);
?>
Success Response (200)
{
"status": true,
"data": [
{
"id": 1,
"reason": "Ürün tükendi"
},
{
"id": 2,
"reason": "Adres bulunamıyor"
},
{
"id": 3,
"reason": "Yoğunluk nedeniyle"
},
{
"id": 4,
"reason": "Müşteri iptal etti"
},
{
"id": 5,
"reason": "Teknik sorun"
},
{
"id": 6,
"reason": "Çok uzak teslimat adresi"
},
{
"id": 7,
"reason": "Ödeme problemi"
},
{
"id": 8,
"reason": "Diğer"
}
]
}
Error Response (401)
{
"status": false,
"error": "yetkisiz erişim"
}
Cancel Reasons Reference
| ID | Reason (Turkish) | English Translation | When to Use |
|---|---|---|---|
| 1 | Ürün tükendi | Product out of stock | Ingredient unavailable |
| 2 | Adres bulunamıyor | Address not found | Invalid/unclear address |
| 3 | Yoğunluk nedeniyle | Due to congestion | Restaurant too busy |
| 4 | Müşteri iptal etti | Customer canceled | Customer requested |
| 5 | Teknik sorun | Technical issue | System/equipment failure |
| 6 | Çok uzak teslimat adresi | Delivery address too far | Outside service area |
| 7 | Ödeme problemi | Payment problem | Payment verification failed |
| 8 | Diğer | Other | Any other reason |
Use Cases
Build Cancellation UI
Build Cancellation UI
Display reasons in dropdown menu for staff.
async function buildCancelDialog() {
const reasons = await getCancelReasons();
const dropdown = reasons.map(r => `
<option value="${r.id}">${r.reason}</option>
`).join('');
return `
<select id="cancelReason">
${dropdown}
</select>
`;
}
Initialize POS
Initialize POS
Cache reasons when POS starts.
async function initializePOS() {
const reasons = await getCancelReasons();
// Store in local cache
localStorage.setItem('cancelReasons',
JSON.stringify(reasons));
console.log('Cancel reasons cached');
}
Validate Reason ID
Validate Reason ID
Ensure valid reason before canceling.
function validateCancelReason(reasonId) {
const reasons = getCachedReasons();
const validIds = reasons.map(r => r.id);
if (!validIds.includes(reasonId)) {
throw new Error(`Invalid reason_id: ${reasonId}`);
}
return true;
}
Reason Lookup
Reason Lookup
Get reason text by ID.
function getReasonText(reasonId) {
const reasons = getCachedReasons();
const reason = reasons.find(r => r.id === reasonId);
return reason ? reason.reason : 'Unknown';
}
// Usage
console.log(getReasonText(3)); // "Yoğunluk nedeniyle"
Integration Example
class CancelOrderDialog {
async show(order) {
// 1. Fetch reasons
const reasons = await this.getCancelReasons();
// 2. Show dialog with reasons
const selectedReasonId = await this.showDialog(order, reasons);
if (selectedReasonId) {
// 3. Validate
this.validateReason(selectedReasonId, reasons);
// 4. Cancel order
await this.cancelOrder(order.payment_key, selectedReasonId);
// 5. Log cancellation
await this.logCancellation({
orderId: order.id,
reasonId: selectedReasonId,
reasonText: this.getReasonText(selectedReasonId, reasons),
timestamp: new Date(),
user: currentUser.id
});
// 6. Notify
showSuccessMessage('Order canceled successfully');
}
}
async showDialog(order, reasons) {
return new Promise((resolve) => {
const dialog = createDialog({
title: `Cancel Order ${order.id}?`,
content: `
<p>Select cancellation reason:</p>
<select id="reason-select">
${reasons.map(r =>
`<option value="${r.id}">${r.reason}</option>`
).join('')}
</select>
`,
buttons: [
{
text: 'Cancel Order',
onClick: () => {
const reasonId = document.getElementById('reason-select').value;
resolve(parseInt(reasonId));
}
},
{
text: 'Keep Order',
onClick: () => resolve(null)
}
]
});
dialog.show();
});
}
}
Caching Strategy
Cancel reasons rarely change. Cache them locally to improve performance.
class CancelReasonsCache {
constructor() {
this.reasons = null;
this.lastFetch = null;
this.cacheDuration = 24 * 60 * 60 * 1000; // 24 hours
}
async getReasons() {
const now = Date.now();
// Return cached if recent
if (this.reasons && (now - this.lastFetch) < this.cacheDuration) {
return this.reasons;
}
// Fetch fresh
const response = await fetch('/orders/cancel-reasons');
const data = await response.json();
this.reasons = data.data;
this.lastFetch = now;
return this.reasons;
}
invalidate() {
this.reasons = null;
this.lastFetch = null;
}
getById(id) {
return this.reasons?.find(r => r.id === id);
}
getText(id) {
return this.getById(id)?.reason || 'Unknown';
}
}
// Usage
const reasonsCache = new CancelReasonsCache();
// Get all reasons
const reasons = await reasonsCache.getReasons();
// Get specific reason text
const reason = reasonsCache.getText(3); // "Yoğunluk nedeniyle"
Best Practices
- Always Fetch First
- Cache Locally
- Validate Before Cancel
// ✅ Good: Fetch reasons before showing dialog
async function cancelOrder(order) {
const reasons = await getCancelReasons();
const reasonId = await showCancelDialog(order, reasons);
await cancelOrder(order.payment_key, reasonId);
}
// ✅ Good: Cache for performance
const cachedReasons = await reasonsCache.getReasons();
// Use cached data
showCancelDialog(order, cachedReasons);
// ✅ Good: Validate reason ID
function validateAndCancel(order, reasonId) {
if (reasonId < 1 || reasonId > 8) {
throw new Error('Invalid reason_id');
}
return cancelOrder(order.payment_key, reasonId);
}
Related Endpoints
Cancel Order
Use these reasons to cancel orders
Get Variables
Another variables endpoint
⌘I