I don't know if it was a bug or feature.
I found that this method had exception on my test store...
public static decimal CalculateAdditionalFee(this IPaymentMethod paymentMethod,
IOrderTotalCalculationService orderTotalCalculationService, IList<ShoppingCartItem> cart,
decimal fee, bool usePercentage)
This method returns decimal, but method
orderTotalCalculationService.GetShoppingCartTotal
can return null value.
The code from the method
//percentage
var orderTotalWithoutPaymentFee = orderTotalCalculationService.GetShoppingCartTotal(cart, usePaymentMethodAdditionalFee: false);
result = (decimal)((((float)orderTotalWithoutPaymentFee) * ((float)fee)) / 100f);
Maybe it will be better to return nullable decimal decimal?.
How to repeat it?
I made Button Payment Method on cart page and wanted to display payment fee on cart page.
Customer was Guest and didb't have any shipment method and any address.
I opened the cart page and I saw the exception...
I solved my problem and added CalculateAdditionalFee in try /catch, but
May be it will be better to change return result.
This is a suggestion.