ext/bestitamazonpay4oxid_oxorder.php
protected function _callSyncAmazonAuthorize($oBasket, $sAmazonOrderReferenceId, $blOptimizedFlow)
    {
        $oContainer = $this->_getContainer();
        $oSession = $oContainer->getSession();
        $oUtils = $oContainer->getUtils();
        $oConfig = $oContainer->getConfig();

        //Authorize method call in Amazon
        $aParams = array(
            'amazon_order_reference_id' => $sAmazonOrderReferenceId,
            'authorization_amount' => $oBasket->getPrice()->getBruttoPrice(),
            'currency_code' => $oBasket->getBasketCurrency()->name,
            'authorization_reference_id' => $sAmazonOrderReferenceId.'_'
                .$oContainer->getUtilsDate()->getTime()
        );

        $oData = $oContainer->getClient()->authorize(null, $aParams, true);

        //Error handling
        if (!$oData || $oData->Error) {
            $oUtils->redirect($oConfig->getShopSecureHomeUrl() . 'cl=user&fnc=cleanAmazonPay', false);
            return false;
        }

        $oAuthorizationStatus = $oData->AuthorizeResult->AuthorizationDetails->AuthorizationStatus;

        //Response handling
        if ((string)$oAuthorizationStatus->State === 'Declined' || (string)$oAuthorizationStatus->State === 'Closed') {
            //Redirect to order page to re-select the payment
            if ($blOptimizedFlow === true && (string)$oAuthorizationStatus->ReasonCode === 'TransactionTimedOut') {
                return false;
            } elseif ((string)$oAuthorizationStatus->ReasonCode === 'InvalidPaymentMethod') {
                $oSession->setVariable('blAmazonSyncChangePayment', 1);
                $oUtils->redirect($oConfig->getShopSecureHomeUrl().'cl=order&action=changePayment', false);
                return false;
            }

            //Cancel ORO in amazon and redirect
            $aParams['amazon_order_reference_id'] = $oSession->getVariable('amazonOrderReferenceId');
            $oContainer->getClient()->cancelOrderReference(null, $aParams);
            $oUtils->redirect(
                $oConfig->getShopSecureHomeUrl()
                    .'cl=user&fnc=cleanAmazonPay&error=BESTITAMAZONPAY_PAYMENT_DECLINED_OR_REJECTED',
                false
            );
            return false;
        }

        //Open Response handling
        if ((string)$oAuthorizationStatus->State === 'Open') {
            //Set response into session for later saving into order info
            $oSession->setVariable(
                'sAmazonSyncResponseState',
                (string)$oAuthorizationStatus->State
            );
            $oSession->setVariable(
                'sAmazonSyncResponseAuthorizationId',
                (string)$oData->AuthorizeResult->AuthorizationDetails->AmazonAuthorizationId
            );
        } else {
            //Unexpected behaviour
            $oUtils->redirect(
                $oConfig->getShopSecureHomeUrl() . 'cl=user&fnc=cleanAmazonPay',
                false
            );

            return false;
        }

        return true;
    }
protected function _callSyncAmazonAuthorize($oBasket, $sAmazonOrderReferenceId, $blOptimizedFlow)
    {
        $oContainer = $this->_getContainer();
        $oSession = $oContainer->getSession();
        $oUtils = $oContainer->getUtils();
        $oConfig = $oContainer->getConfig();

        //Authorize method call in Amazon
        $aParams = array(
            'amazon_order_reference_id' => $sAmazonOrderReferenceId,
            'authorization_amount' => $oBasket->getPrice()->getBruttoPrice(),
            'currency_code' => $oBasket->getBasketCurrency()->name,
            'authorization_reference_id' => $sAmazonOrderReferenceId.'_'
                .$oContainer->getUtilsDate()->getTime()
        );

        $oData = $oContainer->getClient()->authorize(null, $aParams, true);

        //Error handling
        if (!$oData || $oData->Error) {
            $oUtils->redirect($oConfig->getShopSecureHomeUrl() . 'cl=user&fnc=cleanAmazonPay', false);
            return false;
        }

        $oAuthorizationStatus = $oData->AuthorizeResult->AuthorizationDetails->AuthorizationStatus;

        //Response handling
        if ((string)$oAuthorizationStatus->State === 'Declined' || (string)$oAuthorizationStatus->State === 'Closed') {
            //Redirect to order page to re-select the payment
            if ($blOptimizedFlow === true && (string)$oAuthorizationStatus->ReasonCode === 'TransactionTimedOut') {
                return false;
            } elseif ((string)$oAuthorizationStatus->ReasonCode === 'InvalidPaymentMethod') {
                $oSession->setVariable('blAmazonSyncChangePayment', 1);
                $oUtils->redirect($oConfig->getShopSecureHomeUrl().'cl=order&action=changePayment', false);
                return false;
            }

            //Cancel ORO in amazon and redirect
            $aParams['amazon_order_reference_id'] = $oSession->getVariable('amazonOrderReferenceId');
            $oContainer->getClient()->cancelOrderReference(null, $aParams);
            $oUtils->redirect(
                $oConfig->getShopSecureHomeUrl()
                    .'cl=user&fnc=cleanAmazonPay&error=BESTITAMAZONPAY_PAYMENT_DECLINED_OR_REJECTED',
                false
            );
            return false;
        }

        //Open Response handling
        if ((string)$oAuthorizationStatus->State === 'Open') {
            //Set response into session for later saving into order info
            $oSession->setVariable(
                'sAmazonSyncResponseState',
                (string)$oAuthorizationStatus->State
            );
            $oSession->setVariable(
                'sAmazonSyncResponseAuthorizationId',
                (string)$oData->AuthorizeResult->AuthorizationDetails->AmazonAuthorizationId
            );
        } else {
            //Unexpected behaviour
            $oUtils->redirect(
                $oConfig->getShopSecureHomeUrl() . 'cl=user&fnc=cleanAmazonPay',
                false
            );

            return false;
        }

        return true;
    }
