Kurye entegrasyonu için teknik dokümantasyon ve API referansı
Bu dokümantasyon, kurye firmalarının sipariş durumlarını güncellemeye yönelik webhook API'sini açıklar.
Kurye firmaları, siparişlerin teslim durumunu gerçek zamanlı olarak güncellemek için bu webhook endpoint'ini kullanabilir. Sistem, güncelleme sonrası restorana otomatik olarak socket ile bildirim gönderir.
POST /api/v1/webhook/courier/status-update
API çağrıları için restoran tarafından oluşturulan
API KeyContent-Type: application/json
x-api-key: {RESTAURANT_API_KEY}
| Header | Tip | Zorunlu | Açıklama |
|---|---|---|---|
| string | Evet | |
| string | Evet | Restoran tarafından sağlanan API anahtarı |
{
"restaurantId": "string",
"orderId": "string",
"status": 1 | 2
}
| Parametre | Tip | Zorunlu | Açıklama |
|---|---|---|---|
| string | Evet | MongoDB ObjectId formatında restoran ID |
| string | Evet | MongoDB ObjectId formatında sipariş ID |
| number | Evet | 1: Teslim edilecek, 2: Teslim edildi |
| Status | Açıklama | Sipariş Durumu |
|---|---|---|
| Kurye siparişi teslim etmek üzere yola çıktı | |
| Sipariş müşteriye teslim edildi | |
{
"success": true,
"message": "Sipariş durumu başarıyla güncellendi",
"data": {
"orderId": "507f1f77bcf86cd799439011",
"status": "teslim-edilecek",
"updatedAt": "2024-11-05T14:30:00.000Z"
}
}
{
"statusCode": 400,
"error": "Bad Request",
"message": "Header'da API key gereklidir"
}
{
"statusCode": 400,
"error": "Bad Request",
"message": "Geçersiz restoran ID"
}
{
"statusCode": 400,
"error": "Bad Request",
"message": "Geçersiz sipariş ID"
}
{
"statusCode": 400,
"error": "Bad Request",
"message": "Sipariş zaten teslim edildi veya iptal edildi"
}
{
"statusCode": 404,
"error": "Not Found",
"message": "Kurye entegrasyonu bulunamadı veya aktif değil"
}
{
"statusCode": 404,
"error": "Not Found",
"message": "Bu restoran için sipariş bulunamadı"
}
{
"statusCode": 500,
"error": "Internal Server Error",
"message": "Sipariş güncellenemedi"
}
curl -X POST https://backend.paketsefim.com/api/v1/webhook/courier/status-update \
-H "Content-Type: application/json" \
-H "x-api-key: YOUR_API_KEY_HERE" \
-d '{
"restaurantId": "507f1f77bcf86cd799439011",
"orderId": "507f1f77bcf86cd799439012",
"status": 1
}'
const response = await fetch('https://backend.paketsefim.com/api/v1/webhook/courier/status-update', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'x-api-key': 'YOUR_API_KEY_HERE',
},
body: JSON.stringify({
restaurantId: '507f1f77bcf86cd799439011',
orderId: '507f1f77bcf86cd799439012',
status: 1,
}),
})
const data = await response.json()
console.log(data)
import requests
url = 'https://backend.paketsefim.com/api/v1/webhook/courier/status-update'
headers = {
'Content-Type': 'application/json',
'x-api-key': 'YOUR_API_KEY_HERE'
}
payload = {
'restaurantId': '507f1f77bcf86cd799439011',
'orderId': '507f1f77bcf86cd799439012',
'status': 1
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
<?php
$url = 'https://backend.paketsefim.com/api/v1/webhook/courier/status-update';
$apiKey = 'YOUR_API_KEY_HERE';
$data = [
'restaurantId' => '507f1f77bcf86cd799439011',
'orderId' => '507f1f77bcf86cd799439012',
'status' => 1
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json',
'x-api-key: ' . $apiKey
]);
$response = curl_exec($ch);
curl_close($ch);
print_r(json_decode($response, true));
?>
Restorana paket servis siparişi geldiğinde veya manuel olarak kurye çağırdığında, kurye firmasının API endpoint'ine aşağıdaki formatta veri gönderilir:
{
"kuzeyOrderId": "507f1f77bcf86cd799439012",
"restaurantId": "507f1f77bcf86cd799439011",
"platform": "yemeksepeti",
"status": "hazirlanacak",
"orderType": "paket_servis",
"createdAt": "2024-11-07T10:30:00.000Z",
"paymentMethod": "card",
"originalPaymentMethod": "Kapıda Kredi/Banka Kartı",
"price": 125.5,
"hazirlanmaSuresiDk": 15,
"badges": ["Temassız Teslimat"],
"orderNote": "İnce hamur olsun lütfen",
"courierNote": "Kapı kodu: 1234",
"customer": {
"address": {
"district": "Kadıköy",
"city": "İstanbul",
"neighborhood": "Fenerbahçe",
"street": "Bağdat Caddesi",
"buildingNo": "123",
"floor": "4",
"apartmentNo": "8",
"detailedAddress": "Bağdat Caddesi No: 123, Kat: 4, Daire: 8, Fenerbahçe, Kadıköy, İstanbul",
"directions": "Kapı kodu: 1234",
"location": {
"latitude": 40.9857,
"longitude": 29.0347
}
},
"details": {
"name": "Ahmet Yılmaz",
"phone": "+905551234567"
}
}
}
| Alan | Tip | Açıklama |
|---|---|---|
| string | Sistemdeki sipariş ID (MongoDB ObjectId) |
| string | Restoranın ID'si (MongoDB ObjectId) |
| string | Siparişin geldiği platform: |
| string | Siparişin mevcut durumu: |
| string | Sipariş tipi: |
| string (ISO 8601) | Siparişin oluşturulma tarihi |
| string | Normalize edilmiş ödeme yöntemi: |
| string | Platform'dan gelen orjinal ödeme yöntemi bilgisi |
| number | Sipariş toplam tutarı (TL) |
| number | Tahmini hazırlanma süresi (dakika) |
| string[] | Siparişe ait badge label'ları (detaylar aşağıda) |
| string | null |
| string | null |
| object | Müşteri teslimat adresi bilgileri |
| object | Müşteri iletişim bilgileri |
badgesFormat:
"badges": ["Yeşili Koru", "Temassız Teslimat", "Kapıyı Çalma"]
Platform Bazlı Badge Label'ları:
saveGreencontactlessDeliveryringDoorBell: falsedoNotKnockdropOffAtDoorisEcoFriendlyBadge'ler platform verilerine göre otomatik olarak oluşturulur ve boş array (
[]Sipariş notları iki farklı türde gönderilir:
orderNotecourierNoteFormat:
{
"orderNote": "İnce hamur olsun lütfen",
"courierNote": "Kapı kodu: 1234, Yeşil kapı"
}
Her iki alan da opsiyoneldir ve not yoksa
nullstatus: 1status: 2API rate limiting uygulanmamaktadır, ancak makul kullanım beklenmektedir.
Webhook çağrıldığında, sipariş türüne göre otomatik platform güncellemesi yapılır:
phoneÖnemli Notlar:
Herhangi bir sorun veya soru için lütfen bizimle iletişime geçin:
| Versiyon | Tarih | Değişiklikler |
|---|---|---|
| 1.1.0 | 2024-11-05 | Platform entegrasyonu eklendi (GetirYemek, YemekSepeti, MigrosYemek, TrendyolYemek) |
| 1.0.0 | 2024-11-05 | İlk sürüm yayınlandı |
API Key, restoran tarafından kurye entegrasyonu kurulumu sırasında otomatik olarak oluşturulur.
Evet, ancak sipariş
teslim-edildicancelledSistem otomatik olarak 3 kez yeniden deneme yapar. Tüm denemeler başarısız olursa hata loglanır.
Hayır, kurye entegrasyonu için sadece iki durum tanımlanmıştır: Yola çıkış (1) ve Teslim (2).
Platform güncellemesi başarısız olsa bile webhook başarılı yanıt döner ve kendi veritabanımız güncellenir. Bu sayede kurye firması işlemini tamamlayabilir. Platform hataları loglanır ve teknik ekip tarafından incelenir.
Henüz entegrasyon başvurusu yapmadınız mı? Hemen başvurun ve KuzeyPOS platformuna entegre olun.
Başvuru Formunu Doldur