From 3e7c7563d0f31b969e6e7a9d94239b7ceaf73b8c Mon Sep 17 00:00:00 2001 From: inpsyde-maticluznar Date: Tue, 19 Sep 2023 13:48:58 +0200 Subject: [PATCH] Check if surcharge array key exists. --- src/Gateway/Surcharge.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Gateway/Surcharge.php b/src/Gateway/Surcharge.php index 17340bf4..8bb077a0 100644 --- a/src/Gateway/Surcharge.php +++ b/src/Gateway/Surcharge.php @@ -105,6 +105,10 @@ public function aboveMaxLimit(float $totalAmount, array $gatewaySettings): bool */ public function calculateFeeAmount(WC_Cart $cart, array $gatewaySettings): float { + if (!isset($gatewaySettings['payment_surcharge'])) { + return 0.0; + } + $surchargeType = $gatewaySettings['payment_surcharge']; $methodName = sprintf('calculate_%s', $surchargeType); @@ -154,7 +158,7 @@ protected function calculate_no_fee(WC_Cart $cart, array $gatewaySettings): floa */ protected function calculate_fixed_fee($cart, array $gatewaySettings) { - return !empty($gatewaySettings[Surcharge::FIXED_FEE]) ? (float) $gatewaySettings[Surcharge::FIXED_FEE] : 0.0; + return !empty($gatewaySettings[Surcharge::FIXED_FEE]) ? (float)$gatewaySettings[Surcharge::FIXED_FEE] : 0.0; } /** @@ -294,7 +298,12 @@ protected function name_fixed_fee_percentage($paymentMethod) $currency = get_woocommerce_currency_symbol(); $amountPercent = $paymentMethod->getProperty(self::PERCENTAGE); /* translators: Placeholder 1: Fee amount tag. Placeholder 2: Currency. Placeholder 3: Percentage amount. */ - return sprintf(__(' + %1$s %2$s + %3$s%% fee might apply', 'mollie-payments-for-woocommerce'), $currency, $amountFix, $amountPercent); + return sprintf( + __(' + %1$s %2$s + %3$s%% fee might apply', 'mollie-payments-for-woocommerce'), + $currency, + $amountFix, + $amountPercent + ); } /**