Skip to content

Commit

Permalink
NTR: set billing address from cart
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitalij Mik committed Feb 9, 2024
1 parent 5ff9d21 commit 0fae6e1
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ public function removePaymentMethods(PaymentMethodRouteResponse $originalData, S
if (!$this->isAllowedRoute()) {
return $originalData;
}
$billingAddress = null;
$countryIsoCode = null;

if ($this->isCartRoute()) {
try {
Expand All @@ -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 {
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/app/administration/src/snippet/de-DE.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/app/administration/src/snippet/en-GB.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/app/administration/src/snippet/nl-NL.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
"failed": "De betaalmethoden konden niet worden geupdated."
},
"mollieLimits": {
"link": "Open betalingslimieten van Mollie"
"link": "Toon Mollie-beschikbaarheidsregels voor betaalmethoden"
}
},
"rounding": {
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/config/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@
<label lang="nl-NL">Gebruik de beschikbaarheidsregels van Mollie voor betaalmethoden</label>
<helpText>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.</helpText>
<helpText lang="de-DE">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.</helpText>
<helpText lang="nl-NL">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.</helpText>
<helpText lang="nl-NL">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.</helpText>
</input-field>
<input-field type="text">
<name>formatOrderNumber</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function __construct(MollieApiFactory $mollieApiFactory, MollieOrderPrice
* @param array<mixed> $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 [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ interface ActivePaymentMethodsProviderInterface
* @param array<string> $salesChannelIDs
* @return array<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;
}

0 comments on commit 0fae6e1

Please sign in to comment.