Overridden for Paymorrow Services validation

@param $iSuccess

@return string
333360
protected function _getNextStep( $iSuccess )
    {
        /** @var OxpsPaymorrowResponseHandler $oPmResponseHandler */
        $oPmResponseHandler = oxRegistry::get( 'OxpsPaymorrowResponseHandler' );

        /**
         * If after validating confirmOrder against Paymorrow services there are errors,
         * return to order step and render error message
         */
        if ( $oPmResponseHandler->hasErrors() ) {
            $iErrorCode = $oPmResponseHandler->getErrorCode();

            /** @var OxpsPaymorrowErrorHandler $oPmErrorHandler */
            $oPmErrorHandler = oxNew( 'OxpsPaymorrowErrorHandler' );

            $oPmErrorHandler->redirectWithError( $iErrorCode );
        }

        /**
         * At this step assuming everything went fine
         * we need to delete SESSION variables created by Paymorrow
         * to avoid any incompatibilities if user has decided to
         * order again
         *
         * @doc: oxid_js_plugin.doc - 7.1 Controlling of customer’s browser session storage
         *
         * sess_challenge is deleted by `ThankYou` controller
         */
        $oSession = oxRegistry::getSession();
        $oSession->deleteVariable('pm_verify');
        $oSession->deleteVariable('pm_response');
        $oSession->deleteVariable('pm_responseINVOICE');
        $oSession->deleteVariable('pm_responseSDD');
        $oSession->deleteVariable('pm_order_transaction_id');
        $oSession->deleteVariable('pm_order_transaction_idINVOICE');
        $oSession->deleteVariable('pm_order_transaction_idSDD');

        // Set payment method error instead of shipping method error
        if ( $iSuccess == 4 ) {
            $iSuccess = 5;
        }

        return $this->_OxpsPaymorrowOrder_getNextStep_parent( $iSuccess );
    }
833250
protected function getValidVoucher($sShopVoucherCode)
    {
        $oValidVoucher = null;
        /** @var $oVoucher TdbShopVoucher */
        $oVoucher = TdbShopVoucher::GetNewInstance();

        if (strlen($sShopVoucherCode) >= 3) {
            if ($oVoucher->LoadFromFields(array('code' => $sShopVoucherCode, 'is_used_up' => '0'))) {
                $oValidVoucher = $oVoucher;
            }
        }

        return $oValidVoucher;
    }
314134
private function checkSubSpec()
    {
        $validation = $this->cache->validation($this->currentSubSpec);
        if (!is_null($validation)) {
            return $validation;
        }

        return $this->validateSubSpec();
    }
289566
protected function validatePaymentTransaction(PaymentTransaction $paymentTransaction)
    {
        $this->validateQueryConfig($paymentTransaction);

        $errorMessage   = '';
        $missedFields   = array();
        $invalidFields  = array();

        foreach (static::$requestFieldsDefinition as $fieldDescription)
        {
            list($fieldName, $propertyPath, $isFieldRequired, $validationRule) = $fieldDescription;

            $fieldValue = PropertyAccessor::getValue($paymentTransaction, $propertyPath, false);

            if (!empty($fieldValue))
            {
                try
                {
                    Validator::validateByRule($fieldValue, $validationRule);
                }
                catch (ValidationException $e)
                {
                    $invalidFields[] = "Field '{$fieldName}' from property path '{$propertyPath}', {$e->getMessage()}.";
                }
            }
            elseif ($isFieldRequired)
            {
                $missedFields[] = "Field '{$fieldName}' from property path '{$propertyPath}' missed or empty.";
            }
        }

        if (!empty($missedFields))
        {
            $errorMessage .= "Some required fields missed or empty in PaymentTransaction: \n" .
                             implode("\n", $missedFields) . "\n";
        }

        if (!empty($invalidFields))
        {
            $errorMessage .= "Some fields invalid in PaymentTransaction: \n" .
                             implode("\n", $invalidFields) . "\n";
        }

        if (!empty($errorMessage))
        {
            throw new ValidationException($errorMessage);
        }
    }
1252222
public function validatePayment()
    {
        // Remove payment methods initialization data from session of any is set
        $this->_unsetSessionInitData();

        $mReturn = $this->_OxpsPaymorrowPayment_validatePayment_parent();

        if ($this->_isPaymorrowPayment(oxRegistry::getConfig()->getRequestParameter('paymentid')) and
            $this->_isPaymentResponseSessionInvalid()
        ) {
            oxRegistry::getSession()->setVariable('payerror', 1);

            return null;
        }

        return $mReturn;
    }
