OrderID for subscription payments
@author René de Kat <renedekat@9lives-development.com>

@param string $orderId (maxlength 40)
437856
public function setSubscriptionOrderId($orderId)
    {
        if (strlen($orderId) > 40) {
            throw new InvalidArgumentException("Subscription order id cannot be longer than 40 characters");
        }
        if (preg_match('/[^a-zA-Z0-9_-]/', $orderId)) {
            throw new InvalidArgumentException("Subscription order id cannot contain special characters");
        }
        $this->parameters['sub_orderid'] = $orderId;
    }
1187111
static function archiveOrder( $orderID )
    {
        $db = eZDB::instance();
        $orderID =(int) $orderID;
        $db->query( "UPDATE ezorder SET is_archived='1' WHERE id='$orderID' " );
    }
1322670
public function saveTransactionRef($orderId, $transactionRef)
    {
        try {
            $orderId = \intval($orderId);

            if (null !== $order = $this->getOrder($orderId)) {
                $event = new OrderEvent($order);

                $event->setTransactionRef($transactionRef);

                $this->dispatch(TheliaEvents::ORDER_UPDATE_TRANSACTION_REF, $event);

                $this->getLog()->addInfo(
                    $this->getTranslator()->trans(
                        "Payment transaction %transaction_ref for order ref. %ref, ID %id has been successfully saved.",
                        [
                            '%transaction_ref' => $transactionRef,
                            '%ref' => $order->getRef(),
                            '%id' => $order->getId()
                        ]
                    )
                );
            }
        } catch (\Exception $ex) {
            $this->getLog()->addError(
                $this->getTranslator()->trans(
                    "Error occurred while saving payment transaction %transaction_ref for order ID %id.",
                    [
                        '%transaction_ref' => $transactionRef,
                        '%id' => $orderId
                    ]
                )
            );

            throw $ex;
        }
    }
760862
public function invoice($orderId, $invoiceKey)
    {
        /** @var OrderHandler $handler */
        $handler = $this->requestHandler();
        return $handler->invoice($orderId, $invoiceKey);
    }
425113
public function addOrderBy(string $orderBy, string $order)
    {
        if ($this->sql['orderby'] === null) {
            $this->sql['orderby'] = " ORDER BY ".$orderBy." ".$order." ";
        } else {
            $this->sql['orderby'] .= " , ".$orderBy." ".$order." ";
        }
    }
1199049
public function getOrder($orderId)
    {
        $resource = 'campaigns/' . $this->campaignId . '/orders/' . $orderId . '.json';

        $response = $this->sendRequest('GET', $this->getServiceUrl($resource));

        $decodedResponseBody = $this->getDecodedBody($response->getBody());

        $getOrderResponse = new GetOrderResponse($decodedResponseBody);
        return $getOrderResponse->getOrder();
    }
1139537
public function invoice($orderId, $invoiceKey)
    {
        $transformer = new InvoiceTransformer(self::STATUS_PAID, $invoiceKey);
        $body        = $transformer->output();

        /** @var \SkyHub\Api\Handler\Response\HandlerInterface $responseHandler */
        $responseHandler = $this->service()->post($this->baseUrlPath("$orderId/invoice"), $body);
        return $responseHandler;
    }
683151
public static function cancel($orderId)
    {
        $url = static::classUrl();
        $url = $url . '/' . $orderId . '/cancel';
        list($ret, $code) = parent::staticRequest('post', $url, []);

        return (object)[
            'code' => $code,
            'status' => $code === 200? 'success' : 'failed'
        ];
    }
1030488
public function trigger( $order_id ) {
		$order = wc_get_order( $order_id );
		if ( ! $order || ! $this->is_enabled() ) {
			return;
		}
		$reason = get_post_meta( $order->id, '_hametwoo_cancel_reason', true );
		if ( ! $reason ) {
			// Don't send with no reason.
			return;
		}
		$this->object = $order;
		$this->recipient = $this->object->billing_email;
		// Is html?
		foreach ( [
			'order_number' => $order->get_order_number(),
		    'order_date'   => date_i18n( get_option( 'date_format' ) ),
		] as $find => $result ) {
			$this->find[ $find ] = "{{$find}}";
			$this->replace[ $find ] = $result;
		}
		$this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
	}
311820
public Order add(long orderId, long size) {
    Order order = new Order(this, orderId, size);
    orders.add(order);
    return order;
  }
740688
public function delivery($orderId)
    {
        $transformer = new DeliveryTransformer(self::STATUS_COMPLETE);
        $body        = $transformer->output();

        /** @var \SkyHub\Api\Handler\Response\HandlerInterface $responseHandler */
        $responseHandler = $this->service()->post($this->baseUrlPath("$orderId/delivery"), $body);
        return $responseHandler;
    }
633510
public function load($orderId)
    {
        $this->setOrderId($orderId);

        $payments = array();
        $paymentsData = $this->getDbGateway()->getList($this->getOrderId());
        if (is_array($paymentsData) && count($paymentsData)) {
            $payments = array();
            foreach ($paymentsData as $data) {
                $payment = oxNew(\OxidEsales\PayPalModule\Model\OrderPayment::class);
                $payment->setData($data);
                $payments[] = $payment;
            }
        }

        $this->setArray($payments);
    }
