Skip to content

Commit

Permalink
Merge pull request #91 from NicolasBarbey/main
Browse files Browse the repository at this point in the history
fix payment options
  • Loading branch information
NicolasBarbey authored Jun 11, 2024
2 parents 9df0a55 + f93f177 commit 5897230
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Config/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<language>en_US</language>
<language>fr_FR</language>
</languages>
<version>2.2.24</version>
<version>2.2.25</version>
<authors>
<author>
<name>Vincent Lopes-Vicente</name>
Expand Down
33 changes: 32 additions & 1 deletion Model/Api/Checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@ class Checkout extends BaseApiModel
*/
protected $paymentOptionChoices = [];

/**
* @var bool
* @OA\Property(
* type="boolean"
* )
*/
protected $mustSelectPaymentOption = false;

/**
* @var bool
* @OA\Property(
Expand Down Expand Up @@ -127,6 +135,10 @@ public function getIsComplete()
return false;
}

if ($this->isMustSelectPaymentOption() && empty($this->getPaymentOptionChoices())) {
return false;
}

return true;
}

Expand All @@ -145,7 +157,7 @@ public function checkIsValid(): void
);
}

if (null === $this->getPaymentModuleId()) {
if (null === $this->getPaymentModuleId() || ($this->isMustSelectPaymentOption() && empty($this->getPaymentOptionChoices()))) {
throw new \Exception(
Translator::getInstance()->trans(
'You must choose a payment module',
Expand Down Expand Up @@ -326,4 +338,23 @@ public function setPaymentOptionChoices(?array $paymentOptionChoices = []): Chec
$this->paymentOptionChoices = $paymentOptionChoices;
return $this;
}

/**
* @return bool
*/
public function isMustSelectPaymentOption(): bool
{
return $this->mustSelectPaymentOption;
}

/**
* @param bool $mustSelectPaymentOption
*/
public function setMustSelectPaymentOption(?bool $mustSelectPaymentOption = false): Checkout
{
$this->mustSelectPaymentOption = $mustSelectPaymentOption;
return $this;
}


}

0 comments on commit 5897230

Please sign in to comment.