Skip to content

Commit

Permalink
Added 2nd webhook.
Browse files Browse the repository at this point in the history
  • Loading branch information
kFrolichs committed Apr 4, 2018
1 parent d2f761a commit 748b430
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions wuunderconnector/controllers/front/wuunderwebhook.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,18 @@ public function initContent()
{
parent::initContent();
$this->logger->logDebug("Webhook incoming");
$result = json_decode(file_get_contents('php://input'), true)['shipment'];
$result = json_decode(file_get_contents('php://input'), true);
$this->logger->logDebug("Webhook Data received");
if (isset($_REQUEST['orderid']) && isset($_REQUEST['wtoken'])) {
if ($this->updateLabelUrl($_REQUEST['orderid'], $_REQUEST['wtoken'], $result['id'], $result['label_url'], $result['track_and_trace_url'])) {
$history = new OrderHistory();
$history->id_order = (int)$_REQUEST['orderid'];
$history->changeIdOrderState(Configuration::get('postbookingstatus'), (int)$_REQUEST['orderid']);
$this->logger->logDebug(json_encode($result));
if($result['action'] === "shipment_booked") {
$result = $result['shipment'];
$this->logger->logDebug("1st webhook received");
if ($this->updateLabelUrl($_REQUEST['orderid'], $_REQUEST['wtoken'], $result['id'], $result['label_url'], $result['track_and_trace_url'])) {
$history = new OrderHistory();
$history->id_order = (int)$_REQUEST['orderid'];
$history->changeIdOrderState(Configuration::get('postbookingstatus'), (int)$_REQUEST['orderid']);
}
}
}
exit;
Expand All @@ -45,4 +50,4 @@ private function updateLabelUrl($order_id, $booking_token, $label_id, $label_url
return false;
}
}
}
}

0 comments on commit 748b430

Please sign in to comment.