public function placeOrder(SS_HTTPRequest $request) { $eventbrite_event_header = $request->getHeader('X-Eventbrite-Event'); if (!$eventbrite_event_header) { return $this->httpError(403); } if ($eventbrite_event_header !== 'order.placed') { return $this->httpError(403); } if (!$this->isJson()) { return $this->httpError(403); } $json_request = $this->getJsonRequest(); if (!isset($json_request['config']) || !isset($json_request['api_url'])) { return $this->httpError(403); } $config = $json_request['config']; if (!isset($config['action']) || $config['action'] !== 'order.placed') { return $this->httpError(403); } $current_local_url = Controller::join_links(Director::absoluteBaseURL(), $request->getURL()); if (!isset($config['endpoint_url']) || $config['endpoint_url'] !== $current_local_url) { return $this->httpError(403); } try { $this->manager->registerEvent('ORDER_PLACED', $json_request['api_url']); } catch (Exception $ex) { SS_Log::log($ex->getMessage(), SS_Log::ERR); return $this->httpError(500); } return true; }