1261128
protected function getStatus($response, $isRedirect)
    {
        if ($isRedirect) {
            return new Status('pending');
        }

        if (isset($response['PAYMENTINFO_0_PAYMENTSTATUS'])
            && $response['PAYMENTINFO_0_PAYMENTSTATUS'] == 'Pending') {
            return new Status('pending');
        }

        return new Status('paid');
    }
149271
private function getPutPostBodyDescriptionFiles($isCreating) {
        $description = '';
        $reflectionClass = new \ReflectionClass($this->getModel()->getModelsManager());
        $reflectionBehavior = $reflectionClass->getProperty('_behaviors');
        $reflectionBehavior->setAccessible(true);
        /** @var array $allBehaviors */
        $allBehaviors = $reflectionBehavior->getValue($this->getModel()->getModelsManager());
        /** @var BehaviorInterface[] $behaviors */
        $behaviors = $allBehaviors[strtolower(get_class($this->getModel()))];
        /** @var UploadableFile[] $optionalFiles */
        $optionalFiles = [];
        /** @var UploadableFile[] $requiredFiles */
        $requiredFiles = [];
        foreach($behaviors as $behavior) {
            if(is_subclass_of($behavior, 'Bullhorn\FastRest\Api\Services\Behavior\Upload\Base')) {
                /** @var UploadBehavior $behavior */
                foreach($behavior->getFiles() as $file) {
                    if($isCreating ? $file->isAllowedOnCreate() : $file->isAllowedOnUpdate()) {
                        if($isCreating ? $file->isRequiredOnCreate() : $file->isRequiredOnUpdate()) {
                            $requiredFiles[] = $file;
                        } else {
                            $optionalFiles[] = $file;
                        }
                    }
                }
            }
        }
        if(!empty($requiredFiles)) {
            $description .= "\n" . 'The following files are required:';
            foreach($requiredFiles as $file) {
                $description .= "\n" . '"' . $file->getName() . '" with the extensions: ' . implode(', ', $file->getAllowedExtensions());
            }
            $description .= "\n";
        }
        if(!empty($optionalFiles)) {
            $description .= "\n" . 'The following files are optional:';
            foreach($optionalFiles as $file) {
                $description .= "\n" . '"' . $file->getName() . '" with the extensions: ' . implode(', ', $file->getAllowedExtensions());
            }
            $description .= "\n";
        }
        return $description;
    }
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;
    }
252322
public function validatePayment(AnCommandContext $context)
    {
        $data = $context->data;
        $package = $this->getItem();

        if ($data->token) {

            $country = null;
            $identifier = 'com:subscriptions.controller.subscription';
            $method = $this->getService($identifier)->getGateway()->getExpressPaymentMethod($data->token, $country);
            $this->order->setPaymentMethod($method);
            $this->order->country = $country;

        } else {

            $url = route('option=com_subscriptions&view=signup&layout=payment&id='.$package->id);
            $error = false;

            //validate creditcard
            if (!$this->creditcard->is_valid()) {
                $error = true;
                $this->storeValue('credit_card_error', AnTranslator::_('COM-SUBSCRIPTIONS-CREDITCARD-INVALID'));
            }

            //validate contact
            $contact = $this->contact;

            if (! (
                  $contact->address &&
                  $contact->city &&
                  $contact->country &&
                  $contact->state &&
                  $contact->zip
            )) {
                $this->storeValue('address_error', AnTranslator::_('COM-SUBSCRIPTIONS-BILLING-INVALID'));
            }

            if ($error) {
                $context->response->setRedirect($url);
                return false;
            }

            $this->order->country = $contact->country;

            return true;
        }
    }
251045
private function getSuccessAndStatus($response, $code, $type, $isRedirect)
    {
        if (!in_array($code, [200, 201, 204])) {
            return [
                'success'       => false,
                'status'        => new Status('failed'),
                'reference'     => Arr::get($response, 'debug_id'),
                'authorization' => null,
            ];
        }

        $success = true;
        $status = null;
        $reference = null;
        $authorization = null;

        if ($type === 'sale') {
            $transaction = Arr::last($response['transactions']);
            $resource = Arr::last($transaction['related_resources']);

            // if there is no payment resource save general state
            $state = $resource ? $resource['sale']['state'] : $response['state'];

            $reference = $resource ? $resource['sale']['id'] : $response['id'];
            $authorization = $resource ? $response['id'] : null;

            $success = in_array($state, $this->successPaymentStatuses);
            $status = $this->getPaymentStatus($state);
        }

        if ($isRedirect) {
            $approvalUrl = null;
            foreach ($response['links'] as $link) {
                if ($link['rel'] === 'approval_url') {
                    $approvalUrl = rawurlencode($link['href']);
                    break;
                }
            }
            $authorization = "{$response['continue_url']}/?approval_url={$approvalUrl}&reference={$reference}";
        }

        return [
            'success'       => $success,
            'status'        => $status,
            'reference'     => $reference,
            'authorization' => $authorization,
        ];
    }
