Skip to content

Commit

Permalink
PT-1101 improve payment method filtering based on buyer billing addre…
Browse files Browse the repository at this point in the history
…ss and available net terms (#49)
  • Loading branch information
tikohov20 authored May 28, 2024
1 parent 75801de commit 68e1d5e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
5 changes: 5 additions & 0 deletions Src/Services/ConfigService.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@ public function getOrderFlow()
return self::AUTHORIZATION_FLOW;
}

public function getPaymentMethodNetTerm($method)
{
return $this->config->getValue($method . '_net_term');
}

public static function getInstance() {
$cls = static::class;
if (!isset(self::$instances[$cls])) {
Expand Down
14 changes: 14 additions & 0 deletions frontend/hooks/CheckoutPaymentMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,27 @@ private function filterPaymentMethods(): void
$paymentMethods = $this->smarty->getTemplateVars('Zahlungsarten');
$monduPaymentMethods = [];

$allowedNetTerms = $this->getAllowedNetTerms();

foreach ($paymentMethods as $key => $method) {
if ($method->cAnbieter == 'Mondu') {
$paymentMethodType = $this->configService->getPaymentMethodByKPlugin($method->cModulId);
$monduPaymentMethods[$method->kZahlungsart] = $method->cModulId;

if (!in_array($paymentMethodType, $allowedPaymentMethods)){
unset($paymentMethods[$key]);
continue;
}

$netTerm = (int) $this->configService->getPaymentMethodNetTerm($method->cModulId);

// Installments
if (!$netTerm) {
continue;
}

if (!in_array($netTerm, $allowedNetTerms)) {
unset($paymentMethods[$key]);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<PluginID>MonduPayment</PluginID>
<XMLVersion>100</XMLVersion>
<ShopVersion>5.0.0</ShopVersion>
<Version>3.0.3</Version>
<Version>3.0.4</Version>
<CreateDate>2022-06-07</CreateDate>
<Install>
<Hooks>
Expand Down

0 comments on commit 68e1d5e

Please sign in to comment.