-
diff --git a/src/Twig/Extension/CustomerCreditCards.php b/src/Twig/Extension/CustomerCreditCards.php
new file mode 100644
index 00000000..1ef0588f
--- /dev/null
+++ b/src/Twig/Extension/CustomerCreditCards.php
@@ -0,0 +1,68 @@
+apiClient = $apiClient;
+ $this->customerRepository = $customerRepository;
+ $this->customerContext = $customerContext;
+ }
+
+ /**
+ * @return TwigFunction[]
+ */
+ public function getFunctions()
+ {
+ return [
+ new TwigFunction('isCardSaved', [$this, 'isCardSaved']),
+ new TwigFunction('getCustomerFromContext', [$this, 'getCustomerFromContext'])
+ ];
+ }
+
+ /**
+ * @param string $customerEmail
+ *
+ * @return bool
+ */
+ public function isCardSaved(string $customerEmail)
+ {
+ $existingCustomer = $this->customerRepository->findOneBy(['email' => $customerEmail]);
+
+ if ($existingCustomer) {
+ return $existingCustomer->isCreditCardSaved() === '1';
+ }
+
+ return false;
+ }
+
+ /**
+ * @return \Sylius\Component\Customer\Model\CustomerInterface|null
+ */
+ public function getCustomerFromContext()
+ {
+ return $this->customerContext->getCustomer();
+ }
+}
diff --git a/src/Validator/Constraints/MollieGatewayConfigValidator.php b/src/Validator/Constraints/MollieGatewayConfigValidator.php
new file mode 100644
index 00000000..ff49089f
--- /dev/null
+++ b/src/Validator/Constraints/MollieGatewayConfigValidator.php
@@ -0,0 +1,67 @@
+validateAmounts($value, $constraint);
+ }
+
+ Assert::isInstanceOf($constraint, MollieGatewayConfigValidatorType::class);
+ }
+
+ private function validateAmounts(PersistentCollection $collection, Constraint $constraint): void
+ {
+ $mollieGatewayConfigs = $collection->getSnapshot();
+ foreach ($mollieGatewayConfigs as $key => $mollieGatewayConfig) {
+ $amountLimits = $mollieGatewayConfig->getAmountLimits();
+ if (!$amountLimits) {
+ continue;
+ }
+
+ $minAmount = $amountLimits->getMinimumAmount();
+ $maxAmount = $amountLimits->getMaximumAmount();
+
+ if ($minAmount !== null && $maxAmount !== null && $minAmount > $maxAmount) {
+ $this->context->buildViolation($constraint->minGreaterThanMaxMessage)
+ ->atPath("[{$key}]." . self::AMOUNT_LIMITS_FIELD . '.' . self::MAXIMUM_FIELD)
+ ->addViolation();
+ }
+
+ if ($minAmount !== null && $mollieGatewayConfig->getMinimumAmount()) {
+ $mollieMinAmount = $mollieGatewayConfig->getMinimumAmount()[self::FIELD_VALUE];
+ if ($mollieMinAmount !== null && $mollieMinAmount > $minAmount) {
+ $this->context->buildViolation($constraint->minLessThanMollieMinMessage)
+ ->setParameter('%amount%', $mollieMinAmount)
+ ->atPath("[{$key}]." . self::AMOUNT_LIMITS_FIELD . '.' . self::MINIMUM_FIELD)
+ ->addViolation();
+ }
+ }
+
+ if ($maxAmount !== null && $mollieGatewayConfig->getMaximumAmount()) {
+ $mollieMaxAmount = $mollieGatewayConfig->getMaximumAmount()[self::FIELD_VALUE];
+ if ($mollieMaxAmount !== null && $mollieMaxAmount < $maxAmount) {
+ $this->context->buildViolation($constraint->maxGreaterThanMollieMaxMessage)
+ ->setParameter('%amount%', $mollieMaxAmount)
+ ->atPath("[{$key}]." . self::AMOUNT_LIMITS_FIELD . '.' . self::MAXIMUM_FIELD)
+ ->addViolation();
+ }
+ }
+ }
+
+ }
+}
diff --git a/src/Validator/Constraints/MollieGatewayConfigValidatorType.php b/src/Validator/Constraints/MollieGatewayConfigValidatorType.php
new file mode 100644
index 00000000..de05bee7
--- /dev/null
+++ b/src/Validator/Constraints/MollieGatewayConfigValidatorType.php
@@ -0,0 +1,25 @@
+paymentCheckoutOrderResolver->resolve();
- /** @var PaymentInterface $payment */
+ /** @var PaymentInterface|null $payment */
$payment = $order->getPayments()->last();
+ if(null === $payment || false === $payment)
+ {
+ return;
+ }
+
/** @var ?PaymentMethodInterface $paymentMethod */
$paymentMethod = $payment->getMethod();
if (null === $paymentMethod) {
diff --git a/tests/Application/templates/bundles/SyliusAdminBundle/PaymentMethod/_mollieMethodsForm.html.twig b/tests/Application/templates/bundles/SyliusAdminBundle/PaymentMethod/_mollieMethodsForm.html.twig
index 2ce6f0e9..7787c381 100644
--- a/tests/Application/templates/bundles/SyliusAdminBundle/PaymentMethod/_mollieMethodsForm.html.twig
+++ b/tests/Application/templates/bundles/SyliusAdminBundle/PaymentMethod/_mollieMethodsForm.html.twig
@@ -162,7 +162,11 @@
{{ 'sylius_mollie_plugin.ui.payment_fee'|trans }}
{{ form_row(methodForm.paymentSurchargeFee, { 'attr': { 'class': 'js-onboardingWizard-paymentFee' } }) }}
-
+
+
{{ 'sylius_mollie_plugin.form.amount_limit_help'|trans }}
+ {{ form_row(methodForm.amountLimits, { 'attr': { 'class': 'js-onboardingWizard-minMax fields' } }) }}
{% else %}
diff --git a/tests/Application/templates/bundles/SyliusShopBundle/Checkout/SelectPayment/_payment.html.twig b/tests/Application/templates/bundles/SyliusShopBundle/Checkout/SelectPayment/_payment.html.twig
index 9d499a93..0bdc623f 100644
--- a/tests/Application/templates/bundles/SyliusShopBundle/Checkout/SelectPayment/_payment.html.twig
+++ b/tests/Application/templates/bundles/SyliusShopBundle/Checkout/SelectPayment/_payment.html.twig
@@ -10,6 +10,8 @@
{% if form.method.vars.choices[key].data.gatewayConfig.factoryName in [mollieFactoryName, mollieRecurringFactoryName] %}
{% if not isRendered %}
{{ form_row(form.details.cartToken) }}
+ {{ form_row(form.details.saveCardInfo) }}
+ {{ form_row(form.details.useSavedCards) }}
{% set isRendered = true %}
{% endif %}
{% include '@SyliusShop/Checkout/SelectPayment/_choiceMollie.html.twig' with {