Файловый менеджер - Редактировать - /var/www/html/Validators.zip
Ðазад
PK ! �3��� � AccessConfigValidator.phpnu �[��� <?php /* * Created by tpay.com. * Date: 13.06.2017 * Time: 12:51 */ namespace Omnipay\Tpay\_class_tpay\Validators; use Omnipay\Tpay\_class_tpay\Utilities\TException; use Omnipay\Tpay\_class_tpay\Validators\VariableTypes\StringType; trait AccessConfigValidator { /** * FieldsConfigValidator card verification code * * @param string $cardCode * * @throws TException */ public static function validateCardCode($cardCode) { if (!is_string($cardCode) || strlen($cardCode) === 0 || strlen($cardCode) > 40) { throw new TException('Invalid card code'); } } /** * FieldsConfigValidator card hash algorithm * @param string $hashAlg * @throws TException */ public static function validateCardHashAlg($hashAlg) { if (!in_array($hashAlg, array('sha1', 'sha256', 'sha512', 'ripemd160', 'ripemd320', 'md5'))) { throw new TException('Invalid hash algorithm'); } } /** * FieldsConfigValidator merchant Id * * @param int $merchantId * * @throws TException */ public function validateMerchantId($merchantId) { if (!is_int($merchantId) || $merchantId <= 0) { throw new TException('Invalid merchant ID'); } } public function isNotEmptyString($string, $name) { (new StringType())->validateType($string, $name); $this->validateMinLength($string, 'minlength_1', $name); } } PK ! �� � PaymentTypesInterface.phpnu �[��� <?php /* * Created by tpay.com. * Date: 19.06.2017 * Time: 11:09 */ namespace Omnipay\Tpay\_class_tpay\Validators; interface PaymentTypesInterface { public function getRequestFields(); public function getResponseFields(); } PK ! ���m� � ResponseFieldsValidator.phpnu �[��� <?php /* * Created by tpay.com. * Date: 20.06.2017 * Time: 17:49 */ namespace Omnipay\Tpay\_class_tpay\Validators; use Omnipay\Tpay\_class_tpay\Utilities\TException; use Omnipay\Tpay\_class_tpay\Utilities\Util; use Omnipay\Tpay\Dictionaries\FieldsConfigDictionary; trait ResponseFieldsValidator { /** * Check all variables required in response * Parse variables to valid types * * @param object $paymentType * * @return array * @throws TException */ public function getResponse($paymentType) { $ready = array(); $missed = array(); $responseFields = $paymentType->getResponseFields(); foreach ($responseFields as $fieldName => $field) { if (Util::post($fieldName, FieldsConfigDictionary::STRING) === false) { if ($field[FieldsConfigDictionary::REQUIRED] === true) { $missed[] = $fieldName; } } else { $val = Util::post($fieldName, FieldsConfigDictionary::STRING); switch ($field[FieldsConfigDictionary::TYPE]) { case FieldsConfigDictionary::STRING: $val = (string)$val; break; case FieldsConfigDictionary::INT: $val = (int)$val; break; case FieldsConfigDictionary::FLOAT: $val = (float)$val; break; case FieldsConfigDictionary::ARR: $val = (array)$val; break; default: throw new TException(sprintf('unknown field type in getResponse - field name= %s', $fieldName)); } $ready[$fieldName] = $val; } } if (count($missed) > 0) { throw new TException(sprintf('Missing fields in tpay response: %s', implode(',', $missed))); } foreach ($ready as $fieldName => $fieldVal) { $this->hasValidFields($paymentType, $fieldName, $fieldVal, false); } return $ready; } } PK ! %�;� � ! VariableTypes/CountryCodeType.phpnu �[��� <?php /* * Created by tpay.com. * Date: 19.06.2017 * Time: 14:39 */ namespace Omnipay\Tpay\_class_tpay\Validators\VariableTypes; use Omnipay\Tpay\_class_tpay\Utilities\TException; use Omnipay\Tpay\_class_tpay\Validators\VariableTypesInterface; use Omnipay\Tpay\Dictionaries\ISO_codes\CountryCodesDictionary; class CountryCodeType implements VariableTypesInterface { public function validateType($value, $name) { if (!is_string($value) || (strlen($value) !== 2 && strlen($value) !== 3) || (!in_array($value, CountryCodesDictionary::CODES)) ) { throw new TException( sprintf('Field "%s" has invalid country code', $name) ); } } } PK ! ?��Z� � VariableTypes/BooleanType.phpnu �[��� <?php /* * Created by tpay.com. * Date: 19.06.2017 * Time: 14:39 */ namespace Omnipay\Tpay\_class_tpay\Validators\VariableTypes; use Omnipay\Tpay\_class_tpay\Utilities\TException; use Omnipay\Tpay\_class_tpay\Validators\VariableTypesInterface; class BooleanType implements VariableTypesInterface { public function validateType($value, $name) { if (!is_bool($value)) { throw new TException(sprintf('Field "%s" must be a boolean', $name)); } } } PK ! �X� � VariableTypes/ArrayType.phpnu �[��� <?php /* * Created by tpay.com. * Date: 19.06.2017 * Time: 14:39 */ namespace Omnipay\Tpay\_class_tpay\Validators\VariableTypes; use Omnipay\Tpay\_class_tpay\Utilities\TException; use Omnipay\Tpay\_class_tpay\Validators\VariableTypesInterface; class ArrayType implements VariableTypesInterface { public function validateType($value, $name) { if (!is_array($value)) { throw new TException(sprintf('Field "%s" must be an array', $name)); } else { if (count($value) <= 0) { throw new TException(sprintf('Array "%s" must not be empty', $name)); } } } } PK ! ���^O O ! VariableTypes/DescriptionType.phpnu �[��� <?php /* * Created by tpay.com. * Date: 19.06.2017 * Time: 14:39 */ namespace Omnipay\Tpay\_class_tpay\Validators\VariableTypes; use Omnipay\Tpay\_class_tpay\Utilities\TException; use Omnipay\Tpay\_class_tpay\Validators\VariableTypesInterface; class DescriptionType implements VariableTypesInterface { public function validateType($value, $name) { if (preg_match('/[^a-zA-Z0-9 ]/', $value) !== 0) { throw new TException( sprintf('Field "%s" contains invalid characters. Only a-z A-Z 0-9 and space', $name) ); } } } PK ! ���� � ( VariableTypes/VariableTypesValidator.phpnu �[��� <?php /* * Created by tpay.com. * Date: 26.06.2017 * Time: 12:28 */ namespace Omnipay\Tpay\_class_tpay\Validators\VariableTypes; use Omnipay\Tpay\_class_tpay\Utilities\TException; use Omnipay\Tpay\Dictionaries\FieldsConfigDictionary; class VariableTypesValidator { public function __construct($type, $value, $name) { $this->validateType($type, $value, $name); } /** * @param string $type * @param $value * @param string $name * @throws TException */ private function validateType($type, $value, $name) { $a = [ FieldsConfigDictionary::FLOAT => new FloatType(), FieldsConfigDictionary::STRING => new StringType(), FieldsConfigDictionary::INT => new IntType(), FieldsConfigDictionary::EMAIL_LIST => new EmailListType(), FieldsConfigDictionary::ARR => new ArrayType(), FieldsConfigDictionary::BOOLEAN => new BooleanType(), FieldsConfigDictionary::OPIS_DODATKOWY => new DescriptionType(), 'CountryCode' => new CountryCodeType(), ]; if (array_key_exists($type, $a)) { foreach ($a as $key => $value2) { if ($key === $type) { $value2->validateType($value, $name); } } } } } PK ! yr�� � VariableTypes/FloatType.phpnu �[��� <?php /* * Created by tpay.com. * Date: 19.06.2017 * Time: 14:39 */ namespace Omnipay\Tpay\_class_tpay\Validators\VariableTypes; use Omnipay\Tpay\_class_tpay\Utilities\TException; use Omnipay\Tpay\_class_tpay\Validators\VariableTypesInterface; class FloatType implements VariableTypesInterface { public function validateType($value, $name) { if (!is_numeric($value) && !is_int($value)) { throw new TException(sprintf('Field "%s" must be a float|int number', $name)); } else { if ($value < 0) { throw new TException(sprintf('Field "%s" must be higher than zero', $name)); } } } } PK ! �J� VariableTypes/StringType.phpnu �[��� <?php /* * Created by tpay.com. * Date: 19.06.2017 * Time: 14:39 */ namespace Omnipay\Tpay\_class_tpay\Validators\VariableTypes; use Omnipay\Tpay\_class_tpay\Utilities\TException; use Omnipay\Tpay\_class_tpay\Validators\VariableTypesInterface; class StringType implements VariableTypesInterface { public function validateType($value, $name) { if (!is_string($value)) { throw new TException(sprintf('Field "%s" must be a string, type given: ' . gettype($value), $name)); } } } PK ! @M; ; VariableTypes/EmailListType.phpnu �[��� <?php /* * Created by tpay.com. * Date: 19.06.2017 * Time: 14:39 */ namespace Omnipay\Tpay\_class_tpay\Validators\VariableTypes; use Omnipay\Tpay\_class_tpay\Utilities\TException; use Omnipay\Tpay\_class_tpay\Validators\VariableTypesInterface; class EmailListType implements VariableTypesInterface { public function validateType($value, $name) { if (!is_string($value)) { throw new TException(sprintf('Field "%s" must be a string', $name)); } $emails = explode(',', $value); foreach ($emails as $email) { if (filter_var($email, FILTER_VALIDATE_EMAIL) === false && strlen($email) > 0) { throw new TException( sprintf('Field "%s" contains invalid email address', $name) ); } } } } PK ! ��'�� � VariableTypes/IntType.phpnu �[��� <?php /* * Created by tpay.com. * Date: 19.06.2017 * Time: 14:39 */ namespace Omnipay\Tpay\_class_tpay\Validators\VariableTypes; use Omnipay\Tpay\_class_tpay\Utilities\TException; use Omnipay\Tpay\_class_tpay\Validators\VariableTypesInterface; class IntType implements VariableTypesInterface { public function validateType($value, $name) { if (!is_int($value)) { throw new TException(sprintf('Field "%s" must be an integer', $name)); } else { if ($value <= 0) { throw new TException(sprintf('Field "%s" must be higher than zero', $name)); } } } } PK ! �G��� � VariableTypesInterface.phpnu �[��� <?php /* * Created by tpay.com. * Date: 19.06.2017 * Time: 14:43 */ namespace Omnipay\Tpay\_class_tpay\Validators; interface VariableTypesInterface { public function validateType($value, $name); } PK ! P�[�$ $ $ PaymentTypes/PaymentTypeBasicApi.phpnu �[��� <?php /* * Created by tpay.com. * Date: 19.06.2017 * Time: 11:13 */ namespace Omnipay\Tpay\_class_tpay\Validators\PaymentTypes; use Omnipay\Tpay\_class_tpay\Validators\PaymentTypesInterface; use Omnipay\Tpay\Dictionaries\FieldsConfigDictionary; use Omnipay\Tpay\Dictionaries\Payments\StandardFieldsDictionary; class PaymentTypeBasicApi implements PaymentTypesInterface { public function getRequestFields() { $fields = StandardFieldsDictionary::REQUEST_FIELDS; $fields[FieldsConfigDictionary::GROUP][FieldsConfigDictionary::REQUIRED] = true; $fields[FieldsConfigDictionary::NAME][FieldsConfigDictionary::REQUIRED] = true; return $fields; } public function getResponseFields() { return StandardFieldsDictionary::RESPONSE_FIELDS; } } PK ! Tƕ: : * PaymentTypes/PaymentTypeCardDeregister.phpnu �[��� <?php /* * Created by tpay.com. * Date: 19.06.2017 * Time: 11:13 */ namespace Omnipay\Tpay\_class_tpay\Validators\PaymentTypes; use Omnipay\Tpay\_class_tpay\Validators\PaymentTypesInterface; use Omnipay\Tpay\Dictionaries\Payments\CardDeregisterFieldsDictionary; class PaymentTypeCardDeregister implements PaymentTypesInterface { public function getRequestFields() { return CardDeregisterFieldsDictionary::REQUEST_FIELDS; } public function getResponseFields() { return CardDeregisterFieldsDictionary::RESPONSE_FIELDS; } } PK ! h i ! PaymentTypes/PaymentTypeBasic.phpnu �[��� <?php /* * Created by tpay.com. * Date: 19.06.2017 * Time: 11:13 */ namespace Omnipay\Tpay\_class_tpay\Validators\PaymentTypes; use Omnipay\Tpay\_class_tpay\Validators\PaymentTypesInterface; use Omnipay\Tpay\Dictionaries\Payments\StandardFieldsDictionary; class PaymentTypeBasic implements PaymentTypesInterface { public function getRequestFields() { return StandardFieldsDictionary::REQUEST_FIELDS; } public function getResponseFields() { return StandardFieldsDictionary::RESPONSE_FIELDS; } } PK ! ��q�� � % PaymentTypes/PaymentTypeBlikAlias.phpnu �[��� <?php /* * Created by tpay.com. * Date: 19.06.2017 * Time: 11:13 */ namespace Omnipay\Tpay\_class_tpay\Validators\PaymentTypes; use Omnipay\Tpay\_class_tpay\Validators\PaymentTypesInterface; use Omnipay\Tpay\Dictionaries\FieldsConfigDictionary; use Omnipay\Tpay\Dictionaries\Payments\BlikFieldsDictionary; class PaymentTypeBlikAlias implements PaymentTypesInterface { public function getRequestFields() { $fields = BlikFieldsDictionary::REQUEST_FIELDS; $fields['code'][FieldsConfigDictionary::REQUIRED] = false; return $fields; } public function getResponseFields() { return BlikFieldsDictionary::ALIAS_RESPONSE_FIELDS; } } PK ! x &