public function setUp()
 {
     $this->webservice = new UpdateOrders();
     $this->request = new Request("UpdateOrders");
     $this->webservice->setRequest($this->request);
 }
Beispiel #2
0
 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);
             }
         }
     }
 }