protected function _callSyncAmazonAuthorize ( $ oBasket , $ sAmazonOrderReferenceId , $ blOptimizedFlow ) { $ oContainer = $ this -> _getContainer ( ) ; $ oSession = $ oContainer -> getSession ( ) ; $ oUtils = $ oContainer -> getUtils ( ) ; $ oConfig = $ oContainer -> getConfig ( ) ; //Authorize method call in Amazon $ aParams = array ( 'amazon_order_reference_id' => $ sAmazonOrderReferenceId , 'authorization_amount' => $ oBasket -> getPrice ( ) -> getBruttoPrice ( ) , 'currency_code' => $ oBasket -> getBasketCurrency ( ) -> name , 'authorization_reference_id' => $ sAmazonOrderReferenceId . '_' . $ oContainer -> getUtilsDate ( ) -> getTime ( ) ) ; $ oData = $ oContainer -> getClient ( ) -> authorize ( null , $ aParams , true ) ; //Error handling if ( ! $ oData || $ oData -> Error ) { $ oUtils -> redirect ( $ oConfig -> getShopSecureHomeUrl ( ) . 'cl=user&fnc=cleanAmazonPay' , false ) ; return false ; } $ oAuthorizationStatus = $ oData -> AuthorizeResult -> AuthorizationDetails -> AuthorizationStatus ; //Response handling if ( ( string ) $ oAuthorizationStatus -> State === 'Declined' || ( string ) $ oAuthorizationStatus -> State === 'Closed' ) { //Redirect to order page to re-select the payment if ( $ blOptimizedFlow === true && ( string ) $ oAuthorizationStatus -> ReasonCode === 'TransactionTimedOut' ) { return false ; } elseif ( ( string ) $ oAuthorizationStatus -> ReasonCode === 'InvalidPaymentMethod' ) { $ oSession -> setVariable ( 'blAmazonSyncChangePayment' , 1 ) ; $ oUtils -> redirect ( $ oConfig -> getShopSecureHomeUrl ( ) . 'cl=order&action=changePayment' , false ) ; return false ; } //Cancel ORO in amazon and redirect $ aParams [ 'amazon_order_reference_id' ] = $ oSession -> getVariable ( 'amazonOrderReferenceId' ) ; $ oContainer -> getClient ( ) -> cancelOrderReference ( null , $ aParams ) ; $ oUtils -> redirect ( $ oConfig -> getShopSecureHomeUrl ( ) . 'cl=user&fnc=cleanAmazonPay&error=BESTITAMAZONPAY_PAYMENT_DECLINED_OR_REJECTED' , false ) ; return false ; } //Open Response handling if ( ( string ) $ oAuthorizationStatus -> State === 'Open' ) { //Set response into session for later saving into order info $ oSession -> setVariable ( 'sAmazonSyncResponseState' , ( string ) $ oAuthorizationStatus -> State ) ; $ oSession -> setVariable ( 'sAmazonSyncResponseAuthorizationId' , ( string ) $ oData -> AuthorizeResult -> AuthorizationDetails -> AmazonAuthorizationId ) ; } else { //Unexpected behaviour $ oUtils -> redirect ( $ oConfig -> getShopSecureHomeUrl ( ) . 'cl=user&fnc=cleanAmazonPay' , false ) ; return false ; } return true ; }
Calls Authorize method in Amazon depending on settings

@param Basket $oBasket
@param string $sAmazonOrderReferenceId
@param bool   $blOptimizedFlow

@return bool
@throws Exception
Calls Authorize method in Amazon depending on settings