Skip to content

Instantly share code, notes, and snippets.

@puuble
Last active February 17, 2023 00:45
Show Gist options
  • Save puuble/fe42a0f21d4605b601224118317e15fe to your computer and use it in GitHub Desktop.
Save puuble/fe42a0f21d4605b601224118317e15fe to your computer and use it in GitHub Desktop.
Posentegra Help - Order
<?php
/*
* Siparisler uzerinden islem yapmak icin PUT methoduyla ilgili URL tetiklenirken asagidaki sekilde gerekli fieldlari gonderebilirsiniz
* asagidaki ornekte trendyol uzerinde yapilacak islemlerin ornekleri bulunmaktadir.
*/
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => '/ty/order/{eventType}', // {eventType} yerine gelebilecek alanlar verify,pickup,prepare,cancel,complete
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS =>'{
"orderId": "pivot_id", // 212
"callbackURL": "islem sonucunu bildirmek icin gerekli URL" // https://example.com/order/cancel/212
}',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
<?php
$client = new Client();
$headers = [
'Content-Type' => 'application/json'
];
$body = '{
"orderId": "pivot_id",
"callbackURL": "islem sonucunu bildirmek icin gerekli URL"
}';
$request = new Request('PUT', '/ty/order/{eventType}', $headers, $body);
$res = $client->sendAsync($request)->wait();
echo $res->getBody();
@puuble
Copy link
Author

puuble commented Feb 17, 2023

CallbackURL zorunlu değildir.
Yapılan işlemler eğer network ile ilgili bir sıkıntı yoksa her zaman sonuç olumlu döner.
Bu nedenle islemin sonucunu size iletmemiz icin bir callbackURL belirleyebilir o URL ye otomatik olarak
islem sonucu webhook.php de anlatigim formatta doner.
Ornegin onaylama islemi yaptiginizda

event_type: verify
pivot_id: siparis id si

Boylelikle URL ye gelen bilgi ile siparisi cekebilir ve siparisten hangi restoran oldugunu bulabilir ve o restorani siparis hakkindaki bilgileri gosterebilirsiniz.
Eger callbackURL kullanmazsaniz Siparis listelerini veren endpointimiz uzerinden siparis durumunu takip edebilirsiniz.

URL YAPILARI

url yapıları provider alanında verilen slug ile belirlenir.

 { 
   "provider": {
        "slug": "getir",
     }, 
  }

### providerlarimiz

Yemek Sepeti : ys
Getir : getir
Migros : migros
Trendyol : ty

Ornekler:

ys/order/verify - Yemek sepeti onaylama
migros/order/cancel - Migros iptal
getir/order/pickup - yola cikarma

Event type:

  • verify siparis onaylar
  • cancel siparis iptal eder -> bu islemden once reasonId almaniz gerekiyor sebepler her provider icin degiskenlik gosteriyor.
  • prepare siparis hazirlandi
  • pickup Siparis Yola cikar
  • complete, Teslim edildi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment