Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Alex Skrypnyk 5363 posts 19800 karma points MVP 3x admin c-trib
    Mar 09, 2017 @ 11:16
    Alex Skrypnyk
    0

    Strange error - NullReferenceException in GeneratePaymentForm

    Hello

    We have a strange error, sometimes customers are not able to make payments on site. Customer fo through payment steps and on the step that goes to ePay, we don't see submit button. Which is rendering with this code:

    @Html.Raw(TC.GeneratePaymentForm( storeId, "<input type=\"submit\" class=\"btn btn-brown btn-success\" id=\"next\" value=\"" + @nextStepValue + "\" /><input type=\"submit\" class=\"btn btn-brown btn-success\" value=\">\" />" ) )
    

    The strangest is that this problem appears sometimes and after restart of application it's not appearing for some time, then again.

    In the log we have some information:

    2017-03-09 09:22:11,337 [6] ERROR Umbraco.Core.UmbracoApplicationBase - [Thread 38] An unhandled exception occurred
    System.Web.HttpUnhandledException (0x80004005): Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.NullReferenceException: Object reference not set to an instance of an object.
       at TeaCommerce.Umbraco.Application.Views.Orders.EditOrder.SetTransactionPayment(PaymentMethod paymentMethod)
       at TeaCommerce.Umbraco.Application.Views.Orders.EditOrder.OnLoad(EventArgs e)
       at System.Web.UI.Control.LoadRecursive()
       at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
       at System.Web.UI.Page.HandleError(Exception e)
       at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
       at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
       at System.Web.UI.Page.ProcessRequest()
       at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context)
       at System.Web.UI.Page.ProcessRequest(HttpContext context)
       at ASP.umbraco_plugins_tea_commerce_views_orders_editorder_aspx.ProcessRequest(HttpContext context)
       at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
       at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
    

    Thanks,

    Alex

  • Anders Burla Johansen 2560 posts 8256 karma points
    Mar 09, 2017 @ 11:36
    Anders Burla Johansen
    0

    Hi Alex

    Running latest Tea Commerce?

  • Alex Skrypnyk 5363 posts 19800 karma points MVP 3x admin c-trib
    Mar 09, 2017 @ 13:25
    Alex Skrypnyk
    0

    Hi Anders

    Thank you very much for fast response. It's not latest Tea Commerce, it was deployed in November of 2015. Hope it makes any sense for you.

    Thanks,

    Alex

  • Anders Burla Johansen 2560 posts 8256 karma points
    Mar 10, 2017 @ 00:32
    Anders Burla Johansen
    0

    I will need a more specific version. Look in installed packages or maybe the dll files has the version (newer versions does).

    Else - try and update to latest to see if that fix it.

    Kind regards

    Anders

  • Alex Skrypnyk 5363 posts 19800 karma points MVP 3x admin c-trib
    Mar 10, 2017 @ 08:33
    Alex Skrypnyk
    0

    Anders, there is 2.3.3 for Umbraco 6 version. Do you think we have to upgrade it to 2.3.5?

    Thanks,

    Alex

  • Alex Skrypnyk 5363 posts 19800 karma points MVP 3x admin c-trib
    Mar 10, 2017 @ 13:20
    Alex Skrypnyk
    0

    When we visit the page with GeneratePaymentForm method, it generates nothing. No error and no content.

    TC.GeneratePaymentForm(storeId, "<input type=\"submit\" class=\"btn btn-brown btn-success\" id=\"next\" value=\"test\" />   ")
    
  • Anders Burla Johansen 2560 posts 8256 karma points
    Mar 20, 2017 @ 12:06
    Anders Burla Johansen
    100

    If it doesn't generate anything, then it is because an error happens. Try and upgrade to 2.3.5 and see if that fixes it. Properly not, but, just to be sure that you are running the latest version of Tea Commerce 2.

    Kind regards

    Anders

  • Alex Skrypnyk 5363 posts 19800 karma points MVP 3x admin c-trib
    Mar 22, 2017 @ 12:47
    Alex Skrypnyk
    0

    Thanks, Anders

    Will try to upgrade and hope it will help.

  • Paul Wright (suedeapple) 221 posts 604 karma points
    Mar 31, 2017 @ 11:06
    Paul Wright (suedeapple)
    0

    Getting the same problem/Issue on one of my sites too.

    Sometimes the Payment Form//Button dosen't appear.

    Site is hosted on AZURE, on 3.1.1, using STRIPE payment gateway

    Any ideas?

  • Anders Burla Johansen 2560 posts 8256 karma points
    Mar 31, 2017 @ 11:31
    Anders Burla Johansen
    1

    Check the log and see if any errors with payment method happens. Is because an error happens that the button is not generated

  • Paul Wright (suedeapple) 221 posts 604 karma points
    Mar 31, 2017 @ 14:22
    Paul Wright (suedeapple)
    0

    Ahhhhhhhh - found out my blunder.

    Found an edge case/scenario, where a Shipping and Payment Method was being set back to NULL. I've now got something in place to ensure the order has a valid one.

    Thanks anders, sweetheart <3

  • Alex Skrypnyk 5363 posts 19800 karma points MVP 3x admin c-trib
    Apr 02, 2017 @ 15:58
    Alex Skrypnyk
    0

    Hi Paul

    What did you change?

  • Paul Wright (suedeapple) 221 posts 604 karma points
    Apr 02, 2017 @ 16:11
    Paul Wright (suedeapple)
    1

    Just ensured that each Country has a default shipping and payment provider in the back office.

    Also wrote some code to double check the order was fully valid (and not null) before rendering the payment button.

  • Alex Skrypnyk 5363 posts 19800 karma points MVP 3x admin c-trib
    Apr 02, 2017 @ 16:25
    Alex Skrypnyk
    0

    Thanks, Paul, can you share the code please. It will be really nice.

    /Alex

  • Paul Wright (suedeapple) 221 posts 604 karma points
    Apr 02, 2017 @ 19:21
    Paul Wright (suedeapple)
    1
    public static class OrderHelper
    {
    
        /// <summary>
        /// Gets the current order and assigns default shipping and payment methods if not already assigned
        /// </summary>
        /// <param name="storeId"></param>
        /// <returns></returns>
        public static Order GetOrderWithDefaults(long storeId)
        {
            Order order = TC.GetCurrentOrder(storeId, false);
            if (order!=null)
            {
                //set default payment method if none selected
                if (order.PaymentInformation.PaymentMethodId == null)
                {
                    var payMethods = TC.GetPaymentMethods(storeId).ToList();
                    if (payMethods.Count() > 0)
                    {
                        TC.SetCurrentPaymentMethod(storeId, payMethods[0].Id);
                    }
                }
                //set default shipping method if none selected
                if (order.ShipmentInformation.ShippingMethodId == null)
                {
                    var shipMethods = TC.GetShippingMethods(storeId).ToList();
                    if (shipMethods.Count() > 0)
                    {
                        TC.SetCurrentShippingMethod(storeId, shipMethods[0].Id);
                    }
                }
            }
    
            return order;
    
        }
    
    }
    

    Called with something like this...

     //store id
        long storeId = long.Parse(CurrentPage.GetPropertyValue<string>("store", true));
        Order order = OrderHelper.GetOrderWithDefaults(storeId);
    
Please Sign in or register to post replies

Write your reply to:

Draft