Skip to content

Commit 9a7d9d2

Browse files
committed
Update based on feedback: removed duplicated code, improved comment with copyright, added more constants
1 parent 4dd9dc2 commit 9a7d9d2

55 files changed

Lines changed: 142 additions & 155 deletions

Some content is hidden

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

src/Bluem.php

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22

33
/**
4-
* © 2026 - Bluem Plugin Support <pluginsupport@bluem.nl>
4+
* © 2026 - Bluem Payment & Identity: https://bluem.nl
55
*
66
* This source file is subject to the license that is bundled
77
* with this source code in the file LICENSE.
@@ -177,8 +177,8 @@ public function CreateMandateRequest(
177177
$order_id,
178178
$mandate_id,
179179
($this->configuration->environment === "test" &&
180-
$this->configuration->expectedReturnStatus !== null ?
181-
$this->configuration->expectedReturnStatus : "")
180+
$this->configuration->expectedReturnStatus !== null ?
181+
$this->configuration->expectedReturnStatus : "")
182182
);
183183
}
184184

@@ -220,10 +220,10 @@ public function PerformRequest(
220220
) {
221221
return new ErrorBluemResponse(
222222
"Error: Request is not formed correctly. More details: " .
223-
implode(
224-
';<BR>' . PHP_EOL,
225-
$validator->errorDetails
226-
)
223+
implode(
224+
';<BR>' . PHP_EOL,
225+
$validator->errorDetails
226+
)
227227
);
228228
}
229229

@@ -283,7 +283,7 @@ public function PerformRequest(
283283
} catch (Throwable $th) {
284284
return new ErrorBluemResponse(
285285
"Error: Could not create Bluem Response object. More details: " .
286-
$th->getMessage()
286+
$th->getMessage()
287287
);
288288
}
289289

@@ -331,7 +331,7 @@ private function extractErrorMessage(SimpleXMLElement $xml, string $transactionC
331331
return '';
332332
}
333333

334-
return (string) $xml->{$errorNodeName}->Error->ErrorMessage;
334+
return (string) $xml->{$errorNodeName}->Error->ErrorMessage;
335335
}
336336

337337
/**
@@ -372,8 +372,8 @@ public function MandateStatus($mandateID, $entranceCode): BluemResponseInterface
372372
$this->configuration,
373373
$mandateID,
374374
$entranceCode,
375-
($this->configuration->environment === BLUEM_ENVIRONMENT_TESTING &&
376-
$this->configuration->expectedReturnStatus !== null ?
375+
($this->configuration->environment === Constants::TESTING_ENVIRONMENT &&
376+
$this->configuration->expectedReturnStatus !== null ?
377377
$this->configuration->expectedReturnStatus : "")
378378
);
379379

@@ -476,9 +476,9 @@ public function CreatePaymentRequest(
476476
$currency,
477477
$this->CreatePaymentTransactionID($debtorReference),
478478
$entranceCode,
479-
($this->configuration->environment === BLUEM_ENVIRONMENT_TESTING &&
480-
$this->configuration->expectedReturnStatus !== null ?
481-
$this->configuration->expectedReturnStatus : ""),
479+
($this->configuration->environment === Constants::TESTING_ENVIRONMENT &&
480+
$this->configuration->expectedReturnStatus !== null ?
481+
$this->configuration->expectedReturnStatus : ""),
482482
$debtorReturnURL,
483483
$paymentReference
484484
);
@@ -512,7 +512,7 @@ public function PaymentStatus(
512512
$r = new PaymentStatusBluemRequest(
513513
$this->configuration,
514514
$transactionID,
515-
$this->configuration->environment === BLUEM_ENVIRONMENT_TESTING &&
515+
$this->configuration->environment === Constants::TESTING_ENVIRONMENT &&
516516
$this->configuration->expectedReturnStatus !== null ?
517517
$this->configuration->expectedReturnStatus : "",
518518
$entranceCode
@@ -544,7 +544,7 @@ public function CreateIdentityRequest(
544544
return new IdentityBluemRequest(
545545
$this->configuration,
546546
$entranceCode,
547-
$this->configuration->environment === BLUEM_ENVIRONMENT_TESTING &&
547+
$this->configuration->environment === Constants::TESTING_ENVIRONMENT &&
548548
$this->configuration->expectedReturnStatus !== null ?
549549
$this->configuration->expectedReturnStatus : "",
550550
$requestCategory,
@@ -567,7 +567,7 @@ public function IdentityStatus($transactionID, $entranceCode): ErrorBluemRespons
567567
$r = new IdentityStatusBluemRequest(
568568
$this->configuration,
569569
$entranceCode,
570-
($this->configuration->environment === BLUEM_ENVIRONMENT_TESTING &&
570+
($this->configuration->environment === Constants::TESTING_ENVIRONMENT &&
571571
$this->configuration->expectedReturnStatus !== null ?
572572
$this->configuration->expectedReturnStatus : ""),
573573
$transactionID
@@ -703,21 +703,20 @@ public function _retrieveContext($context): BluemContextInterface
703703
{
704704
$localInstrumentCode = $this->configuration->localInstrumentCode;
705705
switch ($context) {
706-
case 'Mandates':
706+
case Constants::MANDATES_CONTEXT:
707707
$context = new MandatesContext($localInstrumentCode);
708708
break;
709-
case 'Payments':
709+
case Constants::PAYMENTS_CONTEXT:
710710
$context = new PaymentsContext();
711711
break;
712-
case 'Identity':
712+
case Constants::IDENTITY_CONTEXT:
713713
$context = new IdentityContext();
714714
break;
715715
default:
716-
$contexts = ["Mandates", "Payments", "Identity"];
717716
throw new RuntimeException(
718717
"Invalid Context requested, should be
719718
one of the following: " .
720-
implode(",", $contexts)
719+
implode(",", Constants::AVAILABLE_CONTEXTS)
721720
);
722721
}
723722

src/Constants.php

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,27 @@
77
/**
88
* The version of this plug-in, to be updated upon each release
99
*/
10-
public const string PHP_PLUGIN_VERSION = '3.0.0';
10+
public const string PHP_PLUGIN_VERSION = '2.5';
1111

