Process order reference.

@param oxOrder  $oOrder
@param stdClass $oOrderReference
@throws Exception
513029
public function processOrderReference(oxOrder $oOrder, stdClass $oOrderReference)
    {
        $sOrderReferenceStatus = $oOrderReference
            ->OrderReferenceStatus
            ->State;

        //Do re-authorization if order was suspended and now it's opened
        if ($sOrderReferenceStatus === 'Open'
            && (string)$oOrder->getFieldData('oxtransstatus') === 'AMZ-Order-Suspended'
        ) {
            $this->authorize($oOrder);
        } else {
            $oOrder->assign(array('oxtransstatus' => 'AMZ-Order-'.$sOrderReferenceStatus));
            $oOrder->save();
        }
    }
1368325
public function setupOrderReference()
    {
        $orderTotal = new OffAmazonPaymentsService_Model_OrderTotal();
        $orderTotal->setCurrencyCode($this->_currencyCode);
        $orderTotal->setAmount($this->_orderTotalAmount);
        
        $setOrderReferenceDetailsRequest 
            = new OffAmazonPaymentsService_Model_SetOrderReferenceDetailsRequest();
        $setOrderReferenceDetailsRequest->setSellerId($this->_sellerId);
        $setOrderReferenceDetailsRequest
            ->setAmazonOrderReferenceId($this->_amazonOrderReferenceId);
        $setOrderReferenceDetailsRequest
            ->setOrderReferenceAttributes(
                new OffAmazonPaymentsService_Model_OrderReferenceAttributes()
            );
        $setOrderReferenceDetailsRequest
            ->getOrderReferenceAttributes()->setOrderTotal($orderTotal);
        
        return $this->_service->setOrderReferenceDetails(
            $setOrderReferenceDetailsRequest
        );
    }
667981
protected function SaveOrderIdAsLastCreatedOrderInSession($oOrder)
    {
        $_SESSION[self::SESSION_KEY_LAST_CREATED_ORDER_ID] = $oOrder->id;
        $myOrderHistory = $this->myOrderDetailHandlerFactory();
        $myOrderHistory->addOrderIdToMyList($oOrder->id, ('' !== $oOrder->fieldDataExtranetUserId) ? $oOrder->fieldDataExtranetUserId : null);
    }
739079
public function generateOrder($sortBy, $sortOrder, &$order)
    {
        if (! empty($sortBy)) {
            if (empty($sortOrder)) { // @codeCoverageIgnore
                $sortOrder = "ASC"; // @codeCoverageIgnore
            } // @codeCoverageIgnore

            $order = "$sortBy $sortOrder";
        }
    }
87808
public function ExecutePayment(TdbShopOrder &$oOrder, $sMessageConsumer = '')
    {
        $bPaymentOk = parent::ExecutePayment($oOrder);
        if ($bPaymentOk) {
            TdbShopPaymentHandler::SetExecutePaymentInterrupt(true);
            $bPaymentOk = $this->ExecuteIPaymentCall($oOrder);
        }

        return $bPaymentOk;
    }
75421
public function createOrderCouponsByCartCoupons(
        CartInterface $cart,
        OrderInterface $order
    ) {
        $cartCouponAmount = $cart->getCouponAmount();

        if ($cartCouponAmount instanceof MoneyInterface) {
            $order->setCouponAmount($cartCouponAmount);
        }

        /**
         * @var CouponInterface $coupons
         */
        $coupons = $this
            ->cartCouponManager
            ->getCoupons($cart);

        if (empty($coupons)) {
            return;
        }

        /**
         * Before applying Coupons to Order, we should remove old references
         * if exist.
         */
        $this
            ->orderCouponTruncator
            ->truncateOrderCoupons($order);

        /**
         * An event is dispatched for each convertible coupon.
         */
        foreach ($coupons as $coupon) {
            $this
                ->orderCouponEventDispatcher
                ->dispatchOrderCouponOnApplyEvent(
                    $order,
                    $coupon
                );
        }
    }
