From f1d282b8a1aebb3c43dd0112e470a818d8ecf2a2 Mon Sep 17 00:00:00 2001 From: Luka Simovic Date: Fri, 15 Mar 2024 10:01:03 +0100 Subject: [PATCH 1/5] Fix surcharge validator when surcharge limit is not set ISSUE: PISYL-228 --- src/Validator/Constraints/PaymentSurchargeTypeValidator.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Validator/Constraints/PaymentSurchargeTypeValidator.php b/src/Validator/Constraints/PaymentSurchargeTypeValidator.php index 6f2fb618..9c743da6 100644 --- a/src/Validator/Constraints/PaymentSurchargeTypeValidator.php +++ b/src/Validator/Constraints/PaymentSurchargeTypeValidator.php @@ -17,6 +17,8 @@ final class PaymentSurchargeTypeValidator extends ConstraintValidator public const FIXED_AMOUNT_FIELD = 'fixedAmount'; + public const SURCHARGE_LIMIT_FIELD = 'surchargeLimit'; + public function validate($value, Constraint $constraint): void { if ($value instanceof PaymentSurchargeFeeInterface) { @@ -31,6 +33,9 @@ private function validatePaymentSurcharge(PaymentSurchargeFeeInterface $paymentS if (Options::PERCENTAGE === $paymentSurchargeFee->getType() && null === $paymentSurchargeFee->getPercentage()) { $this->createNegativeResponse($constraint, self::PERCENTAGE_FIELD); } + if (Options::PERCENTAGE === $paymentSurchargeFee->getType() && null === $paymentSurchargeFee->getSurchargeLimit()) { + $this->createNegativeResponse($constraint, self::SURCHARGE_LIMIT_FIELD); + } if (Options::FIXED_FEE === $paymentSurchargeFee->getType() && null === $paymentSurchargeFee->getFixedAmount()) { $this->createNegativeResponse($constraint, self::FIXED_AMOUNT_FIELD); } From 746a7cbb6aa70c8fd58a648639101629659d3961 Mon Sep 17 00:00:00 2001 From: SergejSavic Date: Thu, 28 Nov 2024 16:26:55 +0100 Subject: [PATCH 2/5] add billing address when using Trustly. Update validation and add new translations. --- src/Action/Api/CreatePaymentAction.php | 3 ++- src/Action/ConvertMolliePaymentAction.php | 2 +- src/Resources/translations/flashes.de.yml | 2 ++ src/Resources/translations/flashes.en.yml | 2 ++ src/Resources/translations/flashes.fr.yml | 2 ++ src/Resources/translations/flashes.nl.yml | 2 ++ .../PaymentMethodCheckoutValidator.php | 23 +++++++++++++++---- 7 files changed, 29 insertions(+), 7 deletions(-) diff --git a/src/Action/Api/CreatePaymentAction.php b/src/Action/Api/CreatePaymentAction.php index 79f7b684..7fc96750 100644 --- a/src/Action/Api/CreatePaymentAction.php +++ b/src/Action/Api/CreatePaymentAction.php @@ -68,7 +68,8 @@ public function execute($request): void 'metadata' => $details['metadata'], ]; - if ($details['metadata']['molliePaymentMethods'] === PaymentMethod::ALMA) { + if ($details['metadata']['molliePaymentMethods'] === PaymentMethod::ALMA || + $details['metadata']['molliePaymentMethods'] === PaymentMethod::TRUSTLY) { $paymentDetails['billingAddress'] = $details['billingAddress']; } diff --git a/src/Action/ConvertMolliePaymentAction.php b/src/Action/ConvertMolliePaymentAction.php index 41f73beb..f4c7d354 100644 --- a/src/Action/ConvertMolliePaymentAction.php +++ b/src/Action/ConvertMolliePaymentAction.php @@ -141,7 +141,7 @@ public function execute($request): void $details['metadata']['customer_mollie_id'] = $model['customer_mollie_id']; } - if ($method->getMethodId() === PaymentMethod::ALMA) { + if ($method->getMethodId() === PaymentMethod::ALMA || $method->getMethodId() === PaymentMethod::TRUSTLY) { $billingAddress = $order->getBillingAddress(); $customer = $order->getCustomer(); $address = []; diff --git a/src/Resources/translations/flashes.de.yml b/src/Resources/translations/flashes.de.yml index 365cea60..4f86995a 100644 --- a/src/Resources/translations/flashes.de.yml +++ b/src/Resources/translations/flashes.de.yml @@ -22,4 +22,6 @@ sylius_mollie_plugin: empty_payment_method_checkout: 'Wählen Sie eine Mollie-Bezahlmethode' billie.error: company_missing: 'Die Angabe eines Firmennamens ist für die Zahlungsart Billie verpflichtend. Bitte geben Sie einen Firmennamen an oder wählen Sie eine andere Zahlungsart.' + billing_address.error: + info_missing: 'Bei Verwendung der Trustly-Zahlungsmethode sind Vorname, Nachname und E-Mail erforderlich. Bitte ergänzen Sie die fehlenden Daten oder wählen Sie eine andere Zahlungsart.' diff --git a/src/Resources/translations/flashes.en.yml b/src/Resources/translations/flashes.en.yml index c3bbb452..5335e99b 100644 --- a/src/Resources/translations/flashes.en.yml +++ b/src/Resources/translations/flashes.en.yml @@ -21,6 +21,8 @@ sylius_mollie_plugin: authentication_failed: 'Authentication failed' billie.error: company_missing: 'Company name is required when Billie payment method is used. Please set company name or choose another payment method' + billing_address.error: + info_missing: 'First name, last name and email are required when Trustly payment method is used. Please add the missing data or choose another payment method.' empty_payment_method_checkout: 'Choose one of mollie payment method' order_checkout: colliding_products: 'There are mixed products (recurring and non-recurring) within your cart. Proceeding with mixed content is forbidden.' diff --git a/src/Resources/translations/flashes.fr.yml b/src/Resources/translations/flashes.fr.yml index e4e05104..5247f1ac 100644 --- a/src/Resources/translations/flashes.fr.yml +++ b/src/Resources/translations/flashes.fr.yml @@ -22,4 +22,6 @@ sylius_mollie_plugin: empty_payment_method_checkout: 'Veuillez choisir une méthode de paiement Mollie' billie.error: company_missing: "Le nom de l'entreprise est requis lorsque la méthode de paiement Billie est utilisée. Veuillez indiquer le nom de l'entreprise ou choisir une autre méthode de paiement" + billing_address.error: + info_missing: "Le prénom, le nom et l'e-mail sont requis lorsque le mode de paiement Trustly est utilisé. Veuillez ajouter les données manquantes ou choisir un autre mode de paiement." diff --git a/src/Resources/translations/flashes.nl.yml b/src/Resources/translations/flashes.nl.yml index 07d0619e..d54c6008 100644 --- a/src/Resources/translations/flashes.nl.yml +++ b/src/Resources/translations/flashes.nl.yml @@ -22,4 +22,6 @@ sylius_mollie_plugin: empty_payment_method_checkout: 'Kies een van de Mollie-betalingsmethoden' billie.error: company_missing: 'De bedrijfsnaam is vereist bij het gebruik van Billie. Geef de bedrijfsnaam op of kies voor een andere betaalmethode.' + billing_address.error: + error: 'Voornaam, achternaam en e-mailadres zijn vereist bij gebruik van de Trustly-betaalmethode. Voeg ontbrekende gegevens toe of kies een andere betaalmethode.' diff --git a/src/Validator/Constraints/PaymentMethodCheckoutValidator.php b/src/Validator/Constraints/PaymentMethodCheckoutValidator.php index b2d57813..98625c9f 100644 --- a/src/Validator/Constraints/PaymentMethodCheckoutValidator.php +++ b/src/Validator/Constraints/PaymentMethodCheckoutValidator.php @@ -27,9 +27,10 @@ final class PaymentMethodCheckoutValidator extends ConstraintValidator public function __construct( PaymentCheckoutOrderResolverInterface $paymentCheckoutOrderResolver, - RequestStack $requestStack, - MollieGatewayFactoryCheckerInterface $mollieGatewayFactoryChecker - ) { + RequestStack $requestStack, + MollieGatewayFactoryCheckerInterface $mollieGatewayFactoryChecker + ) + { $this->requestStack = $requestStack; $this->paymentCheckoutOrderResolver = $paymentCheckoutOrderResolver; $this->mollieGatewayFactoryChecker = $mollieGatewayFactoryChecker; @@ -42,8 +43,7 @@ public function validate($value, Constraint $constraint): void /** @var PaymentInterface|null $payment */ $payment = $order->getPayments()->last(); - if(null === $payment || false === $payment) - { + if (null === $payment || false === $payment) { return; } @@ -63,6 +63,19 @@ public function validate($value, Constraint $constraint): void if ($value === PaymentMethod::BILLIE && empty($order->getBillingAddress()->getCompany())) { $this->flashMessage($constraint, 'error', 'sylius_mollie_plugin.billie.error.company_missing'); } + + $customer = $order->getCustomer(); + $email = ($customer && $customer->getEmail()) ? $customer->getEmail() : + (($order->getUser() && $order->getUser()->getEmail()) ? $order->getUser()->getEmail() : null); + + if (($value === PaymentMethod::TRUSTLY || $value === PaymentMethod::ALMA) && + ( + empty($order->getBillingAddress()->getFirstName()) || + empty($order->getBillingAddress()->getLastName()) || + empty($email) + )) { + $this->flashMessage($constraint, 'error', 'sylius_mollie_plugin.billing_address.error.info_missing'); + } } /** From 849f7fb45e177cf1a8ba7dc61723afd472c00556 Mon Sep 17 00:00:00 2001 From: SergejSavic Date: Fri, 13 Dec 2024 14:53:49 +0100 Subject: [PATCH 3/5] add image url to the convert order --- src/Helper/ConvertOrder.php | 58 ++++++++++++++++++++---- src/Resources/config/services/helper.xml | 1 + 2 files changed, 51 insertions(+), 8 deletions(-) diff --git a/src/Helper/ConvertOrder.php b/src/Helper/ConvertOrder.php index ea5bbbd2..573b9506 100644 --- a/src/Helper/ConvertOrder.php +++ b/src/Helper/ConvertOrder.php @@ -7,6 +7,7 @@ use Mollie\Api\Types\PaymentMethod; use Sylius\Component\Addressing\Model\ZoneInterface; +use Sylius\Component\Core\Model\ImageInterface; use Sylius\Component\Core\Model\Scope; use Sylius\Component\Core\Model\ShippingMethodInterface; use Sylius\Component\Taxation\Model\TaxRateInterface; @@ -21,6 +22,7 @@ use Sylius\Component\Customer\Model\CustomerInterface; use Sylius\Component\Order\Model\Adjustment; use Sylius\Component\Taxation\Resolver\TaxRateResolverInterface; +use Symfony\Component\HttpFoundation\RequestStack; use Webmozart\Assert\Assert; final class ConvertOrder implements ConvertOrderInterface @@ -46,18 +48,24 @@ final class ConvertOrder implements ConvertOrderInterface /** @var ZoneMatcherInterface */ private $zoneMatcher; + /** @var RequestStack */ + private $requestStack; + public function __construct( IntToStringConverterInterface $intToStringConverter, CalculateTaxAmountInterface $calculateTaxAmount, MealVoucherResolverInterface $mealVoucherResolver, TaxRateResolverInterface $taxRateResolver, - ZoneMatcherInterface $zoneMatcher - ) { + ZoneMatcherInterface $zoneMatcher, + RequestStack $requestStack + ) + { $this->intToStringConverter = $intToStringConverter; $this->calculateTaxAmount = $calculateTaxAmount; $this->mealVoucherResolver = $mealVoucherResolver; $this->taxRateResolver = $taxRateResolver; $this->zoneMatcher = $zoneMatcher; + $this->requestStack = $requestStack; } public function convert( @@ -71,8 +79,7 @@ public function convert( Assert::notNull($this->order->getBillingAddress()); $this->zone = $this->zoneMatcher->match($this->order->getBillingAddress(), Scope::TAX); - if(null === $this->zone && null !== $this->order->getChannel()) - { + if (null === $this->zone && null !== $this->order->getChannel()) { Assert::notNull($this->order->getChannel()); $this->zone = $this->order->getChannel()->getDefaultTaxZone(); } @@ -83,7 +90,7 @@ public function convert( $amount = $this->intToStringConverter->convertIntToString($order->getTotal(), $divisor); $details['amount']['value'] = $amount; - $details['orderNumber'] = (string) $order->getNumber(); + $details['orderNumber'] = (string)$order->getNumber(); $details['shippingAddress'] = $this->createShippingAddress($customer); $details['billingAddress'] = $this->createBillingAddress($customer, $method->getMethodId()); $details['lines'] = $this->createLines($divisor, $method); @@ -146,7 +153,7 @@ private function createLines(int $divisor, MollieGatewayConfigInterface $method) 'type' => 'physical', 'name' => $item->getProductName(), 'quantity' => $item->getQuantity(), - 'vatRate' => null === $taxRate ? '0.00' : (string) $taxRate->getAmountAsPercentage(), + 'vatRate' => null === $taxRate ? '0.00' : (string)$taxRate->getAmountAsPercentage(), 'unitPrice' => [ 'currency' => $this->order->getCurrencyCode(), 'value' => $this->intToStringConverter->convertIntToString($this->getUnitPriceWithTax($item, $taxRate), $divisor), @@ -161,6 +168,7 @@ private function createLines(int $divisor, MollieGatewayConfigInterface $method) '0.00' : $this->calculateTaxAmount->calculate($taxRate->getAmount(), $item->getTotal()), ], + 'imageUrl' => $this->getImageUrl($item), 'discountAmount' => [ 'currency' => $this->order->getCurrencyCode(), 'value' => $this->intToStringConverter->convertIntToString($this->getItemDiscountAmount($item), $divisor), @@ -181,6 +189,40 @@ private function createLines(int $divisor, MollieGatewayConfigInterface $method) return $details; } + /** + * Fetches product image url + * + * @param OrderItem $item + * + * @return string + */ + private function getImageUrl(OrderItem $item): string + { + $images = $item->getProduct()->getImages(); + $imagePaths = []; + + foreach ($images as $key => $image) { + if ($image instanceof ImageInterface) { + $imagePaths[] = $image->getPath(); + } + } + + if (!empty($imagePaths) && isset($imagePaths[0])) { + return rtrim($this->fetchBaseShopUrl(), '/') . '/media/cache/sylius_shop_product_thumbnail/' + . $imagePaths[0]; + } + + return ''; + } + + /** + * @return string + */ + private function fetchBaseShopUrl(): string + { + return $this->requestStack->getCurrentRequest()->getSchemeAndHttpHost(); + } + private function createAdjustments(Adjustment $adjustment, int $divisor): array { return [ @@ -218,7 +260,7 @@ private function createShippingFee(int $divisor): array 'type' => self::SHIPPING_TYPE, 'name' => self::SHIPPING_FEE, 'quantity' => 1, - 'vatRate' => null === $taxRate ? '0.00' : (string) $taxRate->getAmountAsPercentage(), + 'vatRate' => null === $taxRate ? '0.00' : (string)$taxRate->getAmountAsPercentage(), 'unitPrice' => [ 'currency' => $this->order->getCurrencyCode(), 'value' => $this->intToStringConverter->convertIntToString($this->order->getShippingTotal(), $divisor), @@ -247,7 +289,7 @@ private function getUnitPriceWithTax(OrderItem $item, ?TaxRateInterface $taxRate return $item->getUnitPrice(); } - return (int) round($item->getUnitPrice() + ($item->getTaxTotal() / $item->getQuantity())); + return (int)round($item->getUnitPrice() + ($item->getTaxTotal() / $item->getQuantity())); } private function getItemDiscountAmount(OrderItem $item): int diff --git a/src/Resources/config/services/helper.xml b/src/Resources/config/services/helper.xml index fadf57d6..b3c5565c 100644 --- a/src/Resources/config/services/helper.xml +++ b/src/Resources/config/services/helper.xml @@ -13,6 +13,7 @@ + From 13948ab5d9cbbf3f1e4edc9101f36e19225a112a Mon Sep 17 00:00:00 2001 From: SergejSavic Date: Mon, 23 Dec 2024 13:45:08 +0100 Subject: [PATCH 4/5] add logs for credit card components error messages --- .../Shop/CreditCardTranslationController.php | 39 +++++++++++++++++++ src/Resources/assets/shop/js/mollie/app.js | 19 ++++++--- src/Resources/config/routing/shop.yaml | 2 + .../routing/shop/creditCardTranslation.yaml | 4 ++ src/Resources/config/services/controller.xml | 3 ++ src/Resources/translations/messages.de.yml | 6 +++ src/Resources/translations/messages.en.yml | 6 +++ src/Resources/translations/messages.fr.yml | 6 +++ src/Resources/translations/messages.nl.yml | 6 +++ .../views/Shop/PaymentMollie/_form.html.twig | 1 + 10 files changed, 87 insertions(+), 5 deletions(-) create mode 100644 src/Controller/Action/Shop/CreditCardTranslationController.php create mode 100644 src/Resources/config/routing/shop/creditCardTranslation.yaml diff --git a/src/Controller/Action/Shop/CreditCardTranslationController.php b/src/Controller/Action/Shop/CreditCardTranslationController.php new file mode 100644 index 00000000..698cf7cc --- /dev/null +++ b/src/Controller/Action/Shop/CreditCardTranslationController.php @@ -0,0 +1,39 @@ +translator = $translator; + } + + /** + * @param Request $request + * + * @return JsonResponse + */ + public function fetchTranslations(Request $request): JsonResponse + { + $response = [ + 'emptyCardHolder' => $this->translator->trans('sylius_mollie_plugin.ui.credit_card_validations.empty_card_holder'), + 'emptyCardNumber' => $this->translator->trans('sylius_mollie_plugin.ui.credit_card_validations.empty_card_number'), + 'emptyExpiryDate' => $this->translator->trans('sylius_mollie_plugin.ui.credit_card_validations.empty_expiry_date'), + 'emptyVerificationCode' => $this->translator->trans('sylius_mollie_plugin.ui.credit_card_validations.empty_verification_code'), + 'oneOrMoreInvalidFields' => $this->translator->trans('sylius_mollie_plugin.ui.credit_card_validations.one_or_more_invalid_fields'), + ]; + + return new JsonResponse(['status' => Response::HTTP_OK, 'translations' => $response]); + } +} diff --git a/src/Resources/assets/shop/js/mollie/app.js b/src/Resources/assets/shop/js/mollie/app.js index 64b5cae5..b1aeff61 100644 --- a/src/Resources/assets/shop/js/mollie/app.js +++ b/src/Resources/assets/shop/js/mollie/app.js @@ -6,11 +6,14 @@ $(function () { let mollieData = $('.online-online-payment__container'); let orderId = null; let qrCodeInterval = null; - let qrCodeUrl = null; const initialOrderTotal = $('#sylius-summary-grand-total').text(); const cardActiveClass = 'online-payment__item--active'; const orderTotalRow = $('#sylius-summary-grand-total'); const components = Boolean(mollieData.data('components')); + let creditCardTranslations = {}; + + let fetchTranslationsUrl = mollieData[0].getAttribute('data-fetchTranslations'); + fetchTranslations(fetchTranslationsUrl); $('input[id*="sylius_checkout_select_payment_"][type=radio]').on('change', ({currentTarget}) => { if (!currentTarget.classList.contains('mollie-payments')) { @@ -327,6 +330,12 @@ $(function () { mollieComponentFields.classList.remove('display-grid'); } + function fetchTranslations(url) { + fetch(url).then(response => response.json()).then(data => { + creditCardTranslations = data.translations; + }); + } + function initializeCreditCartFields(selectedValue) { const environment = mollieData.data('environment'); @@ -355,7 +364,7 @@ $(function () { const cardHolderError = document.getElementById('card-holder-error'); cardHolder.addEventListener('change', (event) => { if (event.error && event.touched) { - cardHolderError.textContent = event.error; + cardHolderError.textContent = creditCardTranslations.emptyCardHolder ? creditCardTranslations.emptyCardHolder : event.error; } else { cardHolderError.textContent = ''; } @@ -368,7 +377,7 @@ $(function () { cardNumber.addEventListener('change', (event) => { if (event.error && event.touched) { - cardNumberError.textContent = event.error; + cardNumberError.textContent = creditCardTranslations.emptyCardNumber ? creditCardTranslations.emptyCardNumber : event.error; } else { cardNumberError.textContent = ''; } @@ -381,7 +390,7 @@ $(function () { expiryDate.addEventListener('change', (event) => { if (event.error && event.touched) { - expiryDateError.textContent = event.error; + expiryDateError.textContent = creditCardTranslations.emptyExpiryDate ? creditCardTranslations.emptyExpiryDate : event.error; } else { expiryDateError.textContent = ''; } @@ -394,7 +403,7 @@ $(function () { verificationCode.addEventListener('change', (event) => { if (event.error && event.touched) { - verificationCodeError.textContent = event.error; + verificationCodeError.textContent = creditCardTranslations.emptyVerificationCode ? creditCardTranslations.emptyVerificationCode : event.error; } else { verificationCodeError.textContent = ''; } diff --git a/src/Resources/config/routing/shop.yaml b/src/Resources/config/routing/shop.yaml index b7aebdcb..7911d644 100644 --- a/src/Resources/config/routing/shop.yaml +++ b/src/Resources/config/routing/shop.yaml @@ -12,3 +12,5 @@ mollie_payment_webhook: resource: "shop/paymentWebhook.yaml" mollie_page_redirect: resource: "shop/pageRedirect.yaml" +mollie_credit_card_translation: + resource: "shop/creditCardTranslation.yaml" diff --git a/src/Resources/config/routing/shop/creditCardTranslation.yaml b/src/Resources/config/routing/shop/creditCardTranslation.yaml new file mode 100644 index 00000000..36480422 --- /dev/null +++ b/src/Resources/config/routing/shop/creditCardTranslation.yaml @@ -0,0 +1,4 @@ +sylius_mollie_plugin_credit_card_translation: + path: /fetch-translations + defaults: + _controller: sylius_mollie_plugin.controller.action.shop.credit_card_translation_controller::fetchTranslations diff --git a/src/Resources/config/services/controller.xml b/src/Resources/config/services/controller.xml index 640c224b..df97750a 100644 --- a/src/Resources/config/services/controller.xml +++ b/src/Resources/config/services/controller.xml @@ -51,6 +51,9 @@ + + + diff --git a/src/Resources/translations/messages.de.yml b/src/Resources/translations/messages.de.yml index d1f39c42..cce4ef9d 100644 --- a/src/Resources/translations/messages.de.yml +++ b/src/Resources/translations/messages.de.yml @@ -55,6 +55,12 @@ sylius_mollie_plugin: veryfication_code: 'Verifizierungscode' save_card: 'Save credit card for the future purchases' use_saved_card: 'Use saved credit card information' + credit_card_validations: + empty_card_holder: "Karteninhaber/in muss ausgefüllt werden" + empty_card_number: "Kartennummer muss ausgefüllt werden" + empty_expiry_date: "Gültig bis muss ausgefüllt werden" + empty_verification_code: "Prüfungsscode muss ausgefüllt werden" + one_or_more_invalid_fields: "Ein oder mehrere Felder sind ungültig" surcharge_title: 'Aufschlag' splitting_shipment_for_order: 'Lieferung für Auftrag #%number% teilen' split_shipment: 'Lieferung teilen' diff --git a/src/Resources/translations/messages.en.yml b/src/Resources/translations/messages.en.yml index 998af0d0..33e75469 100644 --- a/src/Resources/translations/messages.en.yml +++ b/src/Resources/translations/messages.en.yml @@ -103,6 +103,12 @@ sylius_mollie_plugin: veryfication_code: 'CVC/CVV' save_card: 'Save credit card for the future purchases' use_saved_card: 'Use saved credit card information' + credit_card_validations: + empty_card_holder: "Card holder cannot be empty" + empty_card_number: "Card number cannot be empty" + empty_expiry_date: "Expiry date cannot be empty" + empty_verification_code: "Verification code cannot be empty" + one_or_more_invalid_fields: "One or more fields are invalid" surcharge_title: 'Surcharge' splitting_shipment_for_order: 'Splitting shipment for Order no. #%number%' split_shipment: 'Split shipment' diff --git a/src/Resources/translations/messages.fr.yml b/src/Resources/translations/messages.fr.yml index 31249374..552a83a0 100644 --- a/src/Resources/translations/messages.fr.yml +++ b/src/Resources/translations/messages.fr.yml @@ -55,6 +55,12 @@ sylius_mollie_plugin: veryfication_code: "Code de vérification" save_card: 'Save credit card for the future purchases' use_saved_card: 'Use saved credit card information' + credit_card_validations: + empty_card_holder: "Titulaire de la carte ne peut pas être vide" + empty_card_number: "Numéro de carte ne peut pas être vide" + empty_expiry_date: "Date d'expiration ne peut pas être vide" + empty_verification_code: "Code de vérification ne peut pas être vide" + one_or_more_invalid_fields: "Un ou plusieurs champs ne sont pas valides" surcharge_title: "Supplément" splitting_shipment_for_order: "Fractionner l'envoi de la commande nº #%number%" split_shipment: "Expédition fractionnée" diff --git a/src/Resources/translations/messages.nl.yml b/src/Resources/translations/messages.nl.yml index 1814d686..f0f4a2f9 100644 --- a/src/Resources/translations/messages.nl.yml +++ b/src/Resources/translations/messages.nl.yml @@ -55,6 +55,12 @@ sylius_mollie_plugin: veryfication_code: 'Verificatiecode' save_card: 'Save credit card for the future purchases' use_saved_card: 'Use saved credit card information' + credit_card_validations: + empty_card_holder: "Kaarthouder kan niet leeg zijn" + empty_card_number: "Kaartnummer kan niet leeg zijn" + empty_expiry_date: "Vervaldatum kan niet leeg zijn" + empty_verification_code: "Verificatiecode kan niet leeg zijn" + one_or_more_invalid_fields: "Een of meer velden zijn ongeldigd" surcharge_title: 'Toeslag' splitting_shipment_for_order: 'Verzending opsplitsen voor Bestelnr. #%number%' split_shipment: 'Verzending opsplitsen' diff --git a/src/Resources/views/Shop/PaymentMollie/_form.html.twig b/src/Resources/views/Shop/PaymentMollie/_form.html.twig index 3b2c8840..b31582b6 100644 --- a/src/Resources/views/Shop/PaymentMollie/_form.html.twig +++ b/src/Resources/views/Shop/PaymentMollie/_form.html.twig @@ -4,6 +4,7 @@ data-environment="{{ gatewayConfig.config['environment'] }}" data-components="{{ gatewayConfig.config['components'] | default(false) }}" data-removeQrCode="{{ path('sylius_mollie_plugin_remove_qr_code') }}" + data-fetchTranslations="{{ path('sylius_mollie_plugin_credit_card_translation') }}" > {% for keyChoice, choice in methodMollie.vars.choices %}
Date: Wed, 25 Dec 2024 10:08:50 +0100 Subject: [PATCH 5/5] fix issue on the summary checkout page --- src/Resources/assets/shop/js/mollie/app.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Resources/assets/shop/js/mollie/app.js b/src/Resources/assets/shop/js/mollie/app.js index b1aeff61..a2f21237 100644 --- a/src/Resources/assets/shop/js/mollie/app.js +++ b/src/Resources/assets/shop/js/mollie/app.js @@ -12,8 +12,10 @@ $(function () { const components = Boolean(mollieData.data('components')); let creditCardTranslations = {}; - let fetchTranslationsUrl = mollieData[0].getAttribute('data-fetchTranslations'); - fetchTranslations(fetchTranslationsUrl); + if (mollieData && mollieData[0]) { + let fetchTranslationsUrl = mollieData[0].getAttribute('data-fetchTranslations'); + fetchTranslations(fetchTranslationsUrl); + } $('input[id*="sylius_checkout_select_payment_"][type=radio]').on('change', ({currentTarget}) => { if (!currentTarget.classList.contains('mollie-payments')) { @@ -202,7 +204,7 @@ $(function () { } function showQrCodePopUp() { - let cartVariantDetails = document.getElementById('cart-variant-details') + let cartVariantDetails = document.getElementById('cart-variant-details'); if (cartVariantDetails) { let qrCodeGetUrl = cartVariantDetails.getAttribute('data-getQrCode'); @@ -337,7 +339,6 @@ $(function () { } function initializeCreditCartFields(selectedValue) { - const environment = mollieData.data('environment'); let testmode = true;