From 26d45dd90b3fd6dc99c8e3a133f4e986d73f66c6 Mon Sep 17 00:00:00 2001 From: Franck Allimant Date: Fri, 11 Apr 2014 02:24:33 +0200 Subject: [PATCH] Added orderFailed() method --- .../Front/Controller/OrderController.php | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/local/modules/Front/Controller/OrderController.php b/local/modules/Front/Controller/OrderController.php index 5ac01d723..3b24a2ab4 100644 --- a/local/modules/Front/Controller/OrderController.php +++ b/local/modules/Front/Controller/OrderController.php @@ -234,6 +234,29 @@ class OrderController extends BaseFrontController $this->getParserContext()->set("placed_order_id", $placedOrder->getId()); } + public function orderFailed($order_id, $message) + { + /* check if the placed order matched the customer */ + $failedOrder = OrderQuery::create()->findPk( + $this->getRequest()->attributes->get('order_id') + ); + + if (null === $failedOrder) { + throw new TheliaProcessException("No failed order", TheliaProcessException::NO_PLACED_ORDER, $failedOrder); + } + + $customer = $this->getSecurityContext()->getCustomerUser(); + + if (null === $customer || $failedOrder->getCustomerId() !== $customer->getId()) { + throw new TheliaProcessException("Received failed order id does not belong to the current customer", TheliaProcessException::PLACED_ORDER_ID_BAD_CURRENT_CUSTOMER, $placedOrder); + } + + $this->getParserContext() + ->set("failed_order_id", $failedOrder->getId()) + ->set("failed_order_message", $message) + ; + } + protected function getOrderEvent() { $order = $this->getOrder($this->getRequest());