Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions src/Entity/Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Payment
/**
* Payment parameters.
*
* @var array<string, bool|int|string|Money|array<int, string>>
* @var array<string, bool|int|string|Money|array<int, string>|null>
*/
protected $params = [
'test' => false,
Expand Down Expand Up @@ -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);

Expand All @@ -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.
Expand Down
88 changes: 88 additions & 0 deletions tests/Integration/Entity/Request/PaymentCreateRequestCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
],
],
];
}
}
Loading