465210
public function confirmPayment($orderId)
    {
        try {
            $orderId = \intval($orderId);

            if (null !== $order = $this->getOrder($orderId)) {
                $this->getLog()->addInfo(
                    $this->getTranslator()->trans(
                        "Processing confirmation of order ref. %ref, ID %id",
                        array('%ref' => $order->getRef(), '%id' => $order->getId())
                    )
                );

                $event = new OrderEvent($order);

                $event->setStatus(OrderStatusQuery::getPaidStatus()->getId());

                $this->dispatch(TheliaEvents::ORDER_UPDATE_STATUS, $event);

                $this->getLog()->addInfo(
                    $this->getTranslator()->trans(
                        "Order ref. %ref, ID %id has been successfully paid.",
                        array('%ref' => $order->getRef(), '%id' => $order->getId())
                    )
                );
            }
        } catch (\Exception $ex) {
            $this->getLog()->addError(
                $this->getTranslator()->trans(
                    "Error occured while processing order ref. %ref, ID %id: %err",
                    array(
                        '%err' => $ex->getMessage(),
                        '%ref' => !isset($order) ? "?" : $order->getRef(),
                        '%id' => !isset($order) ? "?" : $order->getId()
                    )
                )
            );

            throw $ex;
        }
    }
1188817
static function unArchiveOrder( $orderID )
    {
        $db = eZDB::instance();
        $orderID =(int) $orderID;
        $db->query( "UPDATE ezorder SET is_archived='0' WHERE id='$orderID' " );
    }
853230
public function update( $order_id, $id, $data ) {

		$this->set_request_args( array(
			'method' => 'PUT',
			'path'   => array( $order_id, 'refunds', $id ),
			'body'   => $data,
		) );

		return $this->do_request();
	}
1214422
public function setOrderData($orderData)
    {
        $this->id = $orderData->getIncrementId();
        $this->email = $orderData->getCustomerEmail();
        $this->quoteId = $orderData->getQuoteId();
        $this->storeName = $orderData->getStoreName();
        $this->purchaseDate = $orderData->getCreatedAt();
        $this->deliveryMethod = $orderData->getShippingDescription();
        $this->deliveryTotal = (float)number_format(
            $orderData->getShippingAmount(),
            2,
            '.',
            ''
        );
        $this->currency = $orderData->getStoreCurrencyCode();
        $payment = $orderData->getPayment();

        if ($payment) {
            if ($payment->getMethod()) {
                $methodInstance = $payment->getMethodInstance($payment->getMethod());
                if ($methodInstance) {
                    $this->payment = $methodInstance->getTitle();
                }
            }
        }

        $this->couponCode = $orderData->getCouponCode();

        /*
         * custom order attributes
         */
        $website = $this->_storeManager->getStore($orderData->getStore())->getWebsite();

        $customAttributes
            = $this->helper->getConfigSelectedCustomOrderAttributes(
                $website
            );

        if ($customAttributes) {
            $fields = $this->helper->getOrderTableDescription();
            $this->custom = [];
            foreach ($customAttributes as $customAttribute) {
                if (isset($fields[$customAttribute])) {
                    $field = $fields[$customAttribute];
                    $value = $this->_getCustomAttributeValue(
                        $field,
                        $orderData
                    );
                    if ($value) {
                        $this->_assignCustom($field, $value);
                    }
                }
            }
        }

        /*
         * Billing address.
         */
        $this->processBillingAddress($orderData);

        /*
         * Shipping address.
         */
        $this->processShippingAddress($orderData);

        $syncCustomOption = $this->helper->getWebsiteConfig(
            \Dotdigitalgroup\Email\Helper\Config::XML_PATH_CONNECTOR_SYNC_ORDER_PRODUCT_CUSTOM_OPTIONS,
            $website
        );

        /*
         * Order items.
         */
        $this->processOrderItems($orderData, $syncCustomOption);

        $this->orderSubtotal = (float)number_format(
            $orderData->getData('subtotal'),
            2,
            '.',
            ''
        );
        $this->discountAmount = (float)number_format(
            $orderData->getData('discount_amount'),
            2,
            '.',
            ''
        );
        $orderTotal = abs(
            $orderData->getData('grand_total') - $orderData->getTotalRefunded()
        );
        $this->orderTotal = (float)number_format($orderTotal, 2, '.', '');
        $this->orderStatus = $orderData->getStatus();

        unset($this->_storeManager);

        return $this;
    }
136485
protected function setOrder($order_id)
    {
        $this->data_order = array();

        if (is_numeric($order_id)) {

            $this->data_order = $this->order->get($order_id);

            if (empty($this->data_order)) {
                $this->outputHttpStatus(404);
            }

            $this->order_history->setViewed($this->data_order);
            $this->prepareOrder($this->data_order);
        }
    }