Skip to content

Commit ae6be46

Browse files
[UAS-SCOUT] Add paymentBrandID to BluemConfiguration and update constructor type hints
- Introduced a new property `paymentBrandID` in `BluemConfiguration` for better configuration management. - Updated constructor type hints in `BluemRequest` and `PaymentStatusBluemRequest` to use `BluemConfiguration` explicitly. - Enhanced error handling in `BluemResponse` and `BluemConfigurationValidator` for improved clarity. This change aims to streamline the configuration process and enhance type safety across the Bluem integration.
1 parent 671a800 commit ae6be46

8 files changed

Lines changed: 42 additions & 13 deletions

File tree

src/Bluem.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,9 @@ public function CreateMandateID(string $order_id, string $customer_id): string
209209
* @throws DOMException
210210
* @throws Exception
211211
*/
212-
public function PerformRequest(BluemRequestInterface $transaction_request): ErrorBluemResponse|IBANNameCheckBluemResponse|IdentityStatusBluemResponse|IdentityTransactionBluemResponse|MandateStatusBluemResponse|MandateTransactionBluemResponse|PaymentStatusBluemResponse|PaymentTransactionBluemResponse
213-
{
212+
public function PerformRequest(
213+
BluemRequestInterface $transaction_request
214+
): ErrorBluemResponse|IBANNameCheckBluemResponse|IdentityStatusBluemResponse|IdentityTransactionBluemResponse|MandateStatusBluemResponse|MandateTransactionBluemResponse|PaymentStatusBluemResponse|PaymentTransactionBluemResponse {
214215
$validator = new BluemXMLValidator();
215216
if (
216217
! $validator->validate(

src/Helpers/BluemConfiguration.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ class BluemConfiguration
5858
*/
5959
public bool $webhookDebug = false;
6060

61+
public ?string $paymentBrandID = '';
62+
6163
/**
6264
* An object containing the configuration for the Bluem integration. Can be an array or object
6365
*
@@ -75,7 +77,9 @@ public function __construct(object|array $raw)
7577
$validated = $this->validator->validate($raw);
7678

7779
if ($validated === false) {
78-
throw new InvalidBluemConfigurationException('Bluem Configuration is not valid: ' . $this->errorsAsString());
80+
throw new InvalidBluemConfigurationException(
81+
'Bluem Configuration is not valid: ' . $this->errorsAsString()
82+
);
7983
}
8084

8185
$this->environment = $validated->environment ?? self::TESTING_ENVIRONMENT;

src/Requests/BluemRequest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
namespace Bluem\BluemPHP\Requests;
1111

12+
use Bluem\BluemPHP\Bluem;
1213
use Bluem\BluemPHP\Constants;
1314
use Bluem\BluemPHP\Exceptions\InvalidBluemRequestException;
1415
use Bluem\BluemPHP\Helpers\BluemConfiguration;
@@ -118,7 +119,7 @@ class BluemRequest implements BluemRequestInterface
118119
* @throws InvalidBluemRequestException
119120
*/
120121
public function __construct(
121-
$config,
122+
BluemConfiguration $config,
122123
string $entranceCode = "",
123124
string $expectedReturn = ""
124125
) {

src/Requests/PaymentStatusBluemRequest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
namespace Bluem\BluemPHP\Requests;
1111

1212
use Bluem\BluemPHP\Contexts\PaymentsContext;
13+
use Bluem\BluemPHP\Helpers\BluemConfiguration;
1314

1415
class PaymentStatusBluemRequest extends BluemRequest
1516
{
@@ -22,7 +23,7 @@ class PaymentStatusBluemRequest extends BluemRequest
2223
protected $xmlInterfaceName = "EPaymentInterface";
2324

2425
public function __construct(
25-
$config,
26+
BluemConfiguration $config,
2627
$transactionID,
2728
$expected_return = "",
2829
$entranceCode = ""

src/Responses/BluemResponse.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ public function GetEntranceCode(): string
6060
$attrs = $this->{$this->getParentXmlElement()}->attributes();
6161

6262
if (! $attrs || ! isset($attrs['entranceCode'])) {
63-
throw new RuntimeException("An error occurred in reading the transaction response: no entrance code found.");
63+
throw new RuntimeException(
64+
"An error occurred in reading the transaction response: no entrance code found."
65+
);
6466
}
6567

6668
return $attrs['entranceCode'] . "";

src/Validators/BluemConfigurationValidator.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
use Bluem\BluemPHP\Constants;
1313
use Exception;
14+
use RuntimeException;
1415
use Throwable;
1516

1617
class BluemConfigurationValidator
@@ -136,7 +137,9 @@ private function _validateProduction_accessToken($config)
136137
private function _validateBrandID($config)
137138
{
138139
if (! isset($config->brandID)) {
139-
throw new Exception("brandID not set; please add this to your configuration when instantiating the Bluem integration");
140+
throw new RuntimeException(
141+
"brandID not set; please add this to your configuration when instantiating the Bluem integration"
142+
);
140143
}
141144

142145
return $config;

src/Validators/WebhookSignatureValidation.php

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,19 +73,35 @@ private function getKeyFileName(): string
7373
$prefix = 'webhook_bluem_nl_';
7474

7575
// 2025 certificate on production from July 18th, 8:30 CET time
76-
if ($this->env === BLUEM_ENVIRONMENT_PRODUCTION && ( ( $current_date === "2025-07-18" && $current_time >= "08:30" ) || $current_date > "2025-07-18")) {
76+
if (
77+
$this->env === BLUEM_ENVIRONMENT_PRODUCTION && (
78+
( $current_date === "2025-07-18" && $current_time >= "08:30" )
79+
|| $current_date > "2025-07-18")
80+
) {
7781
$timestamp = '20250717';
7882
// 2025 certificate on testing & acceptance from July 17th, 8:30 CET time
7983
} elseif (
8084
($this->env === BLUEM_ENVIRONMENT_TESTING || $this->env === BLUEM_ENVIRONMENT_ACCEPTANCE)
81-
&& (($current_date === "2024-07-17" && $current_time >= "06:30") || $current_date > "2024-07-17")
85+
&& (($current_date === "2024-07-17"
86+
&& $current_time >= "06:30") || $current_date > "2024-07-17")
8287
) {
8388
$timestamp = '20250717';
84-
} elseif (( $current_date === "2024-07-01" && $current_time >= "12:00" ) || $current_date > "2024-07-01") {
89+
} elseif (
90+
( $current_date === "2024-07-01" && $current_time >= "12:00" )
91+
|| $current_date > "2024-07-01"
92+
) {
8593
$timestamp = '20240701';
86-
} elseif ($this->env === BLUEM_ENVIRONMENT_TESTING && ( ( $current_date === "2023-06-28" && $current_time >= "08:00" ) || $current_date > "2023-06-28")) {
94+
} elseif (
95+
$this->env === BLUEM_ENVIRONMENT_TESTING
96+
&& ( ( $current_date === "2023-06-28" && $current_time >= "08:00" )
97+
|| $current_date > "2023-06-28")
98+
) {
8799
$timestamp = '202306140200-202407050159';
88-
} elseif ($this->env === BLUEM_ENVIRONMENT_PRODUCTION && ( ( $current_date === "2023-07-04" && $current_time >= "08:00" ) || $current_date > "2023-07-04")) {
100+
} elseif (
101+
$this->env === BLUEM_ENVIRONMENT_PRODUCTION
102+
&& ( ( $current_date === "2023-07-04" && $current_time >= "08:00" )
103+
|| $current_date > "2023-07-04")
104+
) {
89105
$timestamp = '202306140200-202407050159';
90106
} else {
91107
$timestamp = '202206090200-202307110159';

tests/Unit/IbanResponseTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ public function testIbanResponseKnownResultExposesAllFields(): void
1212
{
1313
$xml = <<<'XML'
1414
<?xml version="1.0" encoding="UTF-8"?>
15-
<IBANCheckInterface createDateTime="2026-04-05T00:00:00Z" messageCount="1" mode="direct" senderID="S001" type="TransactionRequest" version="1.0">
15+
<IBANCheckInterface createDateTime="2026-04-05T00:00:00Z"
16+
messageCount="1" mode="direct" senderID="S001" type="TransactionRequest" version="1.0">
1617
<IBANCheckTransactionResponse entranceCode="20260405095326910">
1718
<IBANCheckResult>
1819
<IBANResult>KNOWN</IBANResult>

0 commit comments

Comments
 (0)