Amazon Capture method

@param oxOrder $oOrder             OXID Order object
@param array   $aRequestParameters Custom parameters to send

@return stdClass
@throws Exception
764878
public function capture($oOrder = null, $aRequestParameters = array())
    {
        $oData = $this->_callOrderRequest(
            'capture',
            $oOrder,
            $aRequestParameters,
            array(
                'amazon_authorization_id',
                'capture_amount',
                'currency_code',
                'capture_reference_id',
                'seller_capture_note'
            ),
            $blProcessable
        );

        //Update Order info
        if ($blProcessable === true && isset($oData->CaptureResult->CaptureDetails)) {
            $this->setCaptureState($oOrder, $oData->CaptureResult->CaptureDetails);
            $this->closeOrderReference($oOrder, array(), false);
        }

        return $oData;
    }
308606
protected function getPaymentInformation(TdbShopOrder $oOrder, IMapperCacheTriggerRestricted $oCacheTriggerManager, $bCachingEnabled)
    {
        $aPaymentInformation = array();

        $oPaymentMethodParameterList = &$oOrder->GetFieldShopOrderPaymentMethodParameterList();
        $oPaymentMethodParameterList->GoToStart();
        while ($oPaymentParameter = &$oPaymentMethodParameterList->Next()) {
            if ($bCachingEnabled) {
                $oCacheTriggerManager->addTrigger($oPaymentParameter->table, $oPaymentParameter->id);
            }
            $aPaymentInformation[] = array(
                'sName' => $oPaymentParameter->fieldName,
                'sValue' => $oPaymentParameter->fieldValue,
            );
        }

        return $aPaymentInformation;
    }
613123
public function createApiLogsByOrderIdAndRequest($idOrder, $request)
    {
        $query = $this->getFactory()->createPaymentPayoneApiLogQuery()
            ->useSpyPaymentPayoneQuery()
            ->filterByFkSalesOrder($idOrder)
            ->endUse()
            ->filterByRequest($request)
            ->orderByCreatedAt(Criteria::DESC) //TODO: Index?
            ->orderByIdPaymentPayoneApiLog(Criteria::DESC);

        return $query;
    }
753072
public function executePayment($dAmount, &$oOrder)
    {
        $this->_iLastErrorNo = null;
        $this->_sLastError = null;

        if (!$this->_isActive()) {
            return true; // fake yes
        }

        // proceed with no payment
        // used for other countries
        if (@$this->_oPaymentInfo->oxuserpayments__oxpaymentsid->value == 'oxempty') {
            return true;
        }

        return false;
    }
879713
public function isCaptureError(OrderTransfer $orderTransfer)
    {
        return $this->hasApiLogStatus(
            $orderTransfer,
            PayoneApiConstants::REQUEST_TYPE_CAPTURE,
            PayoneApiConstants::RESPONSE_TYPE_ERROR
        );
    }
843133
protected function getArticleList(TdbShopOrder $oOrder, IMapperCacheTriggerRestricted $oCacheTriggerManager, $bCachingEnabled)
    {
        $aArticleList = array();
        $oOrderItemList = &$oOrder->GetFieldShopOrderItemList();
        while ($oOrderItem = &$oOrderItemList->Next()) {
            if ($bCachingEnabled) {
                $oCacheTriggerManager->addTrigger($oOrderItem->table, $oOrderItem->id);
            }
            $aArticleList[] = $this->getArticle($oOrderItem, $oCacheTriggerManager, $bCachingEnabled);
        }

        return $aArticleList;
    }
108115
protected function _OxpsPaymorrowOxOrder_finalizeOrder_parent( oxBasket $oBasket, $oUser,
                                                                   $blRecalculatingOrder = false )
    {
        return parent::finalizeOrder( $oBasket, $oUser, $blRecalculatingOrder );
    }
