From 0fae6e1802280c0d99fcfd9a96d6ef0ac9e2180e Mon Sep 17 00:00:00 2001 From: Vitalij Mik Date: Fri, 9 Feb 2024 14:10:34 +0100 Subject: [PATCH] NTR: set billing address from cart --- ...MolliePaymentMethodAvailabilityRemover.php | 24 ++++++++++++------- .../app/administration/src/snippet/de-DE.json | 2 +- .../app/administration/src/snippet/en-GB.json | 2 +- .../app/administration/src/snippet/nl-NL.json | 2 +- src/Resources/config/config.xml | 2 +- .../Provider/ActivePaymentMethodsProvider.php | 2 +- .../ActivePaymentMethodsProviderInterface.php | 2 +- 7 files changed, 21 insertions(+), 15 deletions(-) diff --git a/src/Components/MollieAvailability/Service/MolliePaymentMethodAvailabilityRemover.php b/src/Components/MollieAvailability/Service/MolliePaymentMethodAvailabilityRemover.php index cfd700df2..d7b92de59 100644 --- a/src/Components/MollieAvailability/Service/MolliePaymentMethodAvailabilityRemover.php +++ b/src/Components/MollieAvailability/Service/MolliePaymentMethodAvailabilityRemover.php @@ -65,6 +65,8 @@ public function removePaymentMethods(PaymentMethodRouteResponse $originalData, S if (!$this->isAllowedRoute()) { return $originalData; } + $billingAddress = null; + $countryIsoCode = null; if ($this->isCartRoute()) { try { @@ -77,8 +79,12 @@ public function removePaymentMethods(PaymentMethodRouteResponse $originalData, S } $price = $cart->getPrice()->getTotalPrice(); + $customer = $context->getCustomer(); + if ($customer !== null) { + $billingAddress = $customer->getDefaultBillingAddress(); + } } - $countryIsoCode = null; + if ($this->isOrderRoute()) { try { @@ -93,20 +99,20 @@ public function removePaymentMethods(PaymentMethodRouteResponse $originalData, S $price = $order->getAmountTotal(); $billingAddress = $order->getBillingAddress(); - if ($billingAddress === null) { - return $originalData; - } - $billingCountry = $billingAddress->getCountry(); - if ($billingCountry === null) { - return $originalData; - } - $countryIsoCode = $billingCountry->getIso(); } if (!isset($price)) { return $originalData; } + if ($billingAddress !== null) { + $billingCountry = $billingAddress->getCountry(); + if ($billingCountry !== null) { + $countryIsoCode = $billingCountry->getIso(); + } + } + + $availableMolliePayments = $this->paymentMethodsProvider->getActivePaymentMethodsForAmount( $price, diff --git a/src/Resources/app/administration/src/snippet/de-DE.json b/src/Resources/app/administration/src/snippet/de-DE.json index 76b59f784..e40cbc976 100644 --- a/src/Resources/app/administration/src/snippet/de-DE.json +++ b/src/Resources/app/administration/src/snippet/de-DE.json @@ -76,7 +76,7 @@ "failed": "Die Zahlungsarten konnten nicht aktualisiert werden." }, "mollieLimits": { - "link": "Öffne Mollie Zahlungs Limits" + "link": "Zeige Mollie Verfügbarkeitsregeln für Zahlungsarten" } }, "rounding": { diff --git a/src/Resources/app/administration/src/snippet/en-GB.json b/src/Resources/app/administration/src/snippet/en-GB.json index c8901c310..934b714d6 100644 --- a/src/Resources/app/administration/src/snippet/en-GB.json +++ b/src/Resources/app/administration/src/snippet/en-GB.json @@ -76,7 +76,7 @@ "failed": "The payment methods couldn't be updated." }, "mollieLimits": { - "link": "Open Mollie Payment Limits" + "link": "Show Mollie availability rules for payment methods" } }, "rounding": { diff --git a/src/Resources/app/administration/src/snippet/nl-NL.json b/src/Resources/app/administration/src/snippet/nl-NL.json index b3f8b10c0..a37ce42c5 100644 --- a/src/Resources/app/administration/src/snippet/nl-NL.json +++ b/src/Resources/app/administration/src/snippet/nl-NL.json @@ -76,7 +76,7 @@ "failed": "De betaalmethoden konden niet worden geupdated." }, "mollieLimits": { - "link": "Open betalingslimieten van Mollie" + "link": "Toon Mollie-beschikbaarheidsregels voor betaalmethoden" } }, "rounding": { diff --git a/src/Resources/config/config.xml b/src/Resources/config/config.xml index aafd5466a..ffd749ce0 100644 --- a/src/Resources/config/config.xml +++ b/src/Resources/config/config.xml @@ -170,7 +170,7 @@ Automatically hides payment methods in the checkout based on the availability rules for payment methods. Only active payment methods from your mollie dashboard will be shown. If the payment method has a cart limit, currency restriction or billing address restriction, it will be hidden during checkout. Blendet automatisch Zahlungsart im Checkout basierend auf Verfügbarkeitsregeln von Mollie. Es werden nur die aktiven Zahlungsarten aus dem Mollie Dashboard angezeigt. Wenn die Zahlungsart eine Einschränkung auf den Warenkorbwert, Währung oder Rechnungsadresse hat, wird diese auch ausgeblendet. - Verbergt automatisch betaalmethoden in de checkout op basis van Mollie's limieten. Als je bijvoorbeeld alleen creditcardbetalingen tot 500 euro kan accepteren, wordt bij een winkelwagen van 600 euro geen creditcard weergegeven als betaalmethode bij het afrekenen. + Automatische betalingsmethode wordt verborgen tijdens het afrekenen op basis van beschikbaarheidsregels van Mollie. Alleen actieve betalingsmethoden uit het Mollie-dashboard worden weergegeven. Als de betalingsmethode beperkingen heeft op de winkelwagenwaarde, valuta of factuuradres, wordt deze ook verborgen. formatOrderNumber diff --git a/src/Service/Payment/Provider/ActivePaymentMethodsProvider.php b/src/Service/Payment/Provider/ActivePaymentMethodsProvider.php index 86ed66877..bb49496b8 100644 --- a/src/Service/Payment/Provider/ActivePaymentMethodsProvider.php +++ b/src/Service/Payment/Provider/ActivePaymentMethodsProvider.php @@ -52,7 +52,7 @@ public function __construct(MollieApiFactory $mollieApiFactory, MollieOrderPrice * @param array $salesChannelIDs * @return Method[] */ - public function getActivePaymentMethodsForAmount(float $price, string $currency,string $billingCountryCode, array $salesChannelIDs): array + public function getActivePaymentMethodsForAmount(float $price, string $currency, string $billingCountryCode, array $salesChannelIDs): array { if ($price < 0.01) { return []; diff --git a/src/Service/Payment/Provider/ActivePaymentMethodsProviderInterface.php b/src/Service/Payment/Provider/ActivePaymentMethodsProviderInterface.php index e688cab26..90d6f831c 100644 --- a/src/Service/Payment/Provider/ActivePaymentMethodsProviderInterface.php +++ b/src/Service/Payment/Provider/ActivePaymentMethodsProviderInterface.php @@ -15,5 +15,5 @@ interface ActivePaymentMethodsProviderInterface * @param array $salesChannelIDs * @return array */ - public function getActivePaymentMethodsForAmount(float $price, string $currency,string $billingCountryCode, array $salesChannelIDs): array; + public function getActivePaymentMethodsForAmount(float $price, string $currency, string $billingCountryCode, array $salesChannelIDs): array; }