Yükseltme ve Düşürme
Bir hizmetin ürününü değiştiren, farkı faturalayan ve değişimi sonuna kadar takip eden dokuz uç.
Genel Bakış
Bir müşteri ürününü değiştirdiğinde iki iş birden olur: para hesabı ve sunucudaki değişim. Bu dokuz uç ikisini de yürütür — önce hangi ürünlere geçilebileceğini ve farkı gösterir, sonra bir kayıt açar ve o kaydı sonuna kadar takip eder.
Değişim anında olmaz. Kayıt açıldığında yanıttaki flow alanı nasıl ilerleyeceğini söyler: ödeme bekleniyorsa fatura ödenene kadar durur, dönem sonuna bırakıldıysa o güne kadar bekler, işleme alındıysa arka plan görevi yürütür.
Referans
Seçenekleri Getirme
Hizmetin geçebileceği ürünleri, her biri için fiyat ve farkla birlikte döndürür.
up yükseltme, down düşürme. Varsayılan up.curl -X POST 'https://panel.ornek.com/api/v1/admin/services/529/upgrade-options' \
-H "Authorization: Bearer $API_KEY" \
-H 'Content-Type: application/json' \
-d '{"grade":"up"}'const res = await fetch('https://panel.ornek.com/api/v1/admin/services/529/upgrade-options', {
method: 'POST',
headers: {
Authorization: `Bearer ${apiKey}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ grade: 'up' }),
});
const body = await res.json();$ch = curl_init('https://panel.ornek.com/api/v1/admin/services/529/upgrade-options');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode(['grade' => 'up']),
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// Fiyat kimligi BURADAN gelir; katalogdaki fiyat kimligini varsaymayin.
$options = Api::Services()->GetUpgradeOptions(['id' => 529, 'grade' => 'up'])['data'];
$target = $options[0];
$price = $target['prices'][0];
Api::Services()->CreateUpdowngrade([
'id' => 529,
'product_id' => $target['id'],
'price_id' => $price['price_id'],
]);{
"data": [
{
"id": 16,
"title": "Pro SSD 2",
"type": "hosting",
"module": "cpanel",
"category": "Hosting",
"prices": [
{
"price_id": 12722,
"period": "month",
"period_time": 1,
"cycle": "monthly",
"amount": 185.82,
"difference": 185.82,
"tax_amount": 37.16,
"payable": 222.99,
"currency": 840
}
]
}
]
}Değişimi Oluşturma
Yükseltme ya da düşürme kaydı açar. Nasıl ilerleyeceğine gönderdiğiniz ayarlar karar verir.
up ya da down. Varsayılan up.none fatura yok, unpaid ödenmemiş fatura, paid ödenmiş sayılan fatura.none ya da credit müşteri bakiyesine.invoice_unpaid ödeme bekleniyor, scheduled dönem sonuna bırakıldı, queued işleme alındı.recreate döner. Bu yanıtta kayıt açılmamıştır.gate:service.upgrade kancası işlemi veto etti.curl -X POST 'https://panel.ornek.com/api/v1/admin/services/529/updowngrade' \
-H "Authorization: Bearer $API_KEY" \
-H 'Content-Type: application/json' \
-d '{"product_id":16,"price_id":12722,"type":"up","invoice_generation":"unpaid","notification":true}'const res = await fetch('https://panel.ornek.com/api/v1/admin/services/529/updowngrade', {
method: 'POST',
headers: {
Authorization: `Bearer ${apiKey}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
product_id: 16,
price_id: 12722,
type: 'up',
invoice_generation: 'unpaid',
notification: true,
}),
});
const body = await res.json();$ch = curl_init('https://panel.ornek.com/api/v1/admin/services/529/updowngrade');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'product_id' => 16,
'price_id' => 12722,
'type' => 'up',
'invoice_generation' => 'unpaid',
]),
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);$response = Api::Services()->CreateUpdowngrade([
'id' => 529,
'product_id' => 16,
'price_id' => 12722,
]);
// Uyari donduyse KAYIT ACILMAMISTIR: onaylayip istegi TEKRAR gonderin.
if (($response['data']['warning'] ?? '') === 'recreate') {
Api::Services()->CreateUpdowngrade([
'id' => 529,
'product_id' => 16,
'price_id' => 12722,
'confirm_recreate' => true,
]);
}{
"data": {
"flow": "invoice_unpaid",
"updowngrade_id": 75,
"invoice_id": 1222
}
}{
"data": {
"warning": "recreate",
"warning_key": "updown-recreate-warning"
}
}Kayıtları Listeleme
Açılmış yükseltme ve düşürme kayıtlarını döndürür.
up ya da down.up yükseltme, down düşürme.waiting, pending, inprocess, completed ya da cancelled.curl -G 'https://panel.ornek.com/api/v1/admin/services/updowngrades' \
-H "Authorization: Bearer $API_KEY" \
-d status=waitingconst url = new URL('https://panel.ornek.com/api/v1/admin/services/updowngrades');
url.searchParams.set('status', 'waiting');
const res = await fetch(url, { headers: { Authorization: `Bearer ${apiKey}` } });
const body = await res.json();$url = 'https://panel.ornek.com/api/v1/admin/services/updowngrades?' . http_build_query(['status' => 'waiting']);
$ch = curl_init($url);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $apiKey],
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);$response = Api::Services()->GetUpdowngrades([], ['status' => 'waiting']);Kayıt Detayı
Tek bir değişim kaydını döndürür. Şema liste öğesiyle aynıdır.
up yükseltme, down düşürme.waiting, pending, inprocess, completed ya da cancelled.curl 'https://panel.ornek.com/api/v1/admin/services/updowngrades/74' \
-H "Authorization: Bearer $API_KEY"const res = await fetch('https://panel.ornek.com/api/v1/admin/services/updowngrades/74', {
headers: { Authorization: `Bearer ${apiKey}` },
});
const body = await res.json();$ch = curl_init('https://panel.ornek.com/api/v1/admin/services/updowngrades/74');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $apiKey],
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);$record = Api::Services()->GetUpdowngrade(['uid' => 74])['data'];
// Takilan bir kaydin sebebi status_msg alanindadir.
$why = $record['status_msg'];Kaydı Onaylama
Varsa iadeyi işler ve kaydı işleme alır. Değişimi arka plan görevi yürütür.
curl -X POST 'https://panel.ornek.com/api/v1/admin/services/updowngrades/74/approve' \
-H "Authorization: Bearer $API_KEY"const res = await fetch('https://panel.ornek.com/api/v1/admin/services/updowngrades/74/approve', {
method: 'POST',
headers: { Authorization: `Bearer ${apiKey}` },
});
const body = await res.json();$ch = curl_init('https://panel.ornek.com/api/v1/admin/services/updowngrades/74/approve');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $apiKey],
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// Onay iadeyi bir KEZ isler; ayni kaydi tekrar onaylamak ikinci iade uretmez.
$response = Api::Services()->ApproveUpdowngrade(['uid' => 74]);Kaydı Yeniden Deneme
Takılmış bir kaydı yeniden işleme alır.
curl -X POST 'https://panel.ornek.com/api/v1/admin/services/updowngrades/74/retry' \
-H "Authorization: Bearer $API_KEY"const res = await fetch('https://panel.ornek.com/api/v1/admin/services/updowngrades/74/retry', {
method: 'POST',
headers: { Authorization: `Bearer ${apiKey}` },
});
const body = await res.json();$ch = curl_init('https://panel.ornek.com/api/v1/admin/services/updowngrades/74/retry');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $apiKey],
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// Yeniden denemeden once sebebe bakin: ayni kosul surerse ayni yerde takilir.
$record = Api::Services()->GetUpdowngrade(['uid' => 74])['data'];
if ($record['status_msg'] === '') {
Api::Services()->RetryUpdowngrade(['uid' => 74]);
}Kaydı Tamamlama
Modülü olmayan bir değişimi elle sonlandırır.
curl -X POST 'https://panel.ornek.com/api/v1/admin/services/updowngrades/74/complete' \
-H "Authorization: Bearer $API_KEY"const res = await fetch('https://panel.ornek.com/api/v1/admin/services/updowngrades/74/complete', {
method: 'POST',
headers: { Authorization: `Bearer ${apiKey}` },
});
const body = await res.json();$ch = curl_init('https://panel.ornek.com/api/v1/admin/services/updowngrades/74/complete');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $apiKey],
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// Modulu olan bir hizmette bunu cagirmayin: degisimi arka plan gorevi yurutur.
$response = Api::Services()->CompleteUpdowngrade(['uid' => 74]);Kaydı Silme
Kaydı siler, bağlı ödenmemiş faturayı iptal eder ve bekleyen işleri durdurur.
curl -X DELETE 'https://panel.ornek.com/api/v1/admin/services/updowngrades/74' \
-H "Authorization: Bearer $API_KEY"const res = await fetch('https://panel.ornek.com/api/v1/admin/services/updowngrades/74', {
method: 'DELETE',
headers: { Authorization: `Bearer ${apiKey}` },
});
const body = await res.json();$ch = curl_init('https://panel.ornek.com/api/v1/admin/services/updowngrades/74');
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);// Tamamlanmis bir kaydi silmek degisimi GERI ALMAZ: hizmet yeni urunde kalir.
$response = Api::Services()->DeleteUpdowngrade(['uid' => 74]);Planlı Düşürmeyi İptal Etme
Dönem sonuna bırakılmış bir düşürmeyi hizmete uygulanmadan geri alır.
curl -X POST 'https://panel.ornek.com/api/v1/admin/services/529/cancel-scheduled-downgrade' \
-H "Authorization: Bearer $API_KEY"const res = await fetch('https://panel.ornek.com/api/v1/admin/services/529/cancel-scheduled-downgrade', {
method: 'POST',
headers: { Authorization: `Bearer ${apiKey}` },
});
const body = await res.json();$ch = curl_init('https://panel.ornek.com/api/v1/admin/services/529/cancel-scheduled-downgrade');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $apiKey],
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// Adres HIZMET kimligini alir, kayit kimligini degil: bekleyen plan hizmetten bulunur.
$response = Api::Services()->CancelScheduledDowngrade(['id' => 529]);Tuzaklar
Değişim modülün hesabı yeniden kurmasını gerektiriyorsa ilk istek 200 ve bir uyarı döndürür, ama hiçbir kayıt açmaz. İşlemin gerçekleşmesi için onayı ekleyip isteği yeniden göndermeniz gerekir. Yanıtta updowngrade_id yoksa hiçbir şey olmamıştır.
Değişim oluştururken gönderilen fiyat kimliği, seçenek ucundan dönen listedeki kimliktir. Katalogdaki fiyatı doğrudan kullanmak yanlış dönem ya da yanlış para birimiyle işlem açar; listede dönen tutarlar zaten vergi ve döviz hesaplanmış hâldedir.
Silme ucu bekleyen bir kaydı iptal etmek için vardır: ödenmemiş faturayı da iptal eder ve bekleyen işleri durdurur. Tamamlanmış bir kaydı silmek hizmeti eski ürüne döndürmez; geri almak için ters yönde yeni bir değişim açmanız gerekir.
Takılan bir kaydın sebebi status_msg alanında yazar. Aynı koşul sürerken yeniden denemek kaydı aynı yerde takar; önce sebebi giderin. Modülü olmayan bir değişim zaten kendiliğinden ilerlemez, onun için tamamlama ucu vardır.
Diğer sekiz uç kayıt kimliğiyle çalışırken planlı düşürme iptali hizmet kimliğini alır: bekleyen plan hizmetten bulunur. Kayıt kimliğini vermek 404 döndürür.
İ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.