500244
public function isPaid()
    {
        $statuses = $this->config()->get("paid_statuses");

        if (!is_array($statuses)) {
            return $this->Status == $statuses;
        } else {
            return in_array($this->Status, $statuses);
        }
    }
697692
protected function NotifyPayloadIsValid($aParameter)
    {
        $bIsValid = true;

        $aMessage = array('msg' => '', 'line' => 0);
        // validate hash
        $sCalculatedHash = $this->BuildIncomingHash($aParameter);
        $sHash = (array_key_exists('hash', $aParameter)) ? $aParameter['hash'] : '';
        if (0 != strcmp($sHash, $sCalculatedHash)) {
            $aMessage = array('msg' => "sofortueberweisung-notify: calculated hash [{$sCalculatedHash}] does not match hash passed [{$sHash}] for order", 'line' => __LINE__);
            $bIsValid = false;
        }

        /** @var $oOrder TdbShopOrder */
        $oOrder = null;
        if ($bIsValid) {
            // order id exists?
            $sOrderId = (array_key_exists('user_variable_3', $aParameter)) ? $aParameter['user_variable_3'] : '';
            $oOrder = TdbShopOrder::GetNewInstance();
            if (false == $oOrder->Load($sOrderId)) {
                $aMessage = array('msg' => "sofortueberweisung-notify: order id passed [{$sOrderId}] was not found in database: ", 'line' => __LINE__);
                $bIsValid = false;
            }
        }

        if ($bIsValid) {
            // order amount matches?
            $dOrderAmount = (array_key_exists('amount', $aParameter)) ? $aParameter['amount'] : '';
            if (0 != strcmp($dOrderAmount, $oOrder->fieldValueTotal)) {
                $aMessage = array('msg' => "sofortueberweisung-notify: amount paid [{$dOrderAmount}] for order [{$oOrder->id}] does not match order value [{$oOrder->fieldValueTotal}]: ", 'line' => __LINE__);
                $bIsValid = false;
            }
        }

        if (false == $bIsValid) {
            TTools::WriteLogEntry($aMessage['msg'].' DATA: '.print_r($aParameter, true), 1, __FILE__, $aMessage['line']);
            $bIsValid = $aMessage['msg'];
        }

        return $bIsValid;
    }
838433
public function isPaymentCapture($idSalesOrder, $idSalesOrderItem)
    {
        $status = PayoneTransactionStatusConstants::TXACTION_CAPTURE;

        return $this->isPayment($idSalesOrder, $idSalesOrderItem, $status);
    }
1113345
public function getValidationFailureMessage()
    {
        $requestPayment = $this->getRequestOrderPayment();
        $orderPayment = $this->getOrderPayment();

        $currencyPayPal = $requestPayment->getCurrency();
        $pricePayPal = $requestPayment->getAmount();

        $currencyPayment = $orderPayment->getCurrency();
        $amountPayment = $orderPayment->getAmount();

        $lang = $this->getLang();
        $validationMessage = $lang->translateString('OEPAYPAL_PAYMENT_INFORMATION') . ': ' . $amountPayment . ' ' . $currencyPayment . '. ' . $lang->translateString('OEPAYPAL_INFORMATION') . ': ' . $pricePayPal . ' ' . $currencyPayPal . '.';

        return $validationMessage;
    }
1339692
public function validate($params, $context = null)
    {
        $validatePromotion = is_array($params) || is_object($params);

        if ($validatePromotion) {
            return $this->promotions->validate($params);
        }
        return $this->validateVoucher($params, $context);
    }
1160
public function validatePayment($oBasket)
    {
        $paymentId = $oBasket->getPaymentId();

        if (!$this->isValidPaymentId($paymentId) || !$this->isValidPayment($oBasket)) {
            return self::ORDER_STATE_INVALIDPAYMENT;
        }
    }
785113
public function getPayPalCheckoutService()
    {
        if ($this->payPalCheckoutService === null) {
            $this->payPalCheckoutService = oxNew(\OxidEsales\PayPalModule\Core\PayPalService::class);
        }

        return $this->payPalCheckoutService;
    }