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..58250ef 100644 --- a/src/Entity/Request/PaymentCreateRequest.php +++ b/src/Entity/Request/PaymentCreateRequest.php @@ -72,8 +72,19 @@ 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'; + } 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 d2c0f85..31b3ac9 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' => 'false', - 'enableApplePayGooglePay' => 'true', '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,7 +113,7 @@ protected function getPaymentScenarios(){ 'url_paid' => '', 'url_cancelled' => '', 'url_pending' => '', - 'chargeUnregulatedCardFees' => 'false', + 'chargeUnregulatedCardFees' => 'true', 'enableApplePayGooglePay' => 'true', 'country' => '', 'curr' => '', 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);