Skip to content

Commit f53f639

Browse files
author
Simon
committed
cleanup
1 parent d67f2cb commit f53f639

36 files changed

Lines changed: 275 additions & 559 deletions

src/Exception/PayconiqApiException.php

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,28 +14,23 @@ public function __construct(
1414
$message = "",
1515
$code = 0,
1616
\Throwable $previous = null,
17-
)
18-
{
17+
) {
1918
parent::__construct($isProd, $message, $code, $previous);
2019
}
2120

22-
public function getPayconiqMessage(): ?string
23-
{
21+
public function getPayconiqMessage(): ?string {
2422
return $this->payconiqMessage;
2523
}
2624

27-
public function getPayconiqCode(): ?string
28-
{
25+
public function getPayconiqCode(): ?string {
2926
return $this->payconiqCode;
3027
}
3128

32-
public function getTraceId(): ?string
33-
{
29+
public function getTraceId(): ?string {
3430
return $this->traceId;
3531
}
3632

37-
public function getSpanId(): ?string
38-
{
33+
public function getSpanId(): ?string {
3934
return $this->spanId;
4035
}
4136
}

src/Exception/PayconiqBaseException.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,11 @@ public function __construct(
99
protected bool $useProd = true,
1010
$message = "",
1111
$code = 0, \Throwable $previous = null,
12-
)
13-
{
12+
) {
1413
parent::__construct($message, $code, $previous);
1514
}
1615

17-
public function isUseProd(): bool
18-
{
16+
public function isUseProd(): bool {
1917
return $this->useProd;
2018
}
2119
}

src/HeaderChecker/PayconiqIssChecker.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,13 @@
99
final class PayconiqIssChecker implements HeaderChecker
1010
{
1111
private const HEADER_NAME = 'https://payconiq.com/iss';
12-
1312
private const ISS_VALUE = 'Payconiq';
1413

1514
/**
1615
* {@inheritdoc}
1716
* @throws InvalidHeaderException
1817
*/
19-
public function checkHeader($value): void
20-
{
18+
public function checkHeader($value): void {
2119
if (false === is_string($value)) {
2220
throw new InvalidHeaderException(
2321
message: sprintf('"%s" must be a string.', self::HEADER_NAME),
@@ -35,13 +33,11 @@ public function checkHeader($value): void
3533
}
3634
}
3735

38-
public function supportedHeader(): string
39-
{
36+
public function supportedHeader(): string {
4037
return self::HEADER_NAME;
4138
}
4239

43-
public function protectedHeaderOnly(): bool
44-
{
40+
public function protectedHeaderOnly(): bool {
4541
return false;
4642
}
4743
}

src/HeaderChecker/PayconiqIssuedAtChecker.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,13 @@
1010
final class PayconiqIssuedAtChecker implements HeaderChecker
1111
{
1212
public const IAT_FORMAT = 'Y-m-d\TH:i:s.uO';
13-
1413
private const HEADER_NAME = 'https://payconiq.com/iat';
1514

1615
/**
1716
* {@inheritdoc}
1817
* @throws InvalidHeaderException
1918
*/
20-
public function checkHeader($value): void
21-
{
19+
public function checkHeader($value): void {
2220
try {
2321
// Payconiq unexpectedly changed their format on 2023-08-23 to include nanoseconds,
2422
// Since PHP doesn't support nanoseconds, we're "hacking" it by trimming it to microseconds
@@ -51,13 +49,11 @@ public function checkHeader($value): void
5149
}
5250
}
5351

54-
public function supportedHeader(): string
55-
{
52+
public function supportedHeader(): string {
5653
return self::HEADER_NAME;
5754
}
5855

59-
public function protectedHeaderOnly(): bool
60-
{
56+
public function protectedHeaderOnly(): bool {
6157
return false;
6258
}
6359
}

src/HeaderChecker/PayconiqJtiChecker.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ final class PayconiqJtiChecker implements HeaderChecker
1414
* {@inheritdoc}
1515
* @throws InvalidHeaderException
1616
*/
17-
public function checkHeader($value): void
18-
{
17+
public function checkHeader($value): void {
1918
if (false === is_string($value)) {
2019
throw new InvalidHeaderException(
2120
message: sprintf('"%s" must be a string.', self::HEADER_NAME),
@@ -25,13 +24,11 @@ public function checkHeader($value): void
2524
}
2625
}
2726

28-
public function supportedHeader(): string
29-
{
27+
public function supportedHeader(): string {
3028
return self::HEADER_NAME;
3129
}
3230

33-
public function protectedHeaderOnly(): bool
34-
{
31+
public function protectedHeaderOnly(): bool {
3532
return false;
3633
}
3734
}

src/HeaderChecker/PayconiqPathChecker.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ final class PayconiqPathChecker implements HeaderChecker
1414
* {@inheritdoc}
1515
* @throws InvalidHeaderException
1616
*/
17-
public function checkHeader($value): void
18-
{
17+
public function checkHeader($value): void {
1918
if (false === filter_var($value, FILTER_VALIDATE_URL)) {
2019
throw new InvalidHeaderException(
2120
message: sprintf('"%s" must be a valid url.', self::HEADER_NAME),
@@ -25,13 +24,11 @@ public function checkHeader($value): void
2524
}
2625
}
2726

28-
public function supportedHeader(): string
29-
{
27+
public function supportedHeader(): string {
3028
return self::HEADER_NAME;
3129
}
3230

33-
public function protectedHeaderOnly(): bool
34-
{
31+
public function protectedHeaderOnly(): bool {
3532
return false;
3633
}
3734
}

src/HeaderChecker/PayconiqSubChecker.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,14 @@
1616

1717
public function __construct(
1818
private string $paymentProfileId,
19-
)
20-
{
19+
) {
2120
}
2221

2322
/**
2423
* {@inheritdoc}
2524
* @throws InvalidHeaderException
2625
*/
27-
public function checkHeader($value): void
28-
{
26+
public function checkHeader($value): void {
2927
if (false === is_string($value)) {
3028
throw new InvalidHeaderException(
3129
message: sprintf('"%s" must be a string.', self::HEADER_NAME),
@@ -43,13 +41,11 @@ public function checkHeader($value): void
4341
}
4442
}
4543

46-
public function supportedHeader(): string
47-
{
44+
public function supportedHeader(): string {
4845
return self::HEADER_NAME;
4946
}
5047

51-
public function protectedHeaderOnly(): bool
52-
{
48+
public function protectedHeaderOnly(): bool {
5349
return false;
5450
}
5551
}

src/MigrationHelper.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ class MigrationHelper
1717
public const SWITCH_DATETIME = '2025-09-21 03:00:00'; // switch to new endpoints at 3AM CET (1 hour buffer)
1818
public const TIMEZONE = 'Europe/Brussels'; // CET
1919

20-
public static function switchToNewEndpoints(): bool
21-
{
20+
public static function switchToNewEndpoints(): bool {
2221
$now = CarbonImmutable::now(self::TIMEZONE);
2322
$switch = CarbonImmutable::parse(self::SWITCH_DATETIME, self::TIMEZONE);
2423

src/PayconiqApiClient.php

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ public function __construct(
4141
?ClientInterface $httpClient = null,
4242
bool $useProd = true,
4343
bool $useNewPreProductionEnv = false,
44-
)
45-
{
44+
) {
4645
if (
4746
true === $useProd
4847
&& true === $useNewPreProductionEnv
@@ -65,13 +64,11 @@ public function __construct(
6564
$this->useNewPreProductionEnv = $useNewPreProductionEnv;
6665
}
6766

68-
public function getApiEndpointBase(): string
69-
{
67+
public function getApiEndpointBase(): string {
7068
return $this->getEndpoint() . self::API_VERSION;
7169
}
7270

73-
private function getEndpoint(): string
74-
{
71+
private function getEndpoint(): string {
7572
if (true === $this->useNewPreProductionEnv || true === MigrationHelper::switchToNewEndpoints()) {
7673
// new endpoints
7774
return ($this->useProd ? self::API_ENDPOINT_PRODUCTION_NEW : self::API_ENDPOINT_STAGING_NEW);
@@ -84,8 +81,7 @@ private function getEndpoint(): string
8481
/**
8582
* @throws PayconiqApiException
8683
*/
87-
public function requestPayment(RequestPayment $requestPayment): Payment
88-
{
84+
public function requestPayment(RequestPayment $requestPayment): Payment {
8985
try {
9086
$uri = $this->getApiEndpointBase() . '/payments' . ($requestPayment->getPosId() ? '/pos' : null);
9187
$response = $this->httpClient->post(
@@ -107,8 +103,7 @@ public function requestPayment(RequestPayment $requestPayment): Payment
107103
/**
108104
* @throws PayconiqApiException
109105
*/
110-
public function getPayment(string $paymentId): Payment
111-
{
106+
public function getPayment(string $paymentId): Payment {
112107
try {
113108
$response = $this->httpClient->get(
114109
uri: $this->getApiEndpointBase() . '/payments/' . $paymentId,
@@ -128,8 +123,7 @@ public function getPayment(string $paymentId): Payment
128123
/**
129124
* @throws PayconiqApiException
130125
*/
131-
public function cancelPayment(string $paymentId): bool
132-
{
126+
public function cancelPayment(string $paymentId): bool {
133127
try {
134128
$this->httpClient->delete(
135129
uri: $this->getApiEndpointBase() . '/payments/' . $paymentId,
@@ -153,8 +147,7 @@ public function searchPayments(
153147
SearchPayments $search,
154148
int $page = 0,
155149
int $size = 50,
156-
): SearchResult
157-
{
150+
): SearchResult {
158151
try {
159152
$uri = Modifier::from(
160153
Http::new($this->getApiEndpointBase() . '/payments/search'),
@@ -184,8 +177,7 @@ public function searchPayments(
184177
/**
185178
* @throws PayconiqApiException
186179
*/
187-
public function refundPayment(string $paymentId)
188-
{
180+
public function refundPayment(string $paymentId) {
189181
try {
190182
$this->httpClient->get(
191183
uri: $this->getApiEndpointBase() . '/payments/' . $paymentId . '/debtor/refundIban',
@@ -197,18 +189,15 @@ public function refundPayment(string $paymentId)
197189
return true;
198190
}
199191

200-
public function getApiKey(): string
201-
{
192+
public function getApiKey(): string {
202193
return $this->apiKey;
203194
}
204195

205-
public function setApiKey(string $apiKey): void
206-
{
196+
public function setApiKey(string $apiKey): void {
207197
$this->apiKey = $apiKey;
208198
}
209199

210-
private function convertToPayconiqApiException(ClientException $e): PayconiqApiException
211-
{
200+
private function convertToPayconiqApiException(ClientException $e): PayconiqApiException {
212201
$contents = $e->getResponse()->getBody()->getContents() ?? null;
213202
if (empty($contents)) {
214203
return new PayconiqApiException(

src/PayconiqCallbackSignatureVerifier.php

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ public function __construct(
5757
AdapterInterface $cache = null,
5858
bool $useProd = true,
5959
bool $useNewPreProductionEnv = false,
60-
)
61-
{
60+
) {
6261
if (
6362
true === $useProd
6463
&& true === $useNewPreProductionEnv
@@ -86,8 +85,7 @@ public function __construct(
8685
$this->jwsLoader = $this->initializeJwsLoader($paymentProfileId);
8786
}
8887

89-
private function getCertificatesUrl(): string
90-
{
88+
private function getCertificatesUrl(): string {
9189
if (true === $this->useNewPreProductionEnv || true === MigrationHelper::switchToNewEndpoints()) {
9290
// new endpoints
9391
return ($this->useProd ? self::CERTIFICATES_PRODUCTION_URL_NEW : self::CERTIFICATES_STAGING_URL_NEW);
@@ -97,8 +95,7 @@ private function getCertificatesUrl(): string
9795
return ($this->useProd ? self::CERTIFICATES_PRODUCTION_URL_LEGACY : self::CERTIFICATES_STAGING_URL_LEGACY);
9896
}
9997

100-
public function isValid(string $token, ?string $payload = null, ?int $signature = 0): bool
101-
{
98+
public function isValid(string $token, ?string $payload = null, ?int $signature = 0): bool {
10299
try {
103100
$this->jwsLoader->loadAndVerifyWithKeySet($token, $this->getJWKSet(), $signature, $payload);
104101
} catch (\Throwable $e) {
@@ -111,8 +108,7 @@ public function isValid(string $token, ?string $payload = null, ?int $signature
111108
/**
112109
* @throws PayconiqCallbackSignatureVerificationException
113110
*/
114-
public function loadAndVerifyJWS(string $token, ?string $payload = null, ?int $signature = 0): JWS
115-
{
111+
public function loadAndVerifyJWS(string $token, ?string $payload = null, ?int $signature = 0): JWS {
116112
try {
117113
return $this->jwsLoader->loadAndVerifyWithKeySet($token, $this->getJWKSet(), $signature, $payload);
118114
} catch (\Throwable $e) {
@@ -128,8 +124,7 @@ public function loadAndVerifyJWS(string $token, ?string $payload = null, ?int $s
128124
/**
129125
* @throws PayconiqJWKSetException
130126
*/
131-
private function getJWKSet(): JWKSet
132-
{
127+
private function getJWKSet(): JWKSet {
133128
try {
134129
$url = $this->getCertificatesUrl();
135130

@@ -155,8 +150,7 @@ private function getJWKSet(): JWKSet
155150
}
156151
}
157152

158-
private function initializeJwsLoader(string $paymentProfileId): JWSLoader
159-
{
153+
private function initializeJwsLoader(string $paymentProfileId): JWSLoader {
160154
return new JWSLoader(
161155
new JWSSerializerManager([
162156
new CompactSerializer(),

0 commit comments

Comments
 (0)