Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
markusmichalski-fc committed Jan 17, 2022
2 parents d726979 + b53ee28 commit 941c458
Show file tree
Hide file tree
Showing 7 changed files with 89 additions and 3 deletions.
2 changes: 2 additions & 0 deletions Application/Helper/Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ public function getMolliePaymentInfo($dAmount = false, $sCurrency = false)
$aPaymentInfo[$oItem->id] = [
'title' => $oItem->description,
'pic' => $oItem->image->size2x,
'minAmount' => $oItem->minimumAmount,
'maxAmount' => $oItem->maximumAmount,
];
}
} catch (\Exception $exc) {
Expand Down
48 changes: 48 additions & 0 deletions Application/Model/Payment/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,54 @@ public function isMolliePaymentActive()
return false;
}

/**
* Returnes minimum order sum for Mollie payment type to be usable
*
* @return object|false
*/
public function getMollieFromAmount()
{
$aInfo = Payment::getInstance()->getMolliePaymentInfo();
if (isset($aInfo[$this->sMolliePaymentCode]['minAmount'])) {
return $aInfo[$this->sMolliePaymentCode]['minAmount'];
}
return false;
}

/**
* Returnes maximum order sum for Mollie payment type to be usable
*
* @return object|false
*/
public function getMollieToAmount()
{
$aInfo = Payment::getInstance()->getMolliePaymentInfo();
if (!empty(isset($aInfo[$this->sMolliePaymentCode]['maxAmount']))) {
return $aInfo[$this->sMolliePaymentCode]['maxAmount'];
}
return false;
}

/**
* Checks if given basket brutto price is withing the payment sum limitations of the current Mollie payment type
*
* @param double $dBasketBruttoPrice
* @return bool
*/
public function mollieIsBasketSumInLimits($dBasketBruttoPrice)
{
$oFrom = $this->getMollieFromAmount();
if ($oFrom && $dBasketBruttoPrice < $oFrom->value) {
return false;
}

$oTo = $this->getMollieToAmount();
if ($oTo && $dBasketBruttoPrice > $oTo->value) {
return false;
}
return true;
}

/**
* Returns alternative logo url
*
Expand Down
4 changes: 4 additions & 0 deletions Application/views/admin/de/mollie_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,8 @@
'MOLLIE_SUPPORT_FORM_ENQUIRY_PLACEHOLDER' => 'Wie k&ouml;nnen wir Ihnen helfen?',
'MOLLIE_SUPPORT_FORM_SUBMIT' => 'Absenden',
'MOLLIE_SUPPORT_EMAIL_SENT' => 'Ihre Anfrage wurde erfolgreich versendet. Sie werden eine Kopie der Email erhalten.',
'MOLLIE_PAYMENT_LIMITATION' => 'Mollie Beschr&auml;nkung',
'MOLLIE_PAYMENT_LIMITATION_FROM' => 'Von',
'MOLLIE_PAYMENT_LIMITATION_TO' => 'bis',
'MOLLIE_PAYMENT_LIMITATION_UNLIMITED' => 'unbegrenzt',
);
4 changes: 4 additions & 0 deletions Application/views/admin/en/mollie_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,8 @@
'MOLLIE_SUPPORT_FORM_ENQUIRY_PLACEHOLDER' => 'How can we help you?',
'MOLLIE_SUPPORT_FORM_SUBMIT' => 'Submit',
'MOLLIE_SUPPORT_EMAIL_SENT' => 'Your support enquiry has been sent. You will receive a copy of the email.',
'MOLLIE_PAYMENT_LIMITATION' => 'Mollie limitation',
'MOLLIE_PAYMENT_LIMITATION_FROM' => 'From',
'MOLLIE_PAYMENT_LIMITATION_TO' => 'to',
'MOLLIE_PAYMENT_LIMITATION_UNLIMITED' => 'unlimited',
);
2 changes: 1 addition & 1 deletion extend/Application/Controller/PaymentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ protected function mollieRemoveDeactivatedPaymentTypes()
if (method_exists($oPayment, 'isMolliePaymentMethod') && $oPayment->isMolliePaymentMethod() === true) {
$oBasket = Registry::getSession()->getBasket();
$oMolliePayment = $oPayment->getMolliePaymentModel($oBasket->getPrice()->getBruttoPrice(), $oBasket->getBasketCurrency()->name);
if ($oMolliePayment->isMolliePaymentActive() === false) {
if ($oMolliePayment->isMolliePaymentActive() === false || $oMolliePayment->mollieIsBasketSumInLimits($oBasket->getPrice()->getBruttoPrice()) === false) {
unset($this->_oPaymentList[$oPayment->getId()]);
}
}
Expand Down
5 changes: 4 additions & 1 deletion extend/Core/ViewConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ public function mollieCanShowApplePayButton($dPrice)
$oApplePay = oxNew(\OxidEsales\Eshop\Application\Model\Payment::class);
if (Payment::getInstance()->getMollieMode() == 'live' && $oApplePay->load('mollieapplepay')) { // Apple Pay only available in live mode
if ($oApplePay->oxpayments__oxactive->value == 1 && ($oApplePay->oxpayments__oxfromamount->value <= $dPrice && $oApplePay->oxpayments__oxtoamount->value >= $dPrice)) {
return true;
$oMolliePayment = $oApplePay->getMolliePaymentModel();
if ($oMolliePayment && $oMolliePayment->isMolliePaymentActive() && $oMolliePayment->mollieIsBasketSumInLimits($dPrice) === true) {
return true;
}
}
}
return false;
Expand Down
27 changes: 26 additions & 1 deletion out/blocks/mollie_admin_payment_main_form.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,31 @@
[{if $paymentModel->getCustomConfigTemplate() !== false}]
[{include file=$paymentModel->getCustomConfigTemplate()}]
[{/if}]
<tr><td class="edittext" colspan="2">&nbsp;</td></tr>
<tr>
<td class="edittext" colspan="2">
&nbsp;<div style="display: none;" id="mollie_payment_min_max">
[{assign var="oFrom" value=$paymentModel->getMollieFromAmount() }]
[{assign var="oTo" value=$paymentModel->getMollieToAmount() }]
[{if $oFrom}]<br>
[{oxmultilang ident="MOLLIE_PAYMENT_LIMITATION"}]:<br>
[{oxmultilang ident="MOLLIE_PAYMENT_LIMITATION_FROM"}] [{$oFrom->value}] [{$oFrom->currency}] [{oxmultilang ident="MOLLIE_PAYMENT_LIMITATION_TO"}]
[{if $oTo != false}]
[{$oTo->value}] [{$oTo->currency}]
[{else}]
[{oxmultilang ident="MOLLIE_PAYMENT_LIMITATION_UNLIMITED"}]
[{/if}]
[{/if}]
</div>
<script>
function appendMinMaxInfo() {
var minMaxInfo = document.getElementById("mollie_payment_min_max");
var clone = minMaxInfo.cloneNode(true);
clone.style.display = "";
document.getElementById("helpText_HELP_PAYMENT_MAIN_AMOUNT").parentNode.appendChild(clone);
}
setTimeout(appendMinMaxInfo, 100);
</script>
</td>
</tr>
[{/if}]
[{$smarty.block.parent}]

0 comments on commit 941c458

Please sign in to comment.