Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update deps and PHP requirements #9

Merged
merged 7 commits into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 26 additions & 9 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,54 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2']
php-versions: ['8.0', '8.1', '8.2', '8.3']

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
# Fetch 10 commits or Scrutinizer will throw ("Failed to retrieve commit parents.
# If you use a shallow git checkout, please checkout at least a depth of one."),
# see: RepositoryIntrospector at scrutinizer-ci/ocular GitHub repository
fetch-depth: 10

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: curl, mbstring, intl, libxml, simplexml
coverage: xdebug

- name: Get composer cache directory
id: composer-cache-dir
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache Composer packages
id: composer-cache-restore
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache-dir.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install dependencies
run: (test -d vendor && echo vendor directory exists) || composer install --prefer-dist --no-progress --no-suggest

- name: Run PHPUnit
run: vendor/bin/phpunit --coverage-text --coverage-clover clover.xml
- name: Upload Scrutinizer coverage
if: matrix.php-versions == '8.1'
uses: sudo-bot/action-scrutinizer@latest
with:
cli-args: "--format=php-clover clover.xml"

- name: "[Coveralls] Extract branch name"
if: matrix.php-versions == '8.3'
shell: bash
run: echo "branch=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_OUTPUT
id: extract_branch

- name: "[Coveralls] Checkout branch"
if: matrix.php-versions == '8.3'
shell: bash
run: git fetch && git checkout ${{ steps.extract_branch.outputs.branch }}

