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

Sipariş Faturası

Bir siparişe harici fatura URL'si ekleyin veya kaldırın. Web API üzerinden dosya yükleme desteklenmez — yalnızca herkese açık bir URL.

Fatura URL'si ayarla

POST /api/v1/orders/{id}/invoice

ParametreTipZorunluAçıklama
urlstringEvetHerkese açık fatura URL'si (PDF/görsel)
namestringHayırGörünen ad

Faturayı kaldır

DELETE /api/v1/orders/{id}/invoice

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,
    ];
}

// Attach invoice URL
$result = apiRequest('POST', $baseUrl . '/orders/' . $orderId . '/invoice', $apiKey, [
    'url' => 'https://example.com/fatura.pdf',
    'name' => 'Fatura',
]);
print_r($result);

// Remove invoice
// $result = apiRequest('DELETE', $baseUrl . '/orders/' . $orderId . '/invoice', $apiKey);
cURL
# Attach invoice URL
curl -s -X POST \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://example.com/fatura.pdf","name":"Fatura"}' \
  "https://example.com/api/v1/orders/15/invoice"

# Remove invoice
curl -s -X DELETE \
  -H "X-API-Key: YOUR_API_KEY" \
  "https://example.com/api/v1/orders/15/invoice"
Örnek Yanıt (JSON)
{
  "success": true,
  "message": "Fatura kaydedildi",
  "content": {
    "id": 15,
    "orderNumber": "FS-20260617-0015",
    "invoice": {
      "type": "url",
      "url": "https://example.com/fatura.pdf",
      "name": "Fatura"
    }
  }
}