873571
public function loadOrderShippingMethod(OrderOnCreatedEvent $event)
    {
        $this
            ->orderShippingMethodLoader
            ->loadOrderShippingMethod(
                $event->getCart(),
                $event->getOrder()
            );
    }
1119423
protected function MarkOrderBasketAsProcessed($oOrderBasket)
    {
        $oOrderBasket->AllowEditByAll(true);
        $oOrderBasket->sqlData['processed'] = 1;
        $oOrderBasket->Save();
        $oOrderBasket->AllowEditByAll(false);
    }
1077648
public function getOrderLanguageId(oxOrder $oOrder)
    {
        //Send GetOrderReferenceDetails request to Amazon to get OrderLanguage string
        $oData = $this->getClient()->getOrderReferenceDetails($oOrder, array(), true);

        //If request did not return us the language string return the existing Order lang ID
        if (isset($oData->GetOrderReferenceDetailsResult->OrderReferenceDetails->OrderLanguage) === false) {
            return (int)$oOrder->getFieldData('oxlang');
        }

        //If we have a language string match it to the one in the language mapping array
        $sAmazonLanguageString = (string)$oData->GetOrderReferenceDetailsResult->OrderReferenceDetails->OrderLanguage;
        //Get OXID Language Id by Amazon Language string
        $iLangId = $this->getLangIdByAmazonLanguage($sAmazonLanguageString);

        return ($iLangId !== false) ? (int)$iLangId : (int)$oOrder->getFieldData('oxlang');
    }
793814
protected function _addOrderHistoryData( array $aData, oxUser $oUser )
    {
        /** @var oxList $oOrdersList */
        $oOrdersList = $oUser->getOrders( 10 );

        if ( empty( $oOrdersList ) or !$oOrdersList->count() ) {
            return $aData;
        }

        $sFieldPrefix = 'customer_history_%d_%s';
        $iItemNumber  = 1;

        foreach ( $oOrdersList as $oOrder ) {
            /** @var OxpsPaymorrowOxOrder|oxOrder $oOrder */

            $aData[sprintf( $sFieldPrefix, $iItemNumber, 'orderDate' )]     = $oOrder->getOrderDate();
            $aData[sprintf( $sFieldPrefix, $iItemNumber, 'totalAmount' )]   = $oOrder->getTotalOrderSum();
            $aData[sprintf( $sFieldPrefix, $iItemNumber, 'paymentMethod' )] = $oOrder->getPaymentMethodName();
            $aData[sprintf( $sFieldPrefix, $iItemNumber, 'orderStatus' )]   = $oOrder->getOrderStatus();

            $iItemNumber++;
        }

        return $aData;
    }
269461
public function authorize($oOrder = null, $aRequestParameters = array(), $blForceSync = false)
    {
        $sMode = $this->getConfig()->getConfigParam('sAmazonMode');
        $aRequestParameters['transaction_timeout'] =
            ($sMode === bestitAmazonPay4OxidClient::BASIC_FLOW || $blForceSync) ? 0 : 1440;

        $oData = $this->_callOrderRequest(
            'authorize',
            $oOrder,
            $aRequestParameters,
            array(
                'amazon_order_reference_id',
                'authorization_amount',
                'currency_code',
                'authorization_reference_id',
                'seller_authorization_note'
            ),
            $blProcessable
        );

        //Update Order info
        if ($blProcessable === true
            && isset($oData->AuthorizeResult->AuthorizationDetails->AuthorizationStatus->State)
        ) {
            $oDetails = $oData->AuthorizeResult->AuthorizationDetails;
            $oOrder->assign(array(
                'bestitamazonauthorizationid' => $oDetails->AmazonAuthorizationId,
                'oxtransstatus' => 'AMZ-Authorize-'.$oDetails->AuthorizationStatus->State
            ));
            $oOrder->save();
        }

        return $oData;
    }
