Skip to content

Commit f6f15b4

Browse files
committed
Use SHA256 as default hash mode. Changed project structure. Added tests.
1 parent 521dcdf commit f6f15b4

34 files changed

+1724
-84
lines changed

.github/CODEOWNERS

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @ekyna

.github/workflows/build.yml

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Build
2+
3+
on:
4+
push: ~
5+
pull_request: ~
6+
release:
7+
types: [created]
8+
schedule:
9+
-
10+
cron: "0 1 * * 6" # Run at 1am every Saturday
11+
workflow_dispatch: ~
12+
13+
jobs:
14+
tests:
15+
runs-on: ubuntu-latest
16+
17+
name: "PHP ${{ matrix.php }}, Symfony ${{ matrix.symfony }}"
18+
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
php: [7.1, 7.2, 7.3, 7.4]
23+
symfony: [^3.4, ^4.4, ^5.2]
24+
exclude:
25+
- php: 7.1
26+
symfony: ^5.2
27+
28+
env:
29+
APP_ENV: test
30+
31+
steps:
32+
-
33+
uses: actions/checkout@v2
34+
35+
-
36+
name: Setup PHP
37+
uses: shivammathur/setup-php@v2
38+
with:
39+
php-version: "${{ matrix.php }}"
40+
extensions: intl
41+
tools: symfony
42+
coverage: none
43+
44+
-
45+
name: Get Composer cache directory
46+
id: composer-cache
47+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
48+
49+
-
50+
name: Cache Composer
51+
uses: actions/cache@v2
52+
with:
53+
path: ${{ steps.composer-cache.outputs.dir }}
54+
key: ${{ runner.os }}-php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.json **/composer.lock') }}
55+
restore-keys: |
56+
${{ runner.os }}-php-${{ matrix.php }}-composer-
57+
-
58+
name: Restrict Symfony version
59+
if: matrix.symfony != ''
60+
run: |
61+
composer global require --no-progress --no-scripts --no-plugins "symfony/flex:^1.10"
62+
composer config extra.symfony.require "${{ matrix.symfony }}"
63+
64+
-
65+
name: Install PHP dependencies
66+
run: composer install --no-interaction
67+
68+
-
69+
name: Run analysis
70+
run: composer validate --strict
71+
72+
-
73+
name: Run PHPUnit
74+
run: vendor/bin/phpunit --colors=always

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@ Thumbs.db
22
ehthumbs.db
33
.DS_Store
44
vendor
5-
composer.lock
5+
cache
6+
composer.lock
7+
.phpunit.result.cache

CHANGELOG.md

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
CHANGELOG for 1.5
2+
===
3+
4+
* 1.5.1
5+
* __Sha256__ is now the <ins>default hash algorithm</ins> used to generate signature. If you still want to use __Sha1__ (previously the default algorithm for SYSTEMPAY endpoint), you must update the API config:
6+
7+
#### Before
8+
9+
$config = [
10+
'site_id' => ' ... ',
11+
'certificate' => ' ... ',
12+
'ctx_mode' => Api::MODE_PRODUCTION,
13+
'directory' => ' ... ',
14+
];
15+
16+
#### After
17+
18+
$config = [
19+
'site_id' => ' ... ',
20+
'certificate' => ' ... ',
21+
'ctx_mode' => Api::MODE_PRODUCTION,
22+
'directory' => ' ... ',
23+
'hash_mode' => Api::HASH_MODE_SHA1, // Add this entry
24+
];

composer.json

+18-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ekyna/payum-payzen",
3-
"description": "PayZen Payum gateway",
3+
"description": "Payum PayZen (Systempay, Scellius) gateway",
44
"type": "component",
55
"authors": [
66
{
@@ -9,23 +9,35 @@
99
}
1010
],
1111
"keywords": [
12+
"php",
1213
"payum",
13-
"payzen"
14+
"payzen",
15+
"systempay",
16+
"scellius"
1417
],
1518
"homepage": "https://github.com/ekyna/PayumPayzen",
1619
"license": [
1720
"MIT"
1821
],
1922
"require": {
20-
"php": "^7.0",
23+
"php": "^7.1",
2124
"payum/core": "^1.5",
2225
"php-http/guzzle6-adapter": "^1.1",
23-
"symfony/process": "~2.7|~3.0|~4.0",
24-
"psr/log": "~1.0"
26+
"symfony/options-resolver": "^3.0|^4.0|^5.0",
27+
"symfony/process": "^3.0|^4.0|^5.0",
28+
"psr/log": "^1.0"
29+
},
30+
"require-dev": {
31+
"phpunit/phpunit": "^8"
2532
},
2633
"autoload": {
2734
"psr-4": {
28-
"Ekyna\\Component\\Payum\\Payzen\\": ""
35+
"Ekyna\\Component\\Payum\\Payzen\\": "src/"
36+
}
37+
},
38+
"autoload-dev": {
39+
"psr-4": {
40+
"Ekyna\\Component\\Payum\\Payzen\\Tests\\": "tests/"
2941
}
3042
}
3143
}