1212
public const string PRODUCTION_ENVIRONMENT = 'prod';
1313
public const string ACCEPTANCE_ENVIRONMENT = 'acc';
1414
public const string TESTING_ENVIRONMENT = 'test';
1515

16+
public const string MANDATES_CONTEXT = 'Mandates';
17+
public const string PAYMENTS_CONTEXT = 'Payments';
18+
public const string IDENTITY_CONTEXT = 'Identity';
19+
20+
/**
21+
* All available context values
22+
*
23+
* @var string[]
24+
*/
25+
public const array AVAILABLE_CONTEXTS = [
26+
self::MANDATES_CONTEXT,
27+
self::PAYMENTS_CONTEXT,
28+
self::IDENTITY_CONTEXT,
29+
];
30+
1631
/**
1732
* All available environment values
1833
*
@@ -30,14 +45,38 @@
3045
public const string BLUEM_STATIC_MERCHANT_ID = '0020000387';
3146

3247
/**
33-
* Possible return statuses, used by validation
48+
* No specific test return outcome requested.
3449
*/
3550
public const string EXPECTED_RETURN_NONE = 'none';
51+
52+
/**
53+
* Test flow should return a successful transaction.
54+
*/
3655
public const string EXPECTED_RETURN_SUCCESS = 'success';
56+
57+
/**
58+
* Test flow should return a cancelled transaction.
59+
*/
3760
public const string EXPECTED_RETURN_CANCELLED = 'cancelled';
61+
62+
/**
63+
* Test flow should return an expired transaction.
64+
*/
3865
public const string EXPECTED_RETURN_EXPIRED = 'expired';
66+
67+
/**
68+
* Test flow should return a failed transaction.
69+
*/
3970
public const string EXPECTED_RETURN_FAILURE = 'failure';
71+
72+
/**
73+
* Test flow should return an open transaction.
74+
*/
4075
public const string EXPECTED_RETURN_OPEN = 'open';
76+
77+
/**
78+
* Test flow should return a pending transaction.
79+
*/
4180
public const string EXPECTED_RETURN_PENDING = 'pending';
4281