267759
protected function HandleNotifyMessageForPaymentState($sPaymentState, $aParameter, $oOrder)
    {
        if (!$oOrder->fieldOrderIsPaid) {
            if ('9' === $sPaymentState) {
                $oOrder->SetStatusPaid(true);
                $oOrder->SetStatusCanceled(false);
                $this->HandleNotifyOrderOnChange($oOrder, true, true, true);
                TTools::WriteLogEntry('OGONE: handle notify message order ('.$aParameter['ORDERID'].') was activated and paid by notify (Status 9 paid)', 1, __FILE__, __LINE__);
            } elseif ('5' === $sPaymentState) {
                if ($oOrder->fieldCanceled || !$oOrder->fieldSystemOrderSaveCompleted) {
                    $oOrder->SetStatusCanceled(false);
                    $oOrder->SetStatusPaid(false);
                    TTools::WriteLogEntry('OGONE: handle notify message order ('.$aParameter['ORDERID'].') was activated by notify and set to not paid (Status 5 reservation)', 1, __FILE__, __LINE__);
                    $this->HandleNotifyOrderOnChange($oOrder, false, !$oOrder->fieldSystemOrderSaveCompleted, true);
                }
            } else {
                if ('6' === $sPaymentState || '1' === $sPaymentState || '2' === $sPaymentState || '0' === $sPaymentState) {
                    $oOrder->SetStatusCanceled(true);
                    $oOrder->SetStatusPaid(false);
                    $this->HandleNotifyOrderOnChange($oOrder, false, false, true);
                    TTools::WriteLogEntry('OGONE: handle notify message order ('.$aParameter['ORDERID'].') was canceled and set to not paid by notify (Status 0,1,2,6)', 1, __FILE__, __LINE__);
                }
            }
        } else {
            TTools::WriteLogEntry('OGONE: handle notify message order ('.$aParameter['ORDERID'].') was already paid nothing to do)', 1, __FILE__, __LINE__);
        }
    }
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');
    }
907856
protected function _savePaymorrowUserPaymentData( oxOrder $oOrder, $oPmResponseHandler )
    {
        $aPmResponse = $oPmResponseHandler->getResponse();

        $oUserPaymentId = $oOrder->oxorder__oxpaymentid->value;

        /** @var OxpsPaymorrowOxUserPayment|oxUserPayment $oUserPayment */
        $oUserPayment = oxNew( 'oxuserpayment' );
        $oUserPayment->load( $oUserPaymentId );

        $sPmBankName = $aPmResponse[self::PAYMORROW_RESPONSE_BANK_NAME];
        $sPmIbanCode = $aPmResponse[self::PAYMORROW_RESPONSE_SDD_IBAN];
        $sPmBicCode  = $aPmResponse[self::PAYMORROW_RESPONSE_SDD_BIC];
        $sPmOrderId  = $aPmResponse[self::PAYMORROW_RESPONSE_ORDER_ID];

        $oUserPayment->setPaymorrowBankName( $sPmBankName );
        $oUserPayment->setPaymorrowIBAN( $sPmIbanCode );
        $oUserPayment->setPaymorrowBIC( $sPmBicCode );
        $oUserPayment->setPaymorrowOrderId( $sPmOrderId );

        return $oUserPayment->save();
    }
861713
public function run(array $orderItems, SpySalesOrder $orderEntity, ReadOnlyArrayObject $data)
    {
        $captureTransfer = new PayoneCaptureTransfer();

        $paymentTransfer = new PayonePaymentTransfer();
        $paymentTransfer->setFkSalesOrder($orderEntity->getSpyPaymentPayones()->getFirst()->getFkSalesOrder());
        $captureTransfer->setPayment($paymentTransfer);
        $captureTransfer->setAmount($this->getOrderTransfer($orderEntity)->getTotals()->getGrandTotal());
        $captureTransfer->setOrder($this->getOrderTransfer($orderEntity));

        $this->getFacade()->capturePayment($captureTransfer);

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

        return $bPaymentOk;
    }
