public function testCompareResponseRequestOrders() { $this->request->addOrder(["IdOrder" => "12345", "Marketplace" => "Amazon", "Status" => "Canceled"]); $this->request->addOrder(["IdOrder" => "12346", "Marketplace" => "eBay", "Status" => "Sent"]); $api = new UpdateOrders("foo"); $rawData = <<<XML <?xml version="1.0" encoding="UTF-8"?> <Result> <Request> <Date>2011-08-09T19:36:54+02:00</Date> <Call>UpdateOrders</Call> <Token>foo</Token> <Mode>Sandbox</Mode> <Version>2</Version> </Request> <Response> <Orders> <Order> <IdOrder>12345</IdOrder> <Marketplace>Amazon</Marketplace> <StatusUpdated>False</StatusUpdated> </Order> <Order> <IdOrder>12346</IdOrder> <Marketplace>eBay</Marketplace> <StatusUpdated>True</StatusUpdated> </Order> </Orders> </Response> </Result> XML; $response = new UpdateOrdersResponse($rawData); $api->setResponse($response)->setRequest($this->request); $this->assertTrue($api->compareResponseRequest()); }
public function processUpdateOrders(OrderEvent $event) { if ($event->getOrder()->getPaymentModuleId() == $this->shoppingFluxPaymentModuleId) { $status = $event->getStatus(); $allowedStatus = [$sentStatusId = OrderStatusQuery::getSentStatus()->getId(), OrderStatusQuery::getCancelledStatus()->getId()]; if (in_array($status, $allowedStatus)) { $order = $event->getOrder(); $mode = ShoppingFluxConfigQuery::getProd() ? UpdateOrders::REQUEST_MODE_PRODUCTION : UpdateOrders::REQUEST_MODE_SANDBOX; $api = new UpdateOrders(ShoppingFluxConfigQuery::getToken(), $mode); $request = new Request("UpdateOrders"); $request->addOrder(["IdOrder" => $order->getRef(), "Marketplace" => $order->getTransactionRef(), "Status" => $status === $sentStatusId ? "Shipped" : "Canceled"]); $response = $api->setRequest($request)->getResponse(); if ($response->isInError()) { $this->logger->error($response->getFormattedError()); } if (!$api->compareResponseRequest()) { $errorMessage = "Bad response from ShoppingFlux: " . $response->getGroup("UpdateOrders")->C14N(); $this->logger->error($errorMessage); } } } }