PATCH https://example.com/api/v1/orders/{id}

Sipariş Durumunu Güncelle

Sipariş durumunu ve/veya kargo takip alanlarını günceller. Şunlardan en az birini gönderin: status, cargoCompany, trackingNumber (snake_case takma adları da kabul edilir).

Geçerli Durum Değerleri

  • 1 — Ödeme bekliyor
  • 2 — Hazırlanıyor
  • 3 — Kargoda
  • 4 — Teslim edildi
  • 5 — İptal edildi

Gövde Parametreleri

ParametreTipZorunluAçıklama
statusintegerHayır*Yeni durum (1–5)
cargoCompanystringHayır*Kargo firması adı
trackingNumberstringHayır*Takip numarası
PHP
<?php

$baseUrl = 'https://example.com/api/v1';
$apiKey  = 'YOUR_API_KEY';
$orderId = 15;

function apiRequest(string $method, string $url, string $apiKey, ?array $data = null): array
{
    $ch = curl_init();
    $headers = [
        'X-API-Key: ' . trim($apiKey),
        'Accept: application/json',
    ];
    if ($data !== null) {
        $headers[] = 'Content-Type: application/json';
    }
    curl_setopt_array($ch, [
        CURLOPT_URL => $url,
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_CUSTOMREQUEST => $method,
        CURLOPT_HTTPHEADER => $headers,
        CURLOPT_SSL_VERIFYPEER => true,
    ]);
    if ($data !== null) {
        curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data, JSON_UNESCAPED_UNICODE));
    }
    $response = curl_exec($ch);
    $httpCode = (int) curl_getinfo($ch, CURLINFO_HTTP_CODE);
    $error = curl_error($ch);
    curl_close($ch);
    $decoded = json_decode((string) $response, true);
    return [
        'http_code' => $httpCode,
        'curl_error' => $error,
        'response' => is_array($decoded) ? $decoded : $response,
    ];
}

$payload = [
    'status' => 3,
    'cargoCompany' => 'Yurtiçi Kargo',
    'trackingNumber' => 'YT123456789',
];

$result = apiRequest('PATCH', $baseUrl . '/orders/' . (int) $orderId, $apiKey, $payload);
print_r($result);
cURL
curl -s -X PATCH \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d '{
    "status": 3,
    "cargoCompany": "Yurtiçi Kargo",
    "trackingNumber": "YT123456789"
  }' \
  "https://example.com/api/v1/orders/15"
Örnek Yanıt (JSON)
{
  "success": true,
  "message": "Sipariş güncellendi",
  "content": {
    "id": 15,
    "orderNumber": "FS-20260617-0015",
    "statusCode": 3,
    "status": "Shipped",
    "statusLabel": "Kargoda",
    "cargoCompany": "Yurtiçi Kargo",
    "trackingNumber": "YT123456789"
  }
}