Checkout error

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
6 years ago
Hi nop team,
Following error occured today:

Log niveau
Fout
Kort bericht
Nullable object must have a value.
Volledig bericht
System.InvalidOperationException: Nullable object must have a value. at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource) at Nop.Services.Payments.PaymentExtensions.CalculateAdditionalFee(IPaymentMethod paymentMethod, IOrderTotalCalculationService orderTotalCalculationService, IList`1 cart, Decimal fee, Boolean usePercentage) at Nop.Plugin.Payments.PayPalStandard.PayPalStandardPaymentProcessor.GetAdditionalHandlingFee(IList`1 cart) at Nop.Services.Payments.PaymentService.GetAdditionalHandlingFee(IList`1 cart, String paymentMethodSystemName) at Nop.Web.Factories.CheckoutModelFactory.PreparePaymentMethodModel(IList`1 cart, Int32 filterByCountryId) at Nop.Web.Controllers.CheckoutController.PaymentMethod() at lambda_method(Closure , ControllerBase , Object[] ) at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) at System.Web.Mvc.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3d() at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass21.<>c__DisplayClass2b.<BeginInvokeAction>b__1c() at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) at System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) at System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) at System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) at System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) at System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
IP adres
***
Klant
***@hotmail.com
Pagina URL
https://www.***.be/checkout/paymentmethod
Verwijs URL
/ShmFrontEnd/start
Aangemaakt op
8/17/2017 10:32:18 AM


This is the code we have found, does anyone know how to solve this error?
We think the issue should be in the nopcommerce Paypal plugin or in the nopcommerce source code but cannot locate it.
Here is the code:


        /// <summary>
        /// Calculate payment method fee
        /// </summary>
        /// <param name="paymentMethod">Payment method</param>
        /// <param name="orderTotalCalculationService">Order total calculation service</param>
        /// <param name="cart">Shopping cart</param>
        /// <param name="fee">Fee value</param>
        /// <param name="usePercentage">Is fee amount specified as percentage or fixed value?</param>
        /// <returns>Result</returns>
        public static decimal CalculateAdditionalFee(this IPaymentMethod paymentMethod,
            IOrderTotalCalculationService orderTotalCalculationService, IList<ShoppingCartItem> cart,
            decimal fee, bool usePercentage)
        {
            if (paymentMethod == null)
                throw new ArgumentNullException("paymentMethod");
            if (fee <= 0)
                return fee;

            decimal result;
            if (usePercentage)
            {
                //percentage
                var orderTotalWithoutPaymentFee = orderTotalCalculationService.GetShoppingCartTotal(cart, usePaymentMethodAdditionalFee: false);
                result = (decimal)((((float)orderTotalWithoutPaymentFee) * ((float)fee)) / 100f);
            }
            else
            {
                //fixed value
                result = fee;
            }
            return result;
        }



Hoping someone can help us out with this!

Thx Bart
6 years ago
I think it would be really helpful if you add following information.

a.m. wrote:

1. nopCommerce version
2. Any private modifications you made to your nopCommerce
3. The version of MS SQL database you're running nopCommerce with
4. Anything else that could possibly be relevant. Err on the side of too much information, rather than too little.
6 years ago
Hi, I'm a colleague of the OP.

nopCommerce version
v3.9
Any private modifications you made to your nopCommerce
- Implemented custom Ogone payment provider
- Added BPost integration (shipping provider)
The version of MS SQL database you're running nopCommerce with
- SQL Server 2012
Anything else that could possibly be relevant. Err on the side of too much information, rather than too little.
From what I can tell from the code it seems as if the orderTotalCalculationService is the only thing that can lead to an 'Nullable object must have a value' exception.
Assuming that 'throw new ArgumentNullException("paymentMethod");' would show a different exception message.

If not, what could cause the paymentmethod to be null? I suppose it's a mandatory step to be able to get to the payment step.
6 years ago
Divyang wrote:
I think it would be really helpful if you add following information.


1. nopCommerce version
2. Any private modifications you made to your nopCommerce
3. The version of MS SQL database you're running nopCommerce with
4. Anything else that could possibly be relevant. Err on the side of too much information, rather than too little.


Hi Divyang,
my colleague provided all the info, can you perhaps help us further?
Thx Bart
6 years ago
bart.m84 wrote:

my colleague provided all the info, can you perhaps help us further?


Hi Bart,

Not sure, where is the actual issue, is it in your source code? then debug and check.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.