- name: "[Coveralls] Send report"
if: matrix.php-versions == '8.3'
run: ./vendor/bin/php-coveralls -v -x clover.xml -o coveralls-upload.json
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ clover.xml
/tests/demo/paymentID.txt
/tests/demo/shopID.txt
/.php-cs-fixer.cache
/.phpunit.cache/test-results
1 change: 0 additions & 1 deletion .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
'protected_to_private' => false,
'strict_param' => true,
'single_quote' => false,
'single_blank_line_before_namespace' => true,
'single_blank_line_at_eof' => true,
'single_trait_insert_per_statement' => false,
'whitespace_after_comma_in_array' => true,
Expand Down
15 changes: 8 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,21 @@
},
"license": "BSD-3-Clause",
"require": {
"php": ">=7.2",
"php": ">=8.0.2",
"ext-curl": "*",
"ext-libxml": "*",
"ext-mbstring": "*",
"ext-simplexml": "*",
"illuminate/support": "^5.8|^6.0|^7.0|^8.0|^9.0",
"illuminate/support": "^9.0|^10.0|^11.0",
"guzzlehttp/guzzle": "~6.0|^7.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.16|^3.0",
"phpunit/phpunit": "^7.5|^8.0|^9.0",
"phpstan/phpstan": "^1.4",
"illuminate/config": "^5.8|^6.0|^7.0|^8.0|^9.0",
"orchestra/testbench": "^3.7|^4.0|^5.0|^6.0|^7.0"
"friendsofphp/php-cs-fixer": "^3.0",
"phpunit/phpunit": "^9.0|^10.0|^11.0",
"phpstan/phpstan": "^1.11",
"illuminate/config": "^9.0|^10.0|^11.0",
"orchestra/testbench": "^7.0|^8.0|^9.0",
"php-coveralls/php-coveralls": "^2.7"
},
"autoload": {
"psr-4": {
Expand Down
31 changes: 15 additions & 16 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage>
<include>
<directory suffix=".php">./src/</directory>
</include>
</coverage>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
backupGlobals="false"
bootstrap="vendor/autoload.php"
colors="true"
processIsolation="false"
stopOnFailure="false"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.2/phpunit.xsd"
cacheDirectory=".phpunit.cache"
backupStaticProperties="false">
<testsuites>
<testsuite name="Unit">
<directory suffix="Test.php">./tests/Unit</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory suffix=".php">./src/</directory>
</include>
</source>
</phpunit>
31 changes: 14 additions & 17 deletions src/Actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,29 @@

namespace PagOnline;

/**
* Class Actions.
*/
final class Actions
{
// Init
const IGFS_CG_INIT = Init\IgfsCgInit::class;
const IGFS_CG_SELECTOR = Init\IgfsCgSelector::class;
const IGFS_CG_VERIFY = Init\IgfsCgVerify::class;
public const IGFS_CG_INIT = Init\IgfsCgInit::class;
public const IGFS_CG_SELECTOR = Init\IgfsCgSelector::class;
public const IGFS_CG_VERIFY = Init\IgfsCgVerify::class;

// Mpi
const IGFS_CG_MPI_AUTH = Mpi\IgfsCgMpiAuth::class;
const IGFS_CG_MPI_ENROLL = Mpi\IgfsCgMpiEnroll::class;
public const IGFS_CG_MPI_AUTH = Mpi\IgfsCgMpiAuth::class;
public const IGFS_CG_MPI_ENROLL = Mpi\IgfsCgMpiEnroll::class;

// PayByMail
const IGFS_CG_PAY_BY_MAIL_INIT = PayByMail\IgfsCgPayByMailInit::class;
const IGFS_CG_PAY_BY_MAIL_VERIFY = PayByMail\IgfsCgPayByMailVerify::class;
public const IGFS_CG_PAY_BY_MAIL_INIT = PayByMail\IgfsCgPayByMailInit::class;
public const IGFS_CG_PAY_BY_MAIL_VERIFY = PayByMail\IgfsCgPayByMailVerify::class;

// Tokenizer
const IGFS_CG_TOKENIZER_CHECK = Tokenizer\IgfsCgTokenizerCheck::class;
const IGFS_CG_TOKENIZER_DELETE = Tokenizer\IgfsCgTokenizerDelete::class;
const IGFS_CG_TOKENIZER_ENROLL = Tokenizer\IgfsCgTokenizerEnroll::class;
public const IGFS_CG_TOKENIZER_CHECK = Tokenizer\IgfsCgTokenizerCheck::class;
public const IGFS_CG_TOKENIZER_DELETE = Tokenizer\IgfsCgTokenizerDelete::class;
public const IGFS_CG_TOKENIZER_ENROLL = Tokenizer\IgfsCgTokenizerEnroll::class;

// Tran
const IGFS_CG_AUTH = Tran\IgfsCgAuth::class;
const IGFS_CG_CONFIRM = Tran\IgfsCgConfirm::class;
const IGFS_CG_CREDIT = Tran\IgfsCgCredit::class;
const IGFS_CG_VOID_AUTH = Tran\IgfsCgVoidAuth::class;
public const IGFS_CG_AUTH = Tran\IgfsCgAuth::class;
public const IGFS_CG_CONFIRM = Tran\IgfsCgConfirm::class;
public const IGFS_CG_CREDIT = Tran\IgfsCgCredit::class;
public const IGFS_CG_VOID_AUTH = Tran\IgfsCgVoidAuth::class;
}
60 changes: 23 additions & 37 deletions src/BaseIgfsCg.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@
use PagOnline\Exceptions\IgfsMissingParException;
use PagOnline\Exceptions\IOException;
use PagOnline\Traits\HttpClient;
use SimpleXMLElement;

/**
* Class BaseIgfsCg.
*/
abstract class BaseIgfsCg implements IgfsCgInterface
{
use HttpClient;
Expand All @@ -22,7 +18,7 @@ abstract class BaseIgfsCg implements IgfsCgInterface
*
* @var string
*/
const VERSION = '2.4.1.5';
public const VERSION = '2.4.1.5';

/**
* Signature Key.
Expand All @@ -36,18 +32,18 @@ abstract class BaseIgfsCg implements IgfsCgInterface
*
* @var null|string
*/
public $serverURL = null;
public $serverURLs = null;
public $serverURL;
public $serverURLs;

public $shopID = null;
public $shopID;

public $tid = null;
public $merID = null;
public $payInstr = null;
public $tid;
public $merID;
public $payInstr;

public $rc = null;
public $error = null;
public $errorDesc = null;
public $rc;
public $error;
public $errorDesc;

protected static $soapBodyTag = 'Body';
protected static $soapResponseParentTag = '';
Expand All @@ -62,18 +58,12 @@ abstract class BaseIgfsCg implements IgfsCgInterface

protected $fields2Reset = false;

/**
* BaseIgfsCg constructor.
*/
public function __construct()
{
$this->generateHttpClient();
}

/**
* Reset fields.
*/
public function resetFields()
public function resetFields(): void
{
$this->tid = null;
$this->merID = null;
Expand Down Expand Up @@ -115,15 +105,15 @@ public function execute(): bool
$mapResponse = $this->executeHttp($this->serverURL);
} else {
$sURLs = $this->serverURLs;
$sURL = \array_shift($sURLs);
$sURL = array_shift($sURLs);
$finished = false;
while (!$finished) {
try {
$mapResponse = $this->executeHttp($sURL);
$finished = true;
} catch (ConnectionException $e) {
if (!empty($sURLs)) {
$sURL = \array_shift($sURLs);
$sURL = array_shift($sURLs);
} else {
throw $e;
}
Expand Down Expand Up @@ -206,12 +196,7 @@ abstract protected function getAdditionalRequestSignatureFields(): array;

/***
* Generates a signature
*
* @param $signatureFields
*
* @throws IgfsException
*
* @return string
*/
protected function getSignature(array $signatureFields): string
{
Expand All @@ -221,8 +206,8 @@ protected function getSignature(array $signatureFields): string
$data .= (string) $value;
}

return \base64_encode(\hash_hmac('sha256', $data, $this->kSig, true));
} catch (\Exception $e) {
return base64_encode(hash_hmac('sha256', $data, $this->kSig, true));
} catch (\Throwable $e) {
throw new IgfsException($e);
}
}
Expand All @@ -238,7 +223,7 @@ protected function getSignature(array $signatureFields): string
*/
protected function setRequestSignature(&$request): void
{
$signatureFields = \array_merge(
$signatureFields = array_merge(
$this->getCommonRequestSignatureFields(),
$this->getAdditionalRequestSignatureFields()
);
Expand Down Expand Up @@ -302,7 +287,7 @@ protected function replaceRequestParameter(
$xmlTag .= $wrap_cdata ? "<![CDATA[{$value}]]>" : $value;
$xmlTag .= "</{$parameter}>";
}
$request = \str_replace('{'.$parameter.'}', $xmlTag, $request);
$request = str_replace('{'.$parameter.'}', $xmlTag, $request);
}

/**
Expand All @@ -327,12 +312,13 @@ abstract protected function getResponseSignature($response);
/**
* @param string $response
*
* @return null|SimpleXMLElement
* @return null|\SimpleXMLElement
*/
protected function responseXmlToObject(string $response): ?SimpleXMLElement
protected function responseXmlToObject(string $response): ?\SimpleXMLElement
{
try {
$dom = new SimpleXMLElement($response, LIBXML_NOERROR, false);
$dom = new \SimpleXMLElement($response, LIBXML_NOERROR, false);

/*$responseNode = $dom->children('soap', true)->{static::$soapBodyTag}
->children('ns1', true)->{static::$soapResponseParentTag}
->children()
Expand Down Expand Up @@ -399,8 +385,8 @@ protected function checkResponseSignature($response)
/**
* @param string $url
*
* @throws \PagOnline\Exceptions\IOException
* @throws \PagOnline\Exceptions\IgfsException
* @throws IOException
* @throws IgfsException
*
* @return array
*/
Expand Down
5 changes: 1 addition & 4 deletions src/BaseIgfsCgRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@

namespace PagOnline;

/**
* Class BaseIgfsCgRequest.
*/
abstract class BaseIgfsCgRequest
{
const CONTENT = '';
public const CONTENT = '';

/**
* @return string
Expand Down
Loading