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);
        }
    }
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);
        }
    }
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 ) ; } }
Validates payment transaction before request constructing

@param       PaymentTransaction      $paymentTransaction        Payment transaction for validation
Validates payment transaction before request constructing