Skip to content

Commit

Permalink
Check if surcharge array key exists.
Browse files Browse the repository at this point in the history
  • Loading branch information
inpsyde-maticluznar committed Sep 19, 2023
1 parent 1a32c39 commit 3e7c756
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/Gateway/Surcharge.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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;
}

/**
Expand Down Expand Up @@ -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
);
}

/**
Expand Down

0 comments on commit 3e7c756

Please sign in to comment.