Skip to content

Commit

Permalink
Ed test pass build (#2)
Browse files Browse the repository at this point in the history
* test build failed pull request

* test build success pull request

* update travis

* Revert "update travis"

This reverts commit 23c41b6.

* update travis

* add php cs

* run php systax error before composer install

* add phpcs.xml

* delete DisallowObEndFlush

* delete Squiz.PHP.ForbiddenFunctions

* php cs fix

* fix phpcs

* phpcs psr-12 standart
  • Loading branch information
enesdayanc committed Jul 10, 2020
1 parent f2bef30 commit 65395a3
Show file tree
Hide file tree
Showing 42 changed files with 535 additions and 89 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -6,3 +6,4 @@
composer.lock
composer.phar
/.idea
/.php_cs.cache
353 changes: 353 additions & 0 deletions .phpcs.xml

Large diffs are not rendered by default.

20 changes: 19 additions & 1 deletion .travis.yml
@@ -1,3 +1,4 @@
sudo: false
language: php
php:
- 7.0
Expand All @@ -10,11 +11,28 @@ cache:
- $HOME/.composer/cache/files

before_script:
- composer self-update
# Search for PHP syntax errors.
- if find . -name "*.php" ! -path "./vendor/*" -exec php -l {} \; | grep -v "No syntax errors detected"; then exit 1; fi
- composer require --dev php-coveralls/php-coveralls
- composer install --dev
- export PHPCS_DIR=/tmp/phpcs;
- export PHPCOMPAT_DIR=/tmp/PHPCompatibility;
# Install PHP CodeSniffer.
- git clone -b master --depth 1 https://github.com/squizlabs/PHP_CodeSniffer.git $PHPCS_DIR;
# Install PHP Compatibility Standard.
- git clone -b master --depth 1 https://github.com/wimg/PHPCompatibility.git $PHPCOMPAT_DIR;
# Set install path for PHP Compatibility Standard.
# @link https://github.com/squizlabs/PHP_CodeSniffer/wiki/Configuration-Options#setting-the-installed-standard-paths
- $PHPCS_DIR/bin/phpcs --config-set installed_paths $PHPCOMPAT_DIR;
# After CodeSniffer install you should refresh your path.
- phpenv rehash;

script:
# Run PHPCS.
# If the custom ruleset is named `.phpcs.xml`, `phpcs.xml`, `.phpcs.xml.dist` or `phpcs.xml.dist`
# and, like the travis script, is in the root of the project, you can leave
# out the `--standard=` part of the command.
- $PHPCS_DIR/bin/phpcs .
- vendor/bin/phpunit --coverage-clover build/logs/clover.xml

after_script:
Expand Down
1 change: 1 addition & 0 deletions composer.json
Expand Up @@ -12,6 +12,7 @@
],
"require": {
"php": ">=7.0",
"ext-simplexml": "*",
"guzzlehttp/guzzle": "~6.0",
"spatie/array-to-xml": "^2.5",
"enesdayanc/iso4217": "^3.0"
Expand Down
3 changes: 1 addition & 2 deletions src/Constant/BankType.php
Expand Up @@ -8,7 +8,6 @@

namespace PaymentGateway\VPosEst\Constant;


class BankType
{
const AKBANK = 'AKBANK';
Expand All @@ -17,4 +16,4 @@ class BankType
const TURKIYE_IS_BANKASI = 'TURKIYE_IS_BANKASI';
const TURKIYE_IS_BANKASI_TEST = 'TURKIYE_IS_BANKASI_TEST';
const MOCKBANK = 'MOCKBANK';
}
}
3 changes: 1 addition & 2 deletions src/Constant/CardholderPresentCode.php
Expand Up @@ -8,8 +8,7 @@

namespace PaymentGateway\VPosEst\Constant;


class CardholderPresentCode
{
const THREE_D = 13;
}
}
2 changes: 1 addition & 1 deletion src/Constant/Currency.php
Expand Up @@ -14,4 +14,4 @@ class Currency
const USD = 'USD';
const EUR = 'EUR';
const GBP = 'GBP';
}
}
2 changes: 1 addition & 1 deletion src/Constant/Language.php
Expand Up @@ -12,4 +12,4 @@ class Language
{
const TR = 'TR';
const EN = 'EN';
}
}
3 changes: 1 addition & 2 deletions src/Constant/MdStatus.php
Expand Up @@ -8,7 +8,6 @@

namespace PaymentGateway\VPosEst\Constant;


class MdStatus
{
const ZERO = 0; // Risk Owner: Merchant
Expand All @@ -21,4 +20,4 @@ class MdStatus
const SEVEN = 7; // Risk Owner: Merchant
const EIGHTH = 8; // Risk Owner: Merchant
const NINE = 9; // Risk Owner: Merchant or Card Owner or Bank (Without 3D rules)
}
}
3 changes: 1 addition & 2 deletions src/Constant/RedirectFormMethod.php
Expand Up @@ -8,9 +8,8 @@

namespace PaymentGateway\VPosEst\Constant;


class RedirectFormMethod
{
const GET = 'GET';
const POST = 'POST';
}
}
2 changes: 1 addition & 1 deletion src/Constant/RequestMode.php
Expand Up @@ -11,4 +11,4 @@
class RequestMode
{
const P = 'P';
}
}
2 changes: 1 addition & 1 deletion src/Constant/RequestType.php
Expand Up @@ -15,4 +15,4 @@ class RequestType
const AUTH = 'Auth';
const CREDIT = 'Credit';
const VOID = 'Void';
}
}
2 changes: 1 addition & 1 deletion src/Constant/StoreType.php
Expand Up @@ -12,4 +12,4 @@ class StoreType
{
const THREE_D = '3d';
const THREE_D_PAY = '3d_pay';
}
}
3 changes: 1 addition & 2 deletions src/Constant/Success.php
Expand Up @@ -8,9 +8,8 @@