phpunit.xml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit backupGlobals="true"
3+
backupStaticAttributes="false"
4+
colors="true"
5+
convertErrorsToExceptions="true"
6+
convertNoticesToExceptions="true"
7+
convertWarningsToExceptions="true"
8+
processIsolation="false"
9+
stopOnFailure="false"
10+
bootstrap="tests/bootstrap.php">
11+
12+
<testsuites>
13+
<testsuite name="Ekyna Payum Payzen Component Test Suite">
14+
<directory>./tests</directory>
15+
</testsuite>
16+
</testsuites>
17+
18+
<filter>
19+
<whitelist>
20+
<directory>./src</directory>
21+
<exclude>
22+
<directory>./tests</directory>
23+
<directory>./vendor</directory>
24+
</exclude>
25+
</whitelist>
26+
</filter>
27+
</phpunit>

Action/Api/AbstractApiAction.php src/Action/Api/AbstractApiAction.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function setApi($api)
4444
}
4545

4646
/**
47-
* {@inheritDoc}
47+
* @inheritDoc
4848
*/
4949
public function setLogger(LoggerInterface $logger)
5050
{
@@ -56,7 +56,7 @@ public function setLogger(LoggerInterface $logger)
5656
*
5757
* @param string $message
5858
*/
59-
protected function log($message)
59+
protected function log(string $message)
6060
{
6161
if (!$this->logger) {
6262
return;
@@ -72,7 +72,7 @@ protected function log($message)
7272
* @param array $data
7373
* @param array $filterKeys
7474
*/
75-
protected function logData($message, array $data, array $filterKeys = [])
75+
protected function logData(string $message, array $data, array $filterKeys = [])
7676
{
7777
if (!$this->logger) {
7878
return;

Action/Api/ApiRequestAction.php src/Action/Api/ApiRequestAction.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ class ApiRequestAction extends AbstractApiAction
1717
/**
1818
* @inheritdoc
1919
*
20-
* @throws \Payum\Core\Reply\HttpRedirect
20+
* @throws HttpRedirect
2121
*/
22-
public function execute($request)
22+
public function execute($request): void
2323
{
2424
/** @var Request $request */
2525
RequestNotSupportedException::assertSupports($this, $request);
@@ -48,7 +48,7 @@ public function execute($request)
4848
*
4949
* @param array $data
5050
*/
51-
private function logRequestData(array $data)
51+
private function logRequestData(array $data): void
5252
{
5353
$this->logData("[Payzen] Request", $data, [
5454
'vads_order_id',
@@ -64,9 +64,9 @@ private function logRequestData(array $data)
6464
}
6565

6666
/**
67-
* @inheritdoc
67+
* @inheritDoc
6868
*/
69-
public function supports($request)
69+
public function supports($request): bool
7070
{
7171
return $request instanceof Request
7272
&& $request->getModel() instanceof \ArrayAccess;

Action/Api/ApiResponseAction.php src/Action/Api/ApiResponseAction.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
class ApiResponseAction extends AbstractApiAction
1616
{
1717
/**
18-
* @inheritdoc
18+
* @inheritDoc
1919
*/
2020
public function execute($request)
2121
{
@@ -71,9 +71,9 @@ private function logResponseData(array $data)
7171
}
7272

7373
/**
74-
* @inheritdec
74+
* @inheritDoc
7575
*/
76-
public function supports($request)
76+
public function supports($request): bool
7777
{
7878
return $request instanceof Response
7979
&& $request->getModel() instanceof \ArrayAccess;

Action/CancelAction.php src/Action/CancelAction.php

+6-5
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
namespace Ekyna\Component\Payum\Payzen\Action;
44

5-
use Ekyna\Component\Commerce\Bridge\Payum\Request\GetHumanStatus;
65
use Payum\Core\Action\ActionInterface;
76
use Payum\Core\Bridge\Spl\ArrayObject;
87
use Payum\Core\Exception\RequestNotSupportedException;
98
use Payum\Core\GatewayAwareInterface;
109
use Payum\Core\GatewayAwareTrait;
1110
use Payum\Core\Request\Cancel;
11+
use Payum\Core\Request\GetHumanStatus;
1212

1313
/**
1414
* Class CancelAction
@@ -20,10 +20,11 @@ class CancelAction implements ActionInterface, GatewayAwareInterface
2020
use GatewayAwareTrait;
2121

2222
/**
23-
* {@inheritdoc}
23+
* @inheritDoc
2424
*
2525
* @param Cancel $request
26-
*/
26+
*
27+
* @noinspection PhpMissingParamTypeInspection*/
2728
public function execute($request)
2829
{
2930
RequestNotSupportedException::assertSupports($this, $request);
@@ -38,9 +39,9 @@ public function execute($request)
3839
}
3940

4041
/**
41-
* {@inheritdoc}
42+
* @inheritDoc
4243
*/
43-
public function supports($request)
44+
public function supports($request): bool
4445
{
4546
return $request instanceof Cancel
4647
&& $request->getModel() instanceof \ArrayAccess;

Action/CaptureAction.php src/Action/CaptureAction.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,17 @@ class CaptureAction implements ActionInterface, GatewayAwareInterface, GenericTo
2424
use GenericTokenFactoryAwareTrait;
2525

2626
/**
27-
* {@inheritdoc}
27+
* @inheritDoc
2828
*
2929
* @param Capture $request
30-
*/
30+
*
31+
* @noinspection PhpMissingParamTypeInspection*/
3132
public function execute($request)
3233
{
3334
RequestNotSupportedException::assertSupports($this, $request);
3435

3536
$model = ArrayObject::ensureArrayObject($request->getModel());
3637

37-
3838
if ($request->getToken()) {
3939
// Done redirections
4040
$targetUrl = $request->getToken()->getTargetUrl();
@@ -70,9 +70,9 @@ public function execute($request)
7070
}
7171

7272
/**
73-
* {@inheritdoc}
73+
* @inheritDoc
7474
*/
75-
public function supports($request)
75+
public function supports($request): bool
7676
{
7777
return $request instanceof Capture
7878
&& $request->getModel() instanceof \ArrayAccess;

Action/ConvertPaymentAction.php src/Action/ConvertPaymentAction.php

+5-4
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@ class ConvertPaymentAction implements ActionInterface, GatewayAwareInterface
2222
use GatewayAwareTrait;
2323

2424
/**
25-
* {@inheritDoc}
25+
* @inheritDoc
2626
*
2727
* @param Convert $request
28-
*/
28+
*
29+
* @noinspection PhpMissingParamTypeInspection*/
2930
public function execute($request)
3031
{
3132
RequestNotSupportedException::assertSupports($this, $request);
@@ -60,9 +61,9 @@ public function execute($request)
6061
}
6162

6263
/**
63-
* {@inheritDoc}
64+
* @inheritDoc
6465
*/
65-
public function supports($request)
66+
public function supports($request): bool
6667
{
6768
return $request instanceof Convert
6869
&& $request->getSource() instanceof PaymentInterface

Action/NotifyAction.php src/Action/NotifyAction.php

+5-4
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@ class NotifyAction implements ActionInterface, GatewayAwareInterface
2020
use GatewayAwareTrait;
2121

2222
/**
23-
* {@inheritDoc}
23+
* @inheritDoc
2424
*
2525
* @param Notify $request
26-
*/
26+
*
27+
* @noinspection PhpMissingParamTypeInspection*/
2728
public function execute($request)
2829
{
2930
RequestNotSupportedException::assertSupports($this, $request);
@@ -34,9 +35,9 @@ public function execute($request)
3435
}
3536

3637
/**
37-
* {@inheritDoc}
38+
* @inheritDoc
3839
*/
39-
public function supports($request)
40+
public function supports($request): bool
4041
{
4142
return $request instanceof Notify
4243
&& $request->getModel() instanceof \ArrayAccess;

0 commit comments

Comments
 (0)