diff --git a/src/Entity/Payment.php b/src/Entity/Payment.php index 97ff200..850d9b8 100644 --- a/src/Entity/Payment.php +++ b/src/Entity/Payment.php @@ -10,7 +10,7 @@ class Payment /** * Payment parameters. * - * @var array> + * @var array|null> */ protected $params = [ 'test' => false, @@ -636,10 +636,21 @@ public function setUrlPendingRedirect(string $urlPending): self public function getChargeUnregulatedCardFees(): ?bool { - return $this->params['chargeUnregulatedCardFees'] ?? null; + if ($this->params['chargeUnregulatedCardFees'] === null || $this->params['chargeUnregulatedCardFees'] === '') { + return null; + } + + // aby se mi vracelo true a false jako boolean + return filter_var($this->params['chargeUnregulatedCardFees'],FILTER_VALIDATE_BOOLEAN); } - public function setChargeUnregulatedCardFees(bool $chargeUnregulatedCardFees): self + /** + * Explicitně umožňuje přidat přirážku za neregulovanou kartu na platby s Apple Pay a Google Pay. Případně pro přímé zakázání pro konkrétní platbu + * + * @param null|bool|string $chargeUnregulatedCardFees + * @return Payment + */ + public function setChargeUnregulatedCardFees($chargeUnregulatedCardFees): self { $this->setParam('chargeUnregulatedCardFees', $chargeUnregulatedCardFees); @@ -652,13 +663,18 @@ public function setChargeUnregulatedCardFees(bool $chargeUnregulatedCardFees): s */ public function getEnableApplePayGooglePay(): ?bool { - return $this->params['enableApplePayGooglePay'] ?? null; + if ($this->params['enableApplePayGooglePay'] === null || $this->params['enableApplePayGooglePay'] === '') { + return null; + } + + // aby se mi vracelo true a false jako boolean + return filter_var($this->params['enableApplePayGooglePay'],FILTER_VALIDATE_BOOLEAN); } /** * Explicitně umožňuje povolení Apple Pay a Google Pay na platbách s přirážkami za neregulovanou kartu. Případně pro přímé zakázání pro konkrétní platbu * - * @param null|bool $enableApplePayGooglePay + * @param null|bool|string $enableApplePayGooglePay * @return Payment */ // Použit komentář místo parametrového typu kvůli nekompatibilitě s null hodnotou. diff --git a/tests/Integration/Entity/Request/PaymentCreateRequestCest.php b/tests/Integration/Entity/Request/PaymentCreateRequestCest.php index 31b3ac9..25a426b 100644 --- a/tests/Integration/Entity/Request/PaymentCreateRequestCest.php +++ b/tests/Integration/Entity/Request/PaymentCreateRequestCest.php @@ -124,6 +124,94 @@ protected function getPaymentScenarios(){ 'initRecurringId' => '', ], ], + '3 state bool empty str' => [ + 'payment' => (new Payment()) + ->setPrice(Money::ofInt(123)) + ->setEnableApplePayGooglePay('') + ->setChargeUnregulatedCardFees('') + , + 'result' => [ + 'test' => 'false', + 'prepareOnly' => 'true', + 'preauth' => 'false', + 'verification' => 'false', + 'embedded' => 'false', + 'method' => '', + 'initRecurring' => 'false', + 'account' => '', + 'name' => '', + 'price' => 12300, + 'dynamicExpiration' => 'false', + 'country' => '', + 'curr' => '', + 'label' => '', + 'refId' => '', + 'email' => '', + 'phone' => '', + 'fullName' => '', + 'billingAddrCity' => '', + 'billingAddrStreet' => '', + 'billingAddrPostalCode' => '', + 'billingAddrCountry' => '', + 'delivery' => '', + 'homeDeliveryCity' => '', + 'homeDeliveryStreet' => '', + 'homeDeliveryPostalCode' => '', + 'homeDeliveryCountry' => '', + 'category' => '', + 'lang' => '', + 'expirationTime' => '', + 'url_paid' => '', + 'url_cancelled' => '', + 'url_pending' => '', + 'initRecurringId' => '', + ], + ], + '3 state bool true false' => [ + 'payment' => (new Payment()) + ->setPrice(Money::ofInt(123)) + ->setEnableApplePayGooglePay('true') + ->setChargeUnregulatedCardFees('false') + , + 'result' => [ + 'test' => 'false', + 'prepareOnly' => 'true', + 'preauth' => 'false', + 'verification' => 'false', + 'embedded' => 'false', + 'method' => '', + 'initRecurring' => 'false', + 'account' => '', + 'name' => '', + 'price' => 12300, + 'dynamicExpiration' => 'false', + 'country' => '', + 'curr' => '', + 'label' => '', + 'refId' => '', + 'email' => '', + 'phone' => '', + 'fullName' => '', + 'billingAddrCity' => '', + 'billingAddrStreet' => '', + 'billingAddrPostalCode' => '', + 'billingAddrCountry' => '', + 'delivery' => '', + 'homeDeliveryCity' => '', + 'homeDeliveryStreet' => '', + 'homeDeliveryPostalCode' => '', + 'homeDeliveryCountry' => '', + 'category' => '', + 'lang' => '', + 'expirationTime' => '', + 'url_paid' => '', + 'url_cancelled' => '', + 'url_pending' => '', + 'initRecurringId' => '', + 'chargeUnregulatedCardFees' => 'false', + 'enableApplePayGooglePay' => 'true', + ], + ], ]; } }