namespace PaymentGateway\VPosEst\Constant;


class Success
{
const PROC_RETURN_CODE = '00';
const RESPONSE = 'Approved';
}
}
11 changes: 10 additions & 1 deletion src/Exception/BaseException.php
Expand Up @@ -13,9 +13,18 @@

abstract class BaseException extends Exception
{

private $userMessage;

private $internalMessage;

/**
* BaseException constructor.
* @param $userMessage
* @param $internalMessage
* @param int $code
* @param Throwable|null $previous
*/
public function __construct($userMessage, $internalMessage, $code = 0, Throwable $previous = null)
{
parent::__construct($userMessage, $code, $previous);
Expand Down Expand Up @@ -54,4 +63,4 @@ public function setInternalMessage($internalMessage)
{
$this->internalMessage = $internalMessage;
}
}
}
4 changes: 1 addition & 3 deletions src/Exception/CurlException.php
Expand Up @@ -8,8 +8,6 @@

namespace PaymentGateway\VPosEst\Exception;


class CurlException extends BaseException
{

}
}
3 changes: 1 addition & 2 deletions src/Exception/NotFoundException.php
Expand Up @@ -10,5 +10,4 @@

class NotFoundException extends BaseException
{

}
}
3 changes: 1 addition & 2 deletions src/Exception/ValidationException.php
Expand Up @@ -4,5 +4,4 @@

class ValidationException extends BaseException
{

}
}
7 changes: 3 additions & 4 deletions src/Helper/Helper.php
Expand Up @@ -8,7 +8,6 @@

namespace PaymentGateway\VPosEst\Helper;


use Exception;
use PaymentGateway\ISO4217\ISO4217;
use PaymentGateway\VPosEst\Constant\BankType;
Expand Down Expand Up @@ -57,7 +56,7 @@ public static function arrayToXmlString(array $array)

public static function getConstants($class)
{
$oClass = new ReflectionClass ($class);
$oClass = new ReflectionClass($class);
return $oClass->getConstants();
}

Expand Down Expand Up @@ -95,7 +94,7 @@ public static function getResponseByXML($xml, $requestRawData)
$response->setRawData($xml);
$response->setRequestRawData($requestRawData);

$data = @simplexml_load_string($xml);
$data = simplexml_load_string($xml);

if (empty($data)) {
throw new ValidationException('Invalid Xml Response', 'INVALID_XML_RESPONSE');
Expand Down Expand Up @@ -219,4 +218,4 @@ public static function getValueFromArray(array $array, $key, $default = null)

return $default;
}
}
}
3 changes: 2 additions & 1 deletion src/Helper/Validator.php
Expand Up @@ -74,6 +74,7 @@ public static function validateCardNumber($value)
$digit -= 9;
}
}

$total += $digit;
}

Expand Down Expand Up @@ -159,4 +160,4 @@ public static function validateNotEmpty($name, $value)
throw new ValidationException("Invalid $name", "INVALID_$name");
}
}
}
}
18 changes: 11 additions & 7 deletions src/HttpClient.php
Expand Up @@ -8,7 +8,6 @@

namespace PaymentGateway\VPosEst;


use PaymentGateway\VPosEst\Exception\CurlException;
use PaymentGateway\VPosEst\Helper\Helper;
use PaymentGateway\VPosEst\Request\RequestInterface;
Expand All @@ -18,7 +17,9 @@

class HttpClient
{

private $setting;

private $timeout = 20;

/**
Expand All @@ -44,16 +45,19 @@ public function send(RequestInterface $requestElements, $url)
$client = new Client();

try {
$clientResponse = $client->post($url, [
'timeout' => $this->timeout,
'form_params' => [
'DATA' => $documentString,
$clientResponse = $client->post(
$url,
[
'timeout' => $this->timeout,
'form_params' => [
'DATA' => $documentString,
]
]
]);
);
} catch (Exception $exception) {
throw new CurlException('Connection Error', $exception->getMessage());
}

return Helper::getResponseByXML($clientResponse->getBody()->getContents(), $documentString);
}
}
}
10 changes: 7 additions & 3 deletions src/Model/Card.php
Expand Up @@ -8,17 +8,22 @@

namespace PaymentGateway\VPosEst\Model;


use PaymentGateway\VPosEst\Helper\Helper;
use PaymentGateway\VPosEst\Helper\Validator;

class Card
{

private $creditCardNumber;

private $expiryMonth;

private $expiryYear;

private $cvv;

private $firstName;

private $lastName;

/**
Expand Down Expand Up @@ -112,7 +117,6 @@ public function getCvv(bool $maskCardData = false)
*/
public function setCvv($cvv)
{

$this->cvv = $cvv;
}

Expand Down Expand Up @@ -160,4 +164,4 @@ public function validate()
Validator::validateExpiryYear($this->getExpiryYear(true));
Validator::validateCvv($this->getCvv());
}
}
}
6 changes: 4 additions & 2 deletions src/Model/RedirectForm.php
Expand Up @@ -8,11 +8,13 @@

namespace PaymentGateway\VPosEst\Model;


class RedirectForm
{

private $action;

private $method;

private $parameters;

/**
Expand Down Expand Up @@ -62,4 +64,4 @@ public function setParameters($parameters)
{
$this->parameters = $parameters;
}
}
}

0 comments on commit 65395a3

Please sign in to comment.