-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2713da2
commit b84c2b5
Showing
11 changed files
with
432 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
<?php | ||
|
||
namespace OpenApi\Events; | ||
|
||
use OpenApi\Model\Api\PaymentModuleOption; | ||
use OpenApi\Model\Api\PaymentModuleOptionGroup; | ||
use Thelia\Core\Event\ActionEvent; | ||
use Thelia\Core\Translation\Translator; | ||
use Thelia\Model\Address; | ||
use Thelia\Model\Base\CountryQuery; | ||
use Thelia\Model\Cart; | ||
use Thelia\Model\Country; | ||
use Thelia\Model\Module; | ||
use Thelia\Model\State; | ||
|
||
class PaymentModuleOptionEvent extends ActionEvent | ||
{ | ||
protected Module $module; | ||
|
||
protected Cart $cart; | ||
|
||
protected ?Address $address = null; | ||
|
||
protected ?Country $country = null; | ||
|
||
protected ?State $state = null; | ||
|
||
protected array $paymentModuleOptionGroups = []; | ||
|
||
public function __construct( | ||
Module $module, | ||
Cart $cart = null, | ||
) { | ||
$this->module = $module; | ||
$address = $cart?->getAddressRelatedByAddressInvoiceId() ?? $cart?->getAddressRelatedByAddressDeliveryId() ?? null; | ||
$this->address = $address; | ||
$this->cart = $cart; | ||
$this->country = $address?->getCountry() ?? CountryQuery::create()->filterByByDefault(true)->findOne(); | ||
$this->state = $address?->getState() ?? $this->country?->getStates()?->getFirst() ?? null; | ||
|
||
if (!$module->isPayementModule()) { | ||
throw new \Exception(Translator::getInstance()->trans($module->getTitle().' is not a payment module.')); | ||
} | ||
} | ||
|
||
public function getPaymentModuleOptionGroups() | ||
{ | ||
return $this->paymentModuleOptionGroups; | ||
} | ||
|
||
public function setPaymentModuleOptionGroups($paymentModuleOptionGroups) | ||
{ | ||
$this->paymentModuleOptionGroups = $paymentModuleOptionGroups; | ||
|
||
return $this; | ||
} | ||
|
||
public function appendPaymentModuleOptionGroups(PaymentModuleOptionGroup $paymentModuleOptionGroup) | ||
{ | ||
$this->paymentModuleOptionGroups[] = $paymentModuleOptionGroup; | ||
|
||
return $this; | ||
} | ||
|
||
public function getModule() | ||
{ | ||
return $this->module; | ||
} | ||
|
||
public function setModule($module) | ||
{ | ||
$this->module = $module; | ||
|
||
return $this; | ||
} | ||
|
||
public function getCart() | ||
{ | ||
return $this->cart; | ||
} | ||
|
||
public function setCart($cart) | ||
{ | ||
$this->cart = $cart; | ||
|
||
return $this; | ||
} | ||
|
||
public function getAddress() | ||
{ | ||
return $this->address; | ||
} | ||
|
||
public function setAddress($address) | ||
{ | ||
$this->address = $address; | ||
|
||
return $this; | ||
} | ||
|
||
public function getCountry() | ||
{ | ||
return $this->country; | ||
} | ||
|
||
public function setCountry($country) | ||
{ | ||
$this->country = $country; | ||
|
||
return $this; | ||
} | ||
|
||
public function getState() | ||
{ | ||
return $this->state; | ||
} | ||
|
||
public function setState($state) | ||
{ | ||
$this->state = $state; | ||
|
||
return $this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
<?php | ||
|
||
namespace OpenApi\Model\Api; | ||
|
||
use OpenApi\Attributes\Property; | ||
use OpenApi\Attributes\Schema; | ||
use Symfony\Component\Validator\Constraints\NotBlank; | ||
|
||
|
||
#[Schema(description: "An option for payment module")] | ||
class PaymentModuleOption extends BaseApiModel | ||
{ | ||
#[Property(type: "string")] | ||
#[NotBlank(groups: ["read"])] | ||
protected string $code; | ||
|
||
#[Property(type: "boolean")] | ||
protected bool $valid; | ||
|
||
#[Property(type: "string")] | ||
protected string $title; | ||
|
||
#[Property(type: "string")] | ||
protected string $description; | ||
|
||
#[Property(description: "Option logo url", type: "string")] | ||
protected string $image; | ||
|
||
public function getCode(): string | ||
{ | ||
return $this->code; | ||
} | ||
|
||
public function setCode(string $code): PaymentModuleOption | ||
{ | ||
$this->code = $code; | ||
return $this; | ||
} | ||
|
||
public function isValid(): bool | ||
{ | ||
return $this->valid; | ||
} | ||
|
||
public function setValid(bool $valid): PaymentModuleOption | ||
{ | ||
$this->valid = $valid; | ||
return $this; | ||
} | ||
|
||
public function getTitle(): string | ||
{ | ||
return $this->title; | ||
} | ||
|
||
public function setTitle(string $title): PaymentModuleOption | ||
{ | ||
$this->title = $title; | ||
return $this; | ||
} | ||
|
||
public function getDescription(): string | ||
{ | ||
return $this->description; | ||
} | ||
|
||
public function setDescription(string $description): PaymentModuleOption | ||
{ | ||
$this->description = $description; | ||
return $this; | ||
} | ||
|
||
public function getImage(): string | ||
{ | ||
return $this->image; | ||
} | ||
|
||
public function setImage(string $image): PaymentModuleOption | ||
{ | ||
$this->image = $image; | ||
return $this; | ||
} | ||
} |
Oops, something went wrong.