public function validatePayment()
    {
        $myConfig = \OxidEsales\Eshop\Core\Registry::getConfig();
        $oSession = $this->getSession();

        //#1308C - check user. Function is executed before render(), and oUser is not set!
        // Set it manually for use in methods getPaymentList(), getShippingSetList()...
        $oUser = $this->getUser();
        if (!$oUser) {
            $oSession->setVariable('payerror', 2);

            return;
        }

        if (!($sShipSetId = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter('sShipSet'))) {
            $sShipSetId = $oSession->getVariable('sShipSet');
        }
        if (!($sPaymentId = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter('paymentid'))) {
            $sPaymentId = $oSession->getVariable('paymentid');
        }
        if (!($aDynvalue = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter('dynvalue'))) {
            $aDynvalue = $oSession->getVariable('dynvalue');
        }

        // A. additional protection
        if (!$myConfig->getConfigParam('blOtherCountryOrder') && $sPaymentId == 'oxempty') {
            $sPaymentId = '';
        }

        //#1308C - check if we have paymentID, and it really exists
        if (!$sPaymentId) {
            $oSession->setVariable('payerror', 1);

            return;
        }

        if ($this->getDynDataFiltered() && $sPaymentId == 'oxidcreditcard') {
            $oSession->setVariable('payerror', 7);

            return;
        }

        $oBasket = $oSession->getBasket();
        $oBasket->setPayment(null);
        $oPayment = oxNew(\OxidEsales\Eshop\Application\Model\Payment::class);
        $oPayment->load($sPaymentId);

        // getting basket price for payment calculation
        $dBasketPrice = $oBasket->getPriceForPayment();

        $blOK = $oPayment->isValidPayment($aDynvalue, $myConfig->getShopId(), $oUser, $dBasketPrice, $sShipSetId);

        if ($blOK) {
            $oSession->setVariable('paymentid', $sPaymentId);
            $oSession->setVariable('dynvalue', $aDynvalue);
            $oBasket->setShipping($sShipSetId);
            $oSession->deleteVariable('_selected_paymentid');

            return 'order';
        } else {
            $oSession->setVariable('payerror', $oPayment->getPaymentErrorNumber());

            //#1308C - delete paymentid from session, and save selected it just for view
            $oSession->deleteVariable('paymentid');
            $oSession->setVariable('_selected_paymentid', $sPaymentId);

            return;
        }
    }