Ship an order
@param string $purchaseOrderId
@param array $order
@return array
@throws \Exception
768435
public function ship($purchaseOrderId, $order)
    {
        if(!is_numeric($purchaseOrderId)){
            throw new \Exception("purchaseOrderId must be numeric",1448480750);
        }

        $schema = [
            '/orderShipment' => [
                'namespace' => 'ns3',
                'childNamespace' => 'ns3',
            ],
            '/orderShipment/orderLines' => [
                'sendItemsAs' => 'orderLine',
            ],
            '/orderShipment/orderLines/orderLine/orderLineStatuses' => [
                'sendItemsAs' => 'orderLineStatus',
            ],
            '@namespaces' => [
                'ns3' => 'http://walmart.com/mp/v3/orders'
            ],
        ];

        $a2x = new A2X($order, $schema);
        $xml = $a2x->asXml();

        return $this->shipOrder([
            'purchaseOrderId' => $purchaseOrderId,
            'order' => $xml,
        ]);
    }
1149839
protected function addDelivery(InvoiceInterface $invoice, OrderInterface $order)
    {
        /** @var InvoiceElementInterface $invoiceElement */
        $invoiceElement = $this->invoiceElementManager->create();

        $invoiceElement->setQuantity(1);
        $invoiceElement->setPrice($order->getDeliveryCost());
        $invoiceElement->setUnitPriceExcl($order->getDeliveryCost());
        $invoiceElement->setUnitPriceInc($order->getDeliveryCost());
        $invoiceElement->setTotal($order->getDeliveryCost());
        $invoiceElement->setVatRate(0);

        $invoiceElement->setDesignation($this->deliveryPool->getMethod($order->getDeliveryMethod())->getName());
        $invoiceElement->setDescription($this->deliveryPool->getMethod($order->getDeliveryMethod())->getName());

        $invoiceElement->setInvoice($invoice);
        $invoice->addInvoiceElement($invoiceElement);
    }
1026617
public function show(Order $order)
    {
        Shop::instance($order->shop_id);
        $paymentMethods = Shop::getPaymentMethods()->flatten()->mapWithKeys(function($method) {
            return [$method::getId() => $method::getName()];
        })->all();
        $orderStatuses = $this->orderstatus->all()->pluck('name', 'id')->toArray();

        return view('order::admin.orders.view', compact('order', 'paymentMethods', 'orderStatuses'));
    }
1037264
public function findByOrderId($orderId, $locale)
    {
        $result = array();
        $items = $this->getShippingRepository()->findByOrderId($orderId, $locale);
        foreach ($items as $item) {
            $result[] = $this->shippingFactory->createApiEntity($item, $locale);
        }
        return $result;
    }
669376
public function create($orderIncrementId, $itemsQty = null, $comment = null, $email = null, $includeComment = null)
    {
        return $this->__createAction('order_shipment.create', func_get_args());
    }
31374
public function shipmentException($orderId, $datetime, $observation)
    {
        $transformer = new ShipmentExceptionTransformer($orderId, $datetime, $observation);
        $body        = $transformer->output();

        /** @var \SkyHub\Api\Handler\Response\HandlerInterface $responseHandler */
        $responseHandler = $this->service()->post($this->baseUrlPath("$orderId/shipment_exception"), $body);
        return $responseHandler;
    }
1148044
public final function setOrderData(Order $order)
    {
        if (get_called_class() != self::class) {
            throw new \InvalidArgumentException("Method can be call only by OrderFinalized entity");
        }
        $this->id = $order->id;
        $this->setProperties($order);
    }
668040
public function PaymentOrderCancel($paymentOrderId, $amount, $currency)
    {
        $request = new Request();
        $request->setMethod('POST');

        foreach (array('paymentOrderId', 'amount', 'currency') as $param) {
            if (null == $$param) {
                throw new InvalidArgumentException($param);
            }
        }

        $params = array(
            'PaymentOrderId' => $paymentOrderId,
            'CancelAmount'   => $amount,
            'Currency'       => $currency
        );

        $request->setContent(json_encode($params));

        return $this->doRequest('PaymentOrder/Cancel', $request)->getContentJson();
    }
289804
public function thenByDesc($order)
    {
        $order = LambdaUtils::toSelectCallable($order);
        $this->orders[] = array("property" => $order, "direction" => self::ORDER_DESC);
        return $this;
    }
318162
private function getCurrentShippingMethodCostsCollection(OrderInterface $order) : Collection
    {
        return $this->methodProvider->getShippingMethodCosts($order->getShippingMethod(), new OrderContext($order));
    }
