Sipariş Kayıtları
Var olan siparişleri okuyan, durumunu değiştiren ve kaldıran altı uç.
Genel Bakış
Sipariş, alışverişin kaydıdır; hizmet ise o alışverişten doğan şeydir. İkisi ayrı yaşar: siparişi silmek hizmeti öldürmez, hizmeti kapatmak siparişi değiştirmez.
Detay ucu bu ikiliği açıkça gösterir. Kalemler siparişin kendi satırlarıdır ve değişmez; hizmet listesi ise her okumada canlı gelir, durumları hizmet kaydından alınır.
Vergi ve indirim de aynı mantıkla saklanır: sipariş anındaki oranlar kaydın içinde donmuştur. Bugünkü ayarla yeniden hesaplamak geçmiş bir faturayı yanlış gösterir.
Referans
Siparişleri Listeleme
Siparişleri sayfalı olarak, müşteri ve fatura özetiyle döndürür.
curl 'https://panel.ornek.com/api/v1/admin/orders?status=waiting&limit=50' \
-H "Authorization: Bearer $API_KEY"const res = await fetch('https://panel.ornek.com/api/v1/admin/orders?status=waiting', {
headers: { Authorization: `Bearer ${apiKey}` },
});
const { data, meta } = await res.json();
const unpaid = data.filter((o) => o.invoice_status === 'unpaid');$ch = curl_init('https://panel.ornek.com/api/v1/admin/orders?status=waiting');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $apiKey],
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// Sipariste tutar VAR, kalemler YOK: kalem ve hizmet ancak detay ucunda gelir.
$rows = Api::Orders()->GetOrders([], ['status' => 'waiting'])['data'];
foreach ($rows as $o) $detail[$o['id']] = Api::Orders()->GetOrder(['id' => $o['id']])['data'];Sipariş Detayını Okuma
Siparişin vergisini, indirimlerini, kalemlerini ve doğurduğu hizmetleri döndürür.
curl 'https://panel.ornek.com/api/v1/admin/orders/92' \
-H "Authorization: Bearer $API_KEY"const res = await fetch(`https://panel.ornek.com/api/v1/admin/orders/${id}`, {
headers: { Authorization: `Bearer ${apiKey}` },
});
const { data } = await res.json();
const live = data.services.filter((s) => s.exists);$ch = curl_init('https://panel.ornek.com/api/v1/admin/orders/' . $id);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $apiKey],
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// Vergi ve indirim SIPARIS ANININ fotografidir; bugunku oranla yeniden hesaplamayin.
$o = Api::Orders()->GetOrder(['id' => $id])['data'];
$rateThen = $o['taxes']['rate'] ?? 0;Sipariş Zarfını Güncelleme
Siparişin notunu ve satış ortağı atamasını değiştirir.
curl -X PATCH 'https://panel.ornek.com/api/v1/admin/orders/92' \
-H "Authorization: Bearer $API_KEY" \
-H 'Content-Type: application/json' \
-d '{"notes":"Expedite provisioning","affiliate_id":5}'const res = await fetch(`https://panel.ornek.com/api/v1/admin/orders/${id}`, {
method: 'PATCH',
headers: {
Authorization: `Bearer ${apiKey}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ notes: 'Expedite provisioning' }),
});
const body = await res.json();$ch = curl_init('https://panel.ornek.com/api/v1/admin/orders/' . $id);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'PATCH',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode(['notes' => $note]),
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// Yalnizca not ve satis ortagi degisir; kalem, fiyat ve musteri bu uctan DUZENLENEMEZ.
Api::Orders()->UpdateOrder(['id' => $id, 'notes' => $note, 'affiliate_id' => $aff]);Sipariş Durumunu Değiştirme
Siparişin durumunu değiştirir ve hizmetlerine de yansıtır.
curl -X PUT 'https://panel.ornek.com/api/v1/admin/orders/92/status' \
-H "Authorization: Bearer $API_KEY" \
-H 'Content-Type: application/json' \
-d '{"status":"active","apply_on_module":false}'const res = await fetch(`https://panel.ornek.com/api/v1/admin/orders/${id}/status`, {
method: 'PUT',
headers: {
Authorization: `Bearer ${apiKey}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ status: 'active', apply_on_module: false }),
});
const { data } = await res.json();
if (data.services_updated) refreshServices();$ch = curl_init('https://panel.ornek.com/api/v1/admin/orders/' . $id . '/status');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode(['status' => 'active', 'apply_on_module' => false]),
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// apply_on_module SAGLAYICIDA gercek islem baslatir: etkin kurar, iptal kapatir. Once yanlis birak.
Api::Orders()->UpdateOrderStatus([
'id' => $id, 'status' => 'active', 'apply_on_module' => false,
]);Siparişi Silme
Sipariş kaydını siler; doğurduğu hizmetler yerinde kalır.
curl -X DELETE 'https://panel.ornek.com/api/v1/admin/orders/92' \
-H "Authorization: Bearer $API_KEY"const res = await fetch(`https://panel.ornek.com/api/v1/admin/orders/${id}`, {
method: 'DELETE',
headers: { Authorization: `Bearer ${apiKey}` },
});
const body = await res.json();$ch = curl_init('https://panel.ornek.com/api/v1/admin/orders/' . $id);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'DELETE',
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $apiKey],
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// Hizmetler SILINMEZ: siparis gider, hizmet kalir ve artik hangi siparisten geldigi izlenemez.
$o = Api::Orders()->GetOrder(['id' => $id])['data'];
foreach ($o['services'] as $s) if ($s['exists']) $orphans[] = $s['id'];
Api::Orders()->DeleteOrder(['id' => $id]);Siparişin Bir Hizmetini Kaldırma
Siparişin doğurduğu bir hizmeti kaldırır.
curl -X DELETE 'https://panel.ornek.com/api/v1/admin/orders/92/services/561' \
-H "Authorization: Bearer $API_KEY" \
-H 'Content-Type: application/json' \
-d '{"apply_on_module":false}'const res = await fetch(`https://panel.ornek.com/api/v1/admin/orders/${id}/services/${sid}`, {
method: 'DELETE',
headers: {
Authorization: `Bearer ${apiKey}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ apply_on_module: false }),
});
const body = await res.json();$ch = curl_init('https://panel.ornek.com/api/v1/admin/orders/' . $id . '/services/' . $sid);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'DELETE',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode(['apply_on_module' => false]),
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// Hizmet BU siparise ait degilse 404 gelir; numarayi detaydaki hizmet listesinden alin.
$o = Api::Orders()->GetOrder(['id' => $id])['data'];
$mine = array_column($o['services'], 'id');
if (in_array($sid, $mine, true))
Api::Orders()->DeleteOrderService(['id' => $id, 'sid' => $sid, 'apply_on_module' => false]);Tuzaklar
Sipariş kaydı gider, doğurduğu hizmetler yerinde kalır ve faturalanmaya devam eder. Geriye kalan tek bağ da kopar: hizmetin hangi siparişten geldiği artık izlenemez. Bir alışverişi tümüyle geri almak istiyorsanız önce hizmetleri kaldırın.
Durum değişiminde sağlayıcıya uygulama seçeneğini açmak sunucuda gerçek işlem başlatır: etkin kurulum yapar, iptal hesabı kapatır. Bir toplu düzeltmede bunu açık bırakmak müşteri sunucularını topluca etkiler. Önce kapalı deneyin, sonucu görün.
Detaydaki vergi oranı, ek vergiler ve kupon indirimi sipariş anında hesaplanmıştır ve kayıtta öyle durur. Bugünkü vergi ayarı değiştiyse iki rakam tutmaz; bu bir tutarsızlık değil, tarihsel doğruluktur. Raporda kaydın kendi oranını kullanın.
Güncelleme ucu yalnız notu ve satış ortağı atamasını yazar. Kalem, adet, fiyat, döngü ve müşteri bu uçtan değiştirilemez. Yanlış kurulmuş bir siparişin doğrusu onu düzeltmek değil, iptal edip yenisini kurmaktır.
Hizmet kaldırma ucu, hizmetin gerçekten o siparişe ait olduğunu denetler; başka bir siparişin hizmeti 404 alır. Bu bir güvenlik kapısıdır ve yanlış numarayla yanlış hizmeti silmeyi engeller. Numarayı detaydaki listeden alın.
Liste ucu her sipariş için yalnız özet verir: tutar, kalem sayısı ve müşteri. Kalemlerin kendisi, soruların yanıtları ve doğan hizmetler detay ucunda gelir. Bir liste ekranında kalem göstermek her satır için ayrı bir çağrı demektir.
İlgili Makaleler
Geri bildiriminiz için teşekkürler!
Yukarıda bulamadığınız her şey için destek ekibimiz her zaman yanınızda.