Skip to content

Commit 7768372

Browse files
simonwestynSimon
andauthored
Payconiq > WERO/Bancontact migration + PHP 8 (#19)
* Payconiq > WERO/Bancontact migration + PHP 8 * cleanup * updated phpcs * fix * PSR12 * improvements * fix github action codecov? * fix codecov? * added codecov.yml * use DateTimeInterface to support DateTime & DateTimeImmutable * readme update * cacheKey fix * fix phpunit * typo * update example * useNewPreProductionEnv for qr code generator * fix JWS verifier? * allow short variables * phpcs fix --------- Co-authored-by: Simon <simon@optios.net>
1 parent 0a06099 commit 7768372

67 files changed

Lines changed: 1947 additions & 1859 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/tests.yaml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ jobs:
99
strategy:
1010
matrix:
1111
operating-system: ['ubuntu-latest']
12-
php-versions: ['7.2', '7.3', '7.4']
12+
php-versions: ['8.2', '8.3', '8.4']
1313
phpunit-versions: ['latest']
1414

1515
steps:
1616
- name: Checkout code
17-
uses: actions/checkout@v2
17+
uses: actions/checkout@v4
1818

1919
- name: Setup PHP, with composer and extensions
2020
uses: shivammathur/setup-php@v2
@@ -40,8 +40,11 @@ jobs:
4040
run: php vendor/bin/phpcs src/ tests/ --colors -p
4141

4242
- name: Send test coverage to codecov.io
43-
uses: codecov/codecov-action@v2.1.0
43+
if: matrix.php-versions == '8.4'
44+
uses: codecov/codecov-action@v5
4445
with:
46+
token: ${{ secrets.CODECOV_TOKEN }}
4547
files: clover.xml
46-
fail_ci_if_error: true # optional (default = false)
47-
verbose: true # optional (default = false)
48+
flags: php-${{ matrix.php-versions }}
49+
fail_ci_if_error: true
50+
verbose: true

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/vendor/
22
/bin/.phpunit.result.cache
3+
.phpunit.cache/
34
.phpunit.result.cache
45
.idea/
56
composer.lock

.php-version

Lines changed: 0 additions & 1 deletion
This file was deleted.

README.md

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[![CI](https://github.com/optiosteam/payconiq-client-php/actions/workflows/tests.yaml/badge.svg?branch=main)](https://github.com/optiosteam/payconiq-client-php/actions/workflows/tests.yaml)
22
[![codecov](https://codecov.io/gh/optiosteam/payconiq-client-php/branch/main/graph/badge.svg?token=S62YDUXV7A)](https://codecov.io/gh/optiosteam/payconiq-client-php)
33

4-
# PHP Payconiq API Client (unofficial)
4+
# PHP Payconiq/Wero/Bancontact API Client (unofficial)
55

66
Supported API version: v3
77

@@ -26,12 +26,23 @@ Not supported yet:
2626

2727
## Installation
2828

29-
**Requirement**: PHP version >=7.2
29+
**Requirement**: PHP version >=8.2
3030

3131
```
3232
composer require optiosteam/payconiq-client-php
3333
```
3434

35+
## Migrating from 1.x to 2.x: Migration Payconiq > WERO/Bancontact
36+
On `2025-09-21 03:00:00 CET` the endpoints will be updated automatically to use the new endpoints according to https://docs.payconiq.be/guides/general/preprod072025v4
37+
38+
The code has been updated for PHP 8 (constructor property promotion, enums, immutable with `readonly`, ...)
39+
40+
All resources (`Payment`, `Creditor`, `Debtor`, `SearchResult`) are now immutable.
41+
42+
**So if you are migrating your code from 1.x to 2.x, make sure to use the enums for PaymentStatus, QR code size, color & format, instead of the old constants**
43+
44+
Setters on resources no longer exist.
45+
3546
## Description
3647
This library provides 3 main classes:
3748
- `PayconiqApiClient`
@@ -157,16 +168,19 @@ var_dump($payconiqCallbackSignatureVerifier->loadAndVerifyJWS($signature, $paylo
157168

158169
### QR link generation
159170
```php
171+
use Optios\Payconiq\Enum\QrImageColor;
172+
use Optios\Payconiq\Enum\QrImageFormat;
173+
use Optios\Payconiq\Enum\QrImageSize;
160174
use Optios\Payconiq\PayconiqQrCodeGenerator;
161175

162176
//Example 1: customized QR code (defaults are PNG, SMALL, MAGENTO)
163177
//e.g. coming from Optios\Payconiq\Resource\Payment\Payment->getQrLink()
164178
$qrLink = 'https://portal.payconiq.com/qrcode?c=https%3A%2F%2Fpayconiq.com%2Fpay%2F2%2F73a222xxxxxxxxx00964';
165179
$customizedQRLink = PayconiqQrCodeGenerator::customizePaymentQrLink(
166180
$qrLink,
167-
PayconiqQrCodeGenerator::FORMAT_PNG,
168-
PayconiqQrCodeGenerator::SIZE_EXTRA_LARGE,
169-
PayconiqQrCodeGenerator::COLOR_BLACK
181+
QrImageFormat::PNG,
182+
QrImageSize::EXTRA_LARGE,
183+
QrImageColor::BLACK,
170184
);
171185
var_dump($customizedQRLink);
172186

codecov.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
codecov:
2+
require_ci_to_pass: yes
3+
4+
coverage:
5+
status:
6+
project:
7+
default:
8+
target: 90%
9+
threshold: 2%
10+
informational: false
11+
patch:
12+
default:
13+
target: 90%
14+
threshold: 2%
15+
informational: false
16+
17+
ignore:
18+
- "vendor/**"
19+
- "examples/**"
20+
- "build/**"
21+
- "coverage/**"
22+
- "tests/**/Fixtures/**"

composer.json

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,21 @@
1919
}
2020
],
2121
"require": {
22-
"php": ">=7.2|>=8.0",
22+
"php": ">=8.2",
2323
"composer/ca-bundle": "^1.1",
2424
"ext-json": "*",
25-
"guzzlehttp/guzzle": "^6.0|^7.0",
26-
"league/url": "^3.3",
27-
"nesbot/carbon": "^2.41",
28-
"symfony/cache": "^3.4|^4.0|^5.0|^6.0",
29-
"web-token/jwt-checker": "^2.2",
30-
"web-token/jwt-signature": "^2.2",
31-
"web-token/jwt-signature-algorithm-ecdsa": "^2.2"
25+
"guzzlehttp/guzzle": "^7.5",
26+
"nesbot/carbon": "^3.0",
27+
"symfony/cache": "^5.4|^6.0|^7.0",
28+
"web-token/jwt-library": "^4.0",
29+
"league/uri": "^7.5",
30+
"league/uri-components": "^7.5",
31+
"phpseclib/phpseclib": "^3.0"
32+
},
33+
"conflict": {
34+
"web-token/jwt-checker": "*",
35+
"web-token/jwt-signature": "*",
36+
"web-token/jwt-signature-algorithm-ecdsa": "*"
3237
},
3338
"autoload": {
3439
"psr-4": {
@@ -43,7 +48,7 @@
4348
"require-dev": {
4449
"squizlabs/php_codesniffer": "^3.5",
4550
"phpmd/phpmd": "^2.9",
46-
"phpunit/phpunit": "^8.5",
47-
"spatie/phpunit-snapshot-assertions": "3.0|4.2.15"
51+
"phpunit/phpunit": "^11.2",
52+
"spatie/phpunit-snapshot-assertions": "^5.0"
4853
}
4954
}

examples/QRCodeGeneratorExample.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77

88
require_once __DIR__ . "../vendor/autoload.php";
99

10+
use Optios\Payconiq\Enum\QrImageColor;
11+
use Optios\Payconiq\Enum\QrImageFormat;
12+
use Optios\Payconiq\Enum\QrImageSize;
1013
use Optios\Payconiq\PayconiqQrCodeGenerator;
1114

1215
//Example 1: customized QR code (defaults are PNG, SMALL, MAGENTO)
@@ -15,9 +18,9 @@
1518
$qrLink = 'https://portal.payconiq.com/qrcode?c=https%3A%2F%2Fpayconiq.com%2Fpay%2F2%2F73a222xxxxxxxxx00964';
1619
$customizedQRLink = PayconiqQrCodeGenerator::customizePaymentQrLink(
1720
$qrLink,
18-
PayconiqQrCodeGenerator::FORMAT_PNG,
19-
PayconiqQrCodeGenerator::SIZE_EXTRA_LARGE,
20-
PayconiqQrCodeGenerator::COLOR_BLACK
21+
QrImageFormat::PNG,
22+
QrImageSize::EXTRA_LARGE,
23+
QrImageColor::BLACK,
2124
);
2225
var_dump($customizedQRLink);
2326

phpcs.xml

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<ruleset name="pcsg-generated-ruleset">
3-
<description>Created with the PHP Coding Standard Generator. http://edorian.github.com/php-coding-standard-generator/
4-
</description>
2+
<ruleset name="Project Standard">
3+
<description>PSR-12 + focused Generic/Squiz rules</description>
4+
5+
<file>src</file>
6+
<file>tests</file>
7+
8+
<rule ref="PSR12"/>
59
<rule ref="Generic.Classes.DuplicateClassName"/>
610
<rule ref="Generic.CodeAnalysis.ForLoopShouldBeWhileLoop"/>
711
<rule ref="Generic.CodeAnalysis.ForLoopWithTestFunctionCall"/>
@@ -19,11 +23,6 @@
1923
</properties>
2024
</rule>
2125
<rule ref="Generic.Formatting.DisallowMultipleStatements"/>
22-
<rule ref="Generic.Formatting.MultipleStatementAlignment">
23-
<properties>
24-
<property name="ignoreMultiLine" value="true"/>
25-
</properties>
26-
</rule>
2726
<rule ref="Generic.Formatting.SpaceAfterCast"/>
2827
<rule ref="Generic.Metrics.CyclomaticComplexity"/>
2928
<rule ref="Generic.Metrics.NestingLevel">
@@ -40,22 +39,6 @@
4039
<rule ref="Generic.Strings.UnnecessaryStringConcat"/>
4140
<rule ref="Generic.WhiteSpace.DisallowTabIndent"/>
4241
<rule ref="Generic.WhiteSpace.ScopeIndent"/>
43-
<rule ref="MySource.PHP.EvalObjectFactory"/>
44-
<rule ref="PEAR.Commenting.InlineComment"/>
45-
<rule ref="PEAR.ControlStructures.ControlSignature"/>
46-
<rule ref="PEAR.NamingConventions.ValidClassName"/>
47-
<rule ref="PEAR.WhiteSpace.ObjectOperatorIndent"/>
48-
<rule ref="PEAR.WhiteSpace.ScopeClosingBrace"/>
49-
<rule ref="PSR1.Classes.ClassDeclaration"/>
50-
<rule ref="PSR1.Files.SideEffects"/>
51-
<rule ref="PSR2.Classes.ClassDeclaration"/>
52-
<rule ref="PSR2.Classes.PropertyDeclaration"/>
53-
<rule ref="PSR2.ControlStructures.ElseIfDeclaration"/>
54-
<rule ref="PSR2.ControlStructures.SwitchDeclaration"/>
55-
<rule ref="PSR2.Files.EndFileNewline"/>
56-
<rule ref="PSR2.Methods.MethodDeclaration"/>
57-
<rule ref="PSR2.Namespaces.NamespaceDeclaration"/>
58-
<rule ref="PSR2.Namespaces.UseDeclaration"/>
5942
<rule ref="Squiz.PHP.DisallowMultipleAssignments"/>
6043
<rule ref="Squiz.PHP.DisallowSizeFunctionsInLoops"/>
6144
<rule ref="Squiz.PHP.Eval"/>

phpmd.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
</rule>
2020
<rule ref="rulesets/naming.xml/ShortVariable">
2121
<properties>
22-
<property name="minimum" value="2"/>
22+
<property name="minimum" value="1"/>
2323
<property name="exceptions" value="id,e" />
2424
</properties>
2525
</rule>

phpunit.xml.dist

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!-- https://phpunit.readthedocs.io/en/latest/configuration.html -->
3-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/8.5/phpunit.xsd" backupGlobals="false" colors="true">
5-
<filter>
6-
<whitelist processUncoveredFilesFromWhitelist="true">
7-
<directory suffix=".php">src</directory>
8-
</whitelist>
9-
</filter>
10-
<php>
11-
<ini name="error_reporting" value="-1"/>
12-
<server name="APP_ENV" value="test" force="true"/>
13-
<server name="SHELL_VERBOSITY" value="-1"/>
14-
</php>
15-
<testsuites>
16-
<testsuite name="unit-tests">
17-
<directory>tests</directory>
18-
</testsuite>
19-
</testsuites>
20-
</phpunit>
3+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.5/phpunit.xsd" backupGlobals="false" colors="true" cacheDirectory=".phpunit.cache">
4+
<php>
5+
<ini name="error_reporting" value="-1"/>
6+
<server name="APP_ENV" value="test" force="true"/>
7+
<server name="SHELL_VERBOSITY" value="-1"/>
8+
</php>
9+
<testsuites>
10+
<testsuite name="unit-tests">
11+
<directory>tests</directory>
12+
</testsuite>
13+
</testsuites>
14+
<source>
15+
<include>
16+
<directory suffix=".php">src</directory>
17+
</include>
18+
</source>
19+
</phpunit>

0 commit comments

Comments
 (0)