1371487
public static function create($order)
    {
        $data = OpenPayU_Util::buildJsonFromArray($order);

        if (empty($data)) {
            throw new OpenPayU_Exception('Empty message OrderCreateRequest');
        }

        try {
            $authType = self::getAuth();
        } catch (OpenPayU_Exception $e) {
            throw new OpenPayU_Exception($e->getMessage(), $e->getCode());
        }

        $pathUrl = OpenPayU_Configuration::getServiceUrl() . self::ORDER_SERVICE;

        $result = self::verifyResponse(OpenPayU_Http::doPost($pathUrl, $data, $authType), 'OrderCreateResponse');

        return $result;
    }
191618
public function onCallbackSuccess($order, $data = null)
    {
        $paymentId  = is_array($data) ? $data['paymentId'] : $data->paymentId;

        $payerId    = is_array($data) ? $data['PayerID'] : $data->PayerID;

        $this->statusCode = 'failed';

        $this->detail = sprintf('Payment failed. Ref: %s', $paymentId);

        // Begin paypal
        try {

            $this->setContext();

            $payment = Payment::get($paymentId, $this->apiContext);
            
            $execution = new PaymentExecution();

            $execution->setPayerId($payerId);

            $payment->execute($execution, $this->apiContext);

            $payment = Payment::get($paymentId, $this->apiContext);

            $this->statusCode = 'completed';

            $this->transactionId = $payment->id;

            $this->detail = 'Success';

        } catch (PayPalConnectionException $e) {

            $response = json_decode($e->getData());

            throw new GatewayException(
                sprintf(
                    '%s: %s',
                    $response->name,
                    isset($response->message) ? $response->message : 'Paypal payment Failed.'
                ),
                1001,
                $e
            );

        } catch (\Exception $e) {

            throw new GatewayException(
                $e->getMessage(),
                1000,
                $e
            );

        }
    }
25420
public function getOrderCompleted(Models\Order $order)
    {
        if (!$order->hasProducts()) {
            throw new \Exception('$order should have at least one product');
        }

        return $this->getTrackPayload(ActionTypes::ORDER_COMPLETED, [
            PayloadProperties::PROPERTIES => [
                [
                    PayloadProperties::ORDER_TOTAL_PRICE => $order->getOrderTotal(),
                    PayloadProperties::PRODUCTS => $order->toArray()
                ]
            ]
        ]);
    }
880919
public function shipment($orderId, array $items, $trackCode, $trackCarrier, $trackMethod, $trackUrl)
    {
        /** @var OrderHandler $handler */
        $handler = $this->requestHandler();
        return $handler->shipment($orderId, $items, $trackCode, $trackCarrier, $trackMethod, $trackUrl);
    }
588407
public function mark_as_ready_to_pickupAction(Order $order)
    {
        $order->markReadyForPickupFromHub();

        $message = \Swift_Message::newInstance()
            ->setSubject('Your order is ready to be picked up')
            ->setFrom(array('no-reply@harvestcloud.com' => 'Harvest Cloud'))
            ->setTo(array('tom@templestreetmedia.com' => 'Tom Haskins-Vaughan'))
            ->setBody($this->renderView(
                'HarvestCloudEmailBundle:Buyer:order_ready_to_pickup.txt.twig', array(
                    'order' => $order
            )))
        ;

        $this->get('mailer')->send($message);

        $em = $this->getDoctrine()->getEntityManager();
        $em->persist($order);
        $em->flush();

        return $this->redirect($this->generateUrl('Order_show', array(
            'id' => $order->getNumberForPath()
        )));
    }
208360
public function PaymentOrderDetailByMerchant($merchantOrderId, array $addElements = array())
    {
        $request = new Request();
        $request->setMethod('GET');

        if (null == $merchantOrderId) {
            throw new InvalidArgumentException('merchantOrderId');
        }

        $qs = array(
            'MerchantOrderId' => $merchantOrderId,
            'MerchantId'      => $this->options['merchantId']
        );

        if ($addElements) {
            $qs['AddElements'] = implode(',', $addElements);
        }

        return $this->doRequest('PaymentOrder/Detail', $request, $qs)->getContentJson();
    }
617171
protected function prepareOrderComponentsAccountOrder(array &$order)
    {
        $this->setItemOrderCartComponent($order, $this->price);
        $this->setItemOrderPriceRuleComponent($order, $this->price, $this->price_rule);
        $this->setItemOrderPaymentComponent($order, $this->price, $this->payment, $this->order);
        $this->setItemOrderShippingComponent($order, $this->price, $this->shipping, $this->order);

        ksort($order['data']['components']);
    }