108115
protected function _OxpsPaymorrowOxOrder_finalizeOrder_parent( oxBasket $oBasket, $oUser,
                                                                   $blRecalculatingOrder = false )
    {
        return parent::finalizeOrder( $oBasket, $oUser, $blRecalculatingOrder );
    }
346440
protected function getOrderList(TdbShopOrderList $oOrderList, $bCachingEnabled, IMapperCacheTriggerRestricted $oCacheTriggerManager)
    {
        $aOrderList = array();
        while ($oOrder = &$oOrderList->Next()) {
            if ($bCachingEnabled) {
                $oCacheTriggerManager->addTrigger($oOrder->table, $oOrder->id);
            }
            $aOrder = $this->getOrder($oOrder, $bCachingEnabled, $oCacheTriggerManager);
            $aOrder['bActive'] = $this->showDetail($oOrder);
            $aOrderList[] = $aOrder;
        }

        return $aOrderList;
    }
440050
protected function SendFailureSettlementMail(TdbShopOrder &$oOrder)
    {
        $bSendMail = false;
        $oMail = TdbDataMailProfile::GetProfile('payment_datatrans_error_settlement');
        if (!is_null($oMail)) {
            $sInfo = TGlobal::OutHTML(TGlobal::Translate('chameleon_system_shop.payment_data_trans.settlement_failure_mail_info',
                    array(
                        '%ordernumber%' => $oOrder->fieldOrdernumber,
                        '%ref%' => $this->GetRefNoParameter(false),
                    )
                ));
            $oMail->AddData('sInfo', $sInfo);
            $bSendMail = $oMail->SendUsingObjectView('emails', 'Customer');
        }

        return $bSendMail;
    }
160258
protected function GetPaymentPayload($oOrder, $dPaymentAmount = null)
    {
        $aPayload = parent::GetPaymentPayload($oOrder, $dPaymentAmount);
        $aPayload['AccNr'] = str_replace(' ', '', $this->aPaymentUserData['accountNr']);
        $aPayload['AccIBAN'] = str_replace(' ', '', $this->aPaymentUserData['bankNr']);
        $aPayload['AccBank'] = $this->aPaymentUserData['bankName'];
        $aPayload['AccOwner'] = $this->aPaymentUserData['accountOwner'];

        return $aPayload;
    }
901972
protected function ExecuteDataTransPaymentCall(TdbShopOrder &$oOrder)
    {
        $sXMLSettlement = $this->GetXMLSettlement();
        $ch = curl_init();
        $settlementurl = trim($this->GetTestLiveModeParameter('settlementurl'));
        curl_setopt($ch, CURLOPT_URL, $settlementurl);
        curl_setopt($ch, CURLOPT_VERBOSE, 1);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, 'xmlRequest='.$sXMLSettlement);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
        $sResponse = curl_exec($ch);
        $sCurlError = curl_error($ch);
        $bPaymentOk = $this->SettlementResponseSuccess($sResponse);
        if (!$bPaymentOk) {
            if (!empty($sCurlError)) {
                TTools::WriteLogEntrySimple('Payment DataTrans: curl failed to ['.$this->GetConfigParameter('settlementurl')."] using xml [{$sXMLSettlement}] with error: ".$sCurlError, 1, __FILE__, __LINE__);
            }
            $iFailure = $this->GetConfigParameter('failure_settlement');
            if ('1' === $iFailure) {
                if ($this->SendFailureSettlementMail($oOrder)) {
                    $bPaymentOk = true;
                } else {
                    TTools::WriteLogEntrySimple('Payment DataTrans: Es konnte keine Abbuchungsfehlere-mail versand werden', 1, __FILE__, __LINE__);
                }
            }
        }
        curl_close($ch);

        return $bPaymentOk;
    }
1181004
public function createOrderCouponsByCartCoupons(OrderOnCreatedEvent $event)
    {
        $this
            ->cartCouponToOrderTransformer
            ->createOrderCouponsByCartCoupons(
                $event->getCart(),
                $event->getOrder()
            );
    }