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:
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)
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.
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.
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);
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:
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:
Thanks,
Alex
Hi Alex
Running latest Tea Commerce?
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
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
Anders, there is 2.3.3 for Umbraco 6 version. Do you think we have to upgrade it to 2.3.5?
Thanks,
Alex
When we visit the page with GeneratePaymentForm method, it generates nothing. No error and no content.
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
Thanks, Anders
Will try to upgrade and hope it will help.
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?
Check the log and see if any errors with payment method happens. Is because an error happens that the button is not generated
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
Hi Paul
What did you change?
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.
Thanks, Paul, can you share the code please. It will be really nice.
/Alex
Called with something like this...
is working on a reply...