From 833020ab35d9241cbf4565e8dd3bb203ea5c8191 Mon Sep 17 00:00:00 2001 From: SimonZanta Date: Thu, 16 Apr 2026 12:36:41 +0200 Subject: [PATCH 1/3] - three state boolean for some params --- src/Entity/Payment.php | 12 ++++++------ src/Entity/Request/PaymentCreateRequest.php | 9 +++++++-- .../Entity/Request/PaymentCreateRequestCest.php | 8 ++++---- tests/Unit/Entity/PaymentCest.php | 4 ++-- 4 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/Entity/Payment.php b/src/Entity/Payment.php index 9a96cb3..97ff200 100644 --- a/src/Entity/Payment.php +++ b/src/Entity/Payment.php @@ -44,8 +44,8 @@ class Payment 'url_paid' => '', 'url_cancelled' => '', 'url_pending' => '', - 'chargeUnregulatedCardFees' => false, - 'enableApplePayGooglePay' => true, + 'chargeUnregulatedCardFees' => null, + 'enableApplePayGooglePay' => null, 'prepareOnly' => true, 'embedded' => false, 'allowedMethods' => [], @@ -634,9 +634,9 @@ public function setUrlPendingRedirect(string $urlPending): self return $this; } - public function getChargeUnregulatedCardFees(): bool + public function getChargeUnregulatedCardFees(): ?bool { - return $this->getParam('chargeUnregulatedCardFees'); + return $this->params['chargeUnregulatedCardFees'] ?? null; } public function setChargeUnregulatedCardFees(bool $chargeUnregulatedCardFees): self @@ -650,9 +650,9 @@ public function setChargeUnregulatedCardFees(bool $chargeUnregulatedCardFees): s * Vrací true/false/null hodnotu zapnutého Google/Apple pay. * @return null|bool */ - public function getEnableApplePayGooglePay() + public function getEnableApplePayGooglePay(): ?bool { - return $this->getParam('enableApplePayGooglePay'); + return $this->params['enableApplePayGooglePay'] ?? null; } /** diff --git a/src/Entity/Request/PaymentCreateRequest.php b/src/Entity/Request/PaymentCreateRequest.php index a5f7c3b..bb4a110 100644 --- a/src/Entity/Request/PaymentCreateRequest.php +++ b/src/Entity/Request/PaymentCreateRequest.php @@ -72,8 +72,13 @@ public function toArray(): array $output['url_paid'] = $this->payment->getUrlPaidRedirect() ?? ''; $output['url_cancelled'] = $this->payment->getUrlCancelledRedirect() ?? ''; $output['url_pending'] = $this->payment->getUrlPendingRedirect() ?? ''; - $output['chargeUnregulatedCardFees'] = $this->payment->getChargeUnregulatedCardFees() ? 'true' : 'false'; - $output['enableApplePayGooglePay'] = $this->payment->getEnableApplePayGooglePay() ? 'true' : 'false'; + if($this->payment->getChargeUnregulatedCardFees() !== null) { + $output['chargeUnregulatedCardFees'] = $this->payment->getChargeUnregulatedCardFees() ? 'true' : 'false'; + } + + if($this->payment->getEnableApplePayGooglePay() !== null) { + $output['enableApplePayGooglePay'] = $this->payment->getEnableApplePayGooglePay() ? 'true' : 'false'; + } $output['embedded'] = $this->payment->isEmbedded() ? 'true' : 'false'; return $output; diff --git a/tests/Integration/Entity/Request/PaymentCreateRequestCest.php b/tests/Integration/Entity/Request/PaymentCreateRequestCest.php index d2c0f85..295cd96 100644 --- a/tests/Integration/Entity/Request/PaymentCreateRequestCest.php +++ b/tests/Integration/Entity/Request/PaymentCreateRequestCest.php @@ -60,8 +60,8 @@ protected function getPaymentScenarios(){ 'url_paid' => '', 'url_cancelled' => '', 'url_pending' => '', - 'chargeUnregulatedCardFees' => 'false', - 'enableApplePayGooglePay' => 'true', + 'chargeUnregulatedCardFees' => null, + 'enableApplePayGooglePay' => null, 'initRecurringId' => '', ], @@ -113,8 +113,8 @@ protected function getPaymentScenarios(){ 'url_paid' => '', 'url_cancelled' => '', 'url_pending' => '', - 'chargeUnregulatedCardFees' => 'false', - 'enableApplePayGooglePay' => 'true', + 'chargeUnregulatedCardFees' => null, + 'enableApplePayGooglePay' => null, 'country' => '', 'curr' => '', 'label' => '', diff --git a/tests/Unit/Entity/PaymentCest.php b/tests/Unit/Entity/PaymentCest.php index b4ff48e..275efbb 100644 --- a/tests/Unit/Entity/PaymentCest.php +++ b/tests/Unit/Entity/PaymentCest.php @@ -70,8 +70,8 @@ public function getParamsTest(UnitTester $I) 'url_paid' => '', 'url_cancelled' => '', 'url_pending' => '', - 'chargeUnregulatedCardFees' => false, - 'enableApplePayGooglePay' => true, + 'chargeUnregulatedCardFees' => null, + 'enableApplePayGooglePay' => null, 'initRecurringId' => '', ], $paymentParams); From 3cf7f11beaa2a9db28b9a673b88bb1348ec3c7f7 Mon Sep 17 00:00:00 2001 From: SimonZanta Date: Thu, 16 Apr 2026 12:44:22 +0200 Subject: [PATCH 2/3] unset variable --- src/Entity/Request/PaymentCreateRequest.php | 6 ++++++ .../Entity/Request/PaymentCreateRequestCest.php | 8 ++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Entity/Request/PaymentCreateRequest.php b/src/Entity/Request/PaymentCreateRequest.php index bb4a110..58250ef 100644 --- a/src/Entity/Request/PaymentCreateRequest.php +++ b/src/Entity/Request/PaymentCreateRequest.php @@ -72,13 +72,19 @@ public function toArray(): array $output['url_paid'] = $this->payment->getUrlPaidRedirect() ?? ''; $output['url_cancelled'] = $this->payment->getUrlCancelledRedirect() ?? ''; $output['url_pending'] = $this->payment->getUrlPendingRedirect() ?? ''; + if($this->payment->getChargeUnregulatedCardFees() !== null) { $output['chargeUnregulatedCardFees'] = $this->payment->getChargeUnregulatedCardFees() ? 'true' : 'false'; + } else { + unset($output['chargeUnregulatedCardFees']); } if($this->payment->getEnableApplePayGooglePay() !== null) { $output['enableApplePayGooglePay'] = $this->payment->getEnableApplePayGooglePay() ? 'true' : 'false'; + } else { + unset($output['enableApplePayGooglePay']); } + $output['embedded'] = $this->payment->isEmbedded() ? 'true' : 'false'; return $output; diff --git a/tests/Integration/Entity/Request/PaymentCreateRequestCest.php b/tests/Integration/Entity/Request/PaymentCreateRequestCest.php index 295cd96..5b690c1 100644 --- a/tests/Integration/Entity/Request/PaymentCreateRequestCest.php +++ b/tests/Integration/Entity/Request/PaymentCreateRequestCest.php @@ -60,8 +60,6 @@ protected function getPaymentScenarios(){ 'url_paid' => '', 'url_cancelled' => '', 'url_pending' => '', - 'chargeUnregulatedCardFees' => null, - 'enableApplePayGooglePay' => null, 'initRecurringId' => '', ], @@ -81,6 +79,8 @@ protected function getPaymentScenarios(){ ->setUrlPaid('https://example.com/paid') ->setUrlPending('https://example.com/pending') ->setUrlCancelled('https://example.com/cancelled') + ->setEnableApplePayGooglePay(true) + ->setChargeUnregulatedCardFees(true) , 'result' => [ 'initRecurring' => 'true', @@ -113,8 +113,8 @@ protected function getPaymentScenarios(){ 'url_paid' => '', 'url_cancelled' => '', 'url_pending' => '', - 'chargeUnregulatedCardFees' => null, - 'enableApplePayGooglePay' => null, + 'chargeUnregulatedCardFees' => true, + 'enableApplePayGooglePay' => true, 'country' => '', 'curr' => '', 'label' => '', From 528dc3b28e21a0e4d0ed67e762422e4f33acb35c Mon Sep 17 00:00:00 2001 From: SimonZanta Date: Thu, 16 Apr 2026 12:47:30 +0200 Subject: [PATCH 3/3] fix: correct test expectations for boolean params to use string 'true'/'false' chargeUnregulatedCardFees and enableApplePayGooglePay are serialized as strings 'true'/'false' in toArray(), not PHP booleans. Update test expectations to match actual output type. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- tests/Integration/Entity/Request/PaymentCreateRequestCest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Integration/Entity/Request/PaymentCreateRequestCest.php b/tests/Integration/Entity/Request/PaymentCreateRequestCest.php index 5b690c1..31b3ac9 100644 --- a/tests/Integration/Entity/Request/PaymentCreateRequestCest.php +++ b/tests/Integration/Entity/Request/PaymentCreateRequestCest.php @@ -113,8 +113,8 @@ protected function getPaymentScenarios(){ 'url_paid' => '', 'url_cancelled' => '', 'url_pending' => '', - 'chargeUnregulatedCardFees' => true, - 'enableApplePayGooglePay' => true, + 'chargeUnregulatedCardFees' => 'true', + 'enableApplePayGooglePay' => 'true', 'country' => '', 'curr' => '', 'label' => '',