Skip to content

Commit 68e1d5e

Browse files
authored
PT-1101 improve payment method filtering based on buyer billing address and available net terms (#49)
1 parent 75801de commit 68e1d5e

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

Src/Services/ConfigService.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,11 @@ public function getOrderFlow()
130130
return self::AUTHORIZATION_FLOW;
131131
}
132132

133+
public function getPaymentMethodNetTerm($method)
134+
{
135+
return $this->config->getValue($method . '_net_term');
136+
}
137+
133138
public static function getInstance() {
134139
$cls = static::class;
135140
if (!isset(self::$instances[$cls])) {

frontend/hooks/CheckoutPaymentMethod.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,27 @@ private function filterPaymentMethods(): void
6262
$paymentMethods = $this->smarty->getTemplateVars('Zahlungsarten');
6363
$monduPaymentMethods = [];
6464

65+
$allowedNetTerms = $this->getAllowedNetTerms();
66+
6567
foreach ($paymentMethods as $key => $method) {
6668
if ($method->cAnbieter == 'Mondu') {
6769
$paymentMethodType = $this->configService->getPaymentMethodByKPlugin($method->cModulId);
6870
$monduPaymentMethods[$method->kZahlungsart] = $method->cModulId;
6971

7072
if (!in_array($paymentMethodType, $allowedPaymentMethods)){
7173
unset($paymentMethods[$key]);
74+
continue;
75+
}
76+
77+
$netTerm = (int) $this->configService->getPaymentMethodNetTerm($method->cModulId);
78+
79+
// Installments
80+
if (!$netTerm) {
81+
continue;
82+
}
83+
84+
if (!in_array($netTerm, $allowedNetTerms)) {
85+
unset($paymentMethods[$key]);
7286
}
7387
}
7488
}

info.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<PluginID>MonduPayment</PluginID>
88
<XMLVersion>100</XMLVersion>
99
<ShopVersion>5.0.0</ShopVersion>
10-
<Version>3.0.3</Version>
10+
<Version>3.0.4</Version>
1111
<CreateDate>2022-06-07</CreateDate>
1212
<Install>
1313
<Hooks>

0 commit comments

Comments
 (0)