Skip to content

Commit cc41483

Browse files
author
Simon
committed
Post migration cleanup
1 parent 2de895f commit cc41483

21 files changed

Lines changed: 60 additions & 967 deletions

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ composer require optiosteam/payconiq-client-php
3333
```
3434

3535
## Migrating from 1.x to 2.x: Migration Payconiq > WERO/Bancontact
36-
On `2025-09-21 05:50:00 CET` the endpoints will be updated automatically to use the new endpoints according to https://docs.payconiq.be/guides/general/preprod072025v4
37-
3836
The code has been updated for PHP 8 (constructor property promotion, enums, immutable with `readonly`, ...)
3937

4038
All resources (`Payment`, `Creditor`, `Debtor`, `SearchResult`) are now immutable.

src/MigrationHelper.php

Lines changed: 0 additions & 27 deletions
This file was deleted.

src/PayconiqApiClient.php

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -21,36 +21,21 @@ class PayconiqApiClient
2121
{
2222
public const API_VERSION = 'v3';
2323

24-
// Legacy endpoints
25-
public const API_ENDPOINT_PRODUCTION_LEGACY = 'https://api.payconiq.com/';
26-
public const API_ENDPOINT_STAGING_LEGACY = 'https://api.ext.payconiq.com/';
27-
28-
// New endpoints
29-
public const API_ENDPOINT_PRODUCTION_NEW = 'https://merchant.api.bancontact.net/';
30-
public const API_ENDPOINT_STAGING_NEW = 'https://merchant.api.preprod.bancontact.net/';
24+
public const API_ENDPOINT_PRODUCTION = 'https://merchant.api.bancontact.net/';
25+
public const API_ENDPOINT_STAGING = 'https://merchant.api.preprod.bancontact.net/';
3126

3227
private const TIMEOUT = 10;
3328
private const CONNECT_TIMEOUT = 2;
3429

3530
private string $apiKey;
3631
private ClientInterface $httpClient;
3732
private bool $useProd;
38-
private bool $useNewPreProductionEnv; // only used for the new pre-production testing
3933

4034
public function __construct(
4135
string $apiKey,
4236
?ClientInterface $httpClient = null,
4337
bool $useProd = true,
44-
bool $useNewPreProductionEnv = false,
4538
) {
46-
if (
47-
true === $useProd
48-
&& true === $useNewPreProductionEnv
49-
&& false === MigrationHelper::switchToNewEndpoints()
50-
) {
51-
throw new \InvalidArgumentException('You can not use the new pre production env in production mode yet');
52-
}
53-
5439
if (null === $httpClient) {
5540
$httpClient = new Client([
5641
RequestOptions::TIMEOUT => self::TIMEOUT,
@@ -62,7 +47,6 @@ public function __construct(
6247
$this->apiKey = $apiKey;
6348
$this->httpClient = $httpClient;
6449
$this->useProd = $useProd;
65-
$this->useNewPreProductionEnv = $useNewPreProductionEnv;
6650
}
6751

6852
public function getApiEndpointBase(): string
@@ -72,13 +56,7 @@ public function getApiEndpointBase(): string
7256

7357
private function getEndpoint(): string
7458
{
75-
if (true === $this->useNewPreProductionEnv || true === MigrationHelper::switchToNewEndpoints()) {
76-
// new endpoints
77-
return ($this->useProd ? self::API_ENDPOINT_PRODUCTION_NEW : self::API_ENDPOINT_STAGING_NEW);
78-
}
79-
80-
// legacy endpoints
81-
return ($this->useProd ? self::API_ENDPOINT_PRODUCTION_LEGACY : self::API_ENDPOINT_STAGING_LEGACY);
59+
return $this->useProd ? self::API_ENDPOINT_PRODUCTION : self::API_ENDPOINT_STAGING;
8260
}
8361

8462
/**

src/PayconiqCallbackSignatureVerifier.php

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -37,38 +37,23 @@
3737
*/
3838
class PayconiqCallbackSignatureVerifier
3939
{
40-
// Legacy endpoints
41-
public const CERTIFICATES_PRODUCTION_URL_LEGACY = 'https://payconiq.com/certificates';
42-
public const CERTIFICATES_STAGING_URL_LEGACY = 'https://ext.payconiq.com/certificates';
43-
44-
// New endpoints
45-
public const CERTIFICATES_PRODUCTION_URL_NEW = 'https://jwks.bancontact.net';
46-
public const CERTIFICATES_STAGING_URL_NEW = 'https://jwks.preprod.bancontact.net';
40+
public const CERTIFICATES_PRODUCTION_URL = 'https://jwks.bancontact.net';
41+
public const CERTIFICATES_STAGING_URL = 'https://jwks.preprod.bancontact.net';
4742

4843
private const TIMEOUT = 10;
4944
private const CONNECT_TIMEOUT = 2;
5045

5146
private ClientInterface $httpClient;
5247
private AdapterInterface $cache;
5348
private bool $useProd;
54-
private bool $useNewPreProductionEnv; // only used for the new pre-production testing
5549
private JWSLoader $jwsLoader;
5650

5751
public function __construct(
5852
string $paymentProfileId,
5953
ClientInterface $httpClient = null,
6054
AdapterInterface $cache = null,
6155
bool $useProd = true,
62-
bool $useNewPreProductionEnv = false,
6356
) {
64-
if (
65-
true === $useProd
66-
&& true === $useNewPreProductionEnv
67-
&& false === MigrationHelper::switchToNewEndpoints()
68-
) {
69-
throw new \InvalidArgumentException('You can not use the new pre production env in production mode yet');
70-
}
71-
7257
if (null === $httpClient) {
7358
$httpClient = new Client([
7459
RequestOptions::TIMEOUT => self::TIMEOUT,
@@ -83,20 +68,13 @@ public function __construct(
8368
$this->httpClient = $httpClient;
8469
$this->cache = $cache;
8570
$this->useProd = $useProd;
86-
$this->useNewPreProductionEnv = $useNewPreProductionEnv;
8771

8872
$this->jwsLoader = $this->initializeJwsLoader($paymentProfileId);
8973
}
9074

9175
private function getCertificatesUrl(): string
9276
{
93-
if (true === $this->useNewPreProductionEnv || true === MigrationHelper::switchToNewEndpoints()) {
94-
// new endpoints
95-
return ($this->useProd ? self::CERTIFICATES_PRODUCTION_URL_NEW : self::CERTIFICATES_STAGING_URL_NEW);
96-
}
97-
98-
// legacy endpoints
99-
return ($this->useProd ? self::CERTIFICATES_PRODUCTION_URL_LEGACY : self::CERTIFICATES_STAGING_URL_LEGACY);
77+
return $this->useProd ? self::CERTIFICATES_PRODUCTION_URL : self::CERTIFICATES_STAGING_URL;
10078
}
10179

10280
public function isValid(string $token, ?string $payload = null, ?int $signature = 0): bool
@@ -185,12 +163,12 @@ private static function normalizeEcdsaSigIfNeeded(string $compactJws, int $partL
185163

186164
// Try DER → raw using phpseclib helpers
187165
try {
188-
$rs = EcdsaAsn1::load($sig); // ['r'=>BigInteger,'s'=>BigInteger]
166+
$rs = EcdsaAsn1::load($sig); // ['r'=>BigInteger,'s'=>BigInteger]
189167
$raw = EcdsaP1363::save($rs['r'], $rs['s'], null, $partLen); // fixed-length P-1363
190168
$sB64u = rtrim(strtr(base64_encode($raw), '+/', '-_'), '=');
191169
return "$h.$p.$sB64u";
192170
} catch (\Throwable) {
193-
// Not DER / not parseable leave as-is and let the verifier decide
171+
// Not DER / not parseable - leave as-is and let the verifier decide
194172
return $compactJws;
195173
}
196174
}

src/PayconiqQrCodeGenerator.php

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,11 @@
1212

1313
class PayconiqQrCodeGenerator
1414
{
15-
public const PORTAL_URL_LEGACY = 'https://portal.payconiq.com/qrcode';
16-
public const PORTAL_URL_NEW = 'https://qrcodegenerator.api.bancontact.net/qrcode';
15+
public const QRCODE_GENERATOR_URL = 'https://qrcodegenerator.api.bancontact.net/qrcode';
1716

1817
public const LOCATION_URL_SCHEME_STATIC = 'https://payconiq.com/l/1/';
1918
public const LOCATION_URL_SCHEME_METADATA = 'https://payconiq.com/t/1/';
2019

21-
private static function getEndpoint(bool $useNewPreProductionEnv = false): string
22-
{
23-
if (true === $useNewPreProductionEnv || true === MigrationHelper::switchToNewEndpoints()) {
24-
// new endpoints
25-
return self::PORTAL_URL_NEW;
26-
}
27-
28-
// legacy endpoints
29-
return self::PORTAL_URL_LEGACY;
30-
}
31-
3220
/**
3321
* Used for customizing QR links returned in the Payment.
3422
* Optios\Payconiq\Resource\Payment\Payment->getQrLink()
@@ -63,11 +51,10 @@ public static function generateStaticQRCodeLink(
6351
QrImageFormat $format = QrImageFormat::PNG,
6452
QrImageSize $size = QrImageSize::SMALL,
6553
QrImageColor $color = QrImageColor::MAGENTA,
66-
bool $useNewPreProductionEnv = false,
6754
): string {
6855
$urlPayload = self::LOCATION_URL_SCHEME_STATIC . $paymentProfileId . '/' . $posId;
6956

70-
$uri = Modifier::from(Http::new(self::getEndpoint($useNewPreProductionEnv)))
57+
$uri = Modifier::from(Http::new(self::QRCODE_GENERATOR_URL))
7158
->mergeQueryParameters(['c' => $urlPayload])
7259
->getUri();
7360

@@ -90,7 +77,6 @@ public static function generateQRCodeWithMetadata(
9077
QrImageFormat $format = QrImageFormat::PNG,
9178
QrImageSize $size = QrImageSize::SMALL,
9279
QrImageColor $color = QrImageColor::MAGENTA,
93-
bool $useNewPreProductionEnv = false,
9480
): string {
9581
$payloadUri = Http::new(self::LOCATION_URL_SCHEME_METADATA . $paymentProfileId);
9682

@@ -123,7 +109,7 @@ public static function generateQRCodeWithMetadata(
123109
$payloadUri = Modifier::from($payloadUri)->mergeQueryParameters($query)->getUri();
124110
}
125111

126-
$uri = Modifier::from(Http::new(self::getEndpoint($useNewPreProductionEnv)))
112+
$uri = Modifier::from(Http::new(self::QRCODE_GENERATOR_URL))
127113
->mergeQueryParameters(['c' => (string) $payloadUri])
128114
->getUri();
129115

0 commit comments

Comments
 (0)