4382
public const array POSSIBLE_RETURN_STATUSES = [

src/Contexts/BluemContext.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
declare(strict_types=1);
44

55
/**
6-
* © 2026 - Bluem Plugin Support <pluginsupport@bluem.nl>
6+
* © 2026 - Bluem Payment & Identity: https://bluem.nl
77
*
88
* This source file is subject to the license that is bundled
99
* with this source code in the file LICENSE.
@@ -15,9 +15,7 @@
1515

1616
abstract class BluemContext implements BluemContextInterface
1717
{
18-
public function __construct(public array $BICs = [])
19-
{
20-
}
18+
public function __construct(public array $BICs = []) {}
2119

2220
public function getBICs(): array
2321
{

src/Contexts/IBANCheckContext.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
declare(strict_types=1);
44

55
/**
6-
* © 2026 - Bluem Plugin Support <pluginsupport@bluem.nl>
6+
* © 2026 - Bluem Payment & Identity: https://bluem.nl
77
*
88
* This source file is subject to the license that is bundled
99
* with this source code in the file LICENSE.

src/Contexts/IdentityContext.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
declare(strict_types=1);
44

55
/**
6-
* © 2026 - Bluem Plugin Support <pluginsupport@bluem.nl>
6+
* © 2026 - Bluem Payment & Identity: https://bluem.nl
77
*
88
* This source file is subject to the license that is bundled
99
* with this source code in the file LICENSE.

src/Contexts/MandatesContext.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
declare(strict_types=1);
44

55
/**
6-
* © 2026 - Bluem Plugin Support <pluginsupport@bluem.nl>
6+
* © 2026 - Bluem Payment & Identity: https://bluem.nl
77
*
88
* This source file is subject to the license that is bundled
99
* with this source code in the file LICENSE.

src/Contexts/PaymentsContext.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
declare(strict_types=1);
44

55
/**
6-
* © 2026 - Bluem Plugin Support <pluginsupport@bluem.nl>
6+
* © 2026 - Bluem Payment & Identity: https://bluem.nl
77
*
88
* This source file is subject to the license that is bundled
99
* with this source code in the file LICENSE.

src/Exceptions/InvalidBluemConfigurationException.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
declare(strict_types=1);
44

55
/**
6-
* © 2026 - Bluem Plugin Support <pluginsupport@bluem.nl>
6+
* © 2026 - Bluem Payment & Identity: https://bluem.nl
77
*
88
* This source file is subject to the license that is bundled
99
* with this source code in the file LICENSE.
@@ -13,6 +13,4 @@
1313

1414
use Exception;
1515

16-
class InvalidBluemConfigurationException extends Exception
17-
{
18-
}
16+
class InvalidBluemConfigurationException extends Exception {}

src/Exceptions/InvalidBluemRequestException.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
declare(strict_types=1);
44

55
/**
6-
* © 2026 - Bluem Plugin Support <pluginsupport@bluem.nl>
6+
* © 2026 - Bluem Payment & Identity: https://bluem.nl
77
*
88
* This source file is subject to the license that is bundled
99
* with this source code in the file LICENSE.
@@ -13,6 +13,4 @@
1313

1414
use Exception;
1515

16-
class InvalidBluemRequestException extends Exception
17-
{
18-
}
16+
class InvalidBluemRequestException extends Exception {}

src/Exceptions/InvalidContextException.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,25 @@
33
declare(strict_types=1);
44

55
/**
6-
* © 2026 - Bluem Plugin Support <pluginsupport@bluem.nl>
6+
* © 2026 - Bluem Payment & Identity: https://bluem.nl
77
*
88
* This source file is subject to the license that is bundled
99
* with this source code in the file LICENSE.
1010
*/
1111

1212
namespace Bluem\BluemPHP\Exceptions;
1313

14+
use Bluem\BluemPHP\Constants;
1415
use Exception;
1516

1617
class InvalidContextException extends Exception
1718
{
18-
public const AVAILABLE_CONTEXTS = ["Mandates", "Payments", "Identity"];
19-
2019
public function __construct()
2120
{
2221
parent::__construct();
2322

2423
$this->message = "Invalid Context requested, should be
2524
one of the following: " .
26-
implode(",", self::AVAILABLE_CONTEXTS);
25+
implode(",", Constants::AVAILABLE_CONTEXTS);
2726
}
2827
}

0 commit comments

Comments
 (0)