670927
public function capturePayment(PayoneCaptureTransfer $captureTransfer): CaptureResponseTransfer
    {
        $paymentEntity = $this->getPaymentEntity($captureTransfer->getPayment()->getFkSalesOrder());
        $paymentMethodMapper = $this->getPaymentMethodMapper($paymentEntity);

        $requestContainer = $paymentMethodMapper->mapPaymentToCapture($paymentEntity);
        $requestContainer = $this->prepareOrderItems($captureTransfer->getOrder(), $requestContainer);
        $requestContainer = $this->prepareOrderShipment($captureTransfer->getOrder(), $requestContainer);
        $requestContainer = $this->prepareOrderDiscount($captureTransfer->getOrder(), $requestContainer);

        if (!empty($captureTransfer->getSettleaccount())) {
            $businnessContainer = new BusinessContainer();
            $businnessContainer->setSettleAccount($captureTransfer->getSettleaccount());
            $requestContainer->setBusiness($businnessContainer);
        }

        $this->setStandardParameter($requestContainer);

        $apiLogEntity = $this->initializeApiLog($paymentEntity, $requestContainer);

        $rawResponse = $this->executionAdapter->sendRequest($requestContainer);
        $responseContainer = new CaptureResponseContainer($rawResponse);

        $this->updateApiLogAfterCapture($apiLogEntity, $responseContainer);

        $responseMapper = new CaptureResponseMapper();
        $responseTransfer = $responseMapper->getCaptureResponseTransfer($responseContainer);

        return $responseTransfer;
    }
29720
public function ExecutePayment(TdbShopOrder &$oOrder, $sMessageConsumer = '')
    {
        $bPaymentOk = parent::ExecutePayment($oOrder);
        if ($bPaymentOk) {
            if ($oOrder->fieldValueTotal * 100 == $this->sAuthorisedAmount) {
                $bPaymentOk = $this->ExecuteDataTransPaymentCall($oOrder);
            } else {
                $oMsgManager = TCMSMessageManager::GetInstance();
                $oMsgManager->AddMessage($sMessageConsumer, 'ERROR_PAYMENT_DATA_TRANS_ORDER_REQUEST_AMOUNT_CHANGE');
                $bPaymentOk = false;
            }
        }

        return $bPaymentOk;
    }
833919
public function retrieveOrder($requestParams)
    {
        $requiredParams = array("id");
        return $this->client->request($requestParams, $this->_mainTransactionEndpoint . "/" . self::ORDER, "get", $requiredParams, $options = NULL);
    }
1132379
protected function _parseRequestParametersForSave($aReqParams)
    {
        // checkbox handling
        if (!isset($aReqParams['oxcategories__oxactive'])) {
            $aReqParams['oxcategories__oxactive'] = 0;
        }
        if (!isset($aReqParams['oxcategories__oxhidden'])) {
            $aReqParams['oxcategories__oxhidden'] = 0;
        }
        if (!isset($aReqParams['oxcategories__oxdefsortmode'])) {
            $aReqParams['oxcategories__oxdefsortmode'] = 0;
        }

        // null values
        if ($aReqParams['oxcategories__oxvat'] === '') {
            $aReqParams['oxcategories__oxvat'] = null;
        }

        if ($this->getEditObjectId() == self::NEW_CATEGORY_ID) {
            //#550A - if new category is made then is must be default activ
            //#4051: Impossible to create inactive category
            //$aReqParams['oxcategories__oxactive'] = 1;
            $aReqParams['oxcategories__oxid'] = null;
        }

        if (isset($aReqParams["oxcategories__oxlongdesc"])) {
            $aReqParams["oxcategories__oxlongdesc"] = $this->_processLongDesc($aReqParams["oxcategories__oxlongdesc"]);
        }

        if (empty($aReqParams['oxcategories__oxpricefrom'])) {
            $aReqParams['oxcategories__oxpricefrom'] = 0;
        }
        if (empty($aReqParams['oxcategories__oxpriceto'])) {
            $aReqParams['oxcategories__oxpriceto'] = 0;
        }

        return $aReqParams;
    }
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;
    }