Error in GetPaymentMethods() if no shippingaddress
I need to call TransactionLibrary.GetPaymentMethods() before I create the shipping address, but when I try I get an error. I have tried with TransactionLibrary.GetPaymentMethods(TransactionLibrary.GetCountries().FirstOrDefault()) also.
As you see in the error message the UCommerce.Transactions.TransactionLibraryInternal.GetPaymentMethods expect a shippingAddressName, but why?
Object reference not set to an instance of an object.
This is because paymentmethods are configured to have a list of enabled countries of which the paymentmethod is available because you can have multiple stores and customers globally.
So whenever you send a country it would get a list of paymentmethods available for that country. No problem.
If you don't send anything it would find the shippingaddress on the basket and look for that country. So if no context is found (country), no paymentmethods could be found. So if there's no country on the shippingaddress (or the shippingaddress is null), you'll get a problem.
When I call it with a country like this "TransactionLibrary.GetPaymentMethods(TransactionLibrary.GetCountries().FirstOrDefault())" the internal function still looks for a shippingAddressName so I don't think that is the solution.
It defaults to GetPaymentMethods() if TransactionLibrary.Getcountries().FirstOrDefault() returns null, so my guess is that it does so, and defaults to GetPaymentMethods(). Can you verify what GetCountries().FirstOrDefault() returns?
I got it to work now by calling the TransactionLibrary.GetPaymentMethods(TransactionLibrary.GetCountries().FirstOrDefault()) so I don't know what was wrong in the first place :)
Error in GetPaymentMethods() if no shippingaddress
I need to call TransactionLibrary.GetPaymentMethods() before I create the shipping address, but when I try I get an error. I have tried with TransactionLibrary.GetPaymentMethods(TransactionLibrary.GetCountries().FirstOrDefault()) also.
As you see in the error message the UCommerce.Transactions.TransactionLibraryInternal.GetPaymentMethods expect a shippingAddressName, but why?
Object reference not set to an instance of an object.
System.Collections.Generic.ICollection`1[UCommerce.EntitiesV2.PaymentMethod] GetPaymentMethods(System.String)
at UCommerce.Transactions.TransactionLibraryInternal.GetPaymentMethods(String shippingAddressName)
at Castle.Proxies.Invocations.TransactionLibraryInternal_GetPaymentMethods.InvokeMethodOnTarget()
at Castle.DynamicProxy.AbstractInvocation.Proceed()
at UCommerce.Infrastructure.Interceptor.ExceptionLoggingInterceptor.Intercept(IInvocation invocation)
at UCommerce.Infrastructure.Interceptor.ExceptionLoggingInterceptor.Intercept(IInvocation invocation)
at Castle.DynamicProxy.AbstractInvocation.Proceed()
at Castle.Proxies.TransactionLibraryInternalProxy.GetPaymentMethods(String shippingAddressName)
at Castle.Proxies.Invocations.TransactionLibraryInternal_GetPaymentMethods_1.InvokeMethodOnTarget()
at Castle.DynamicProxy.AbstractInvocation.Proceed()
at UCommerce.Infrastructure.Interceptor.ExceptionLoggingInterceptor.Intercept(IInvocation invocation)
at Castle.DynamicProxy.AbstractInvocation.Proceed()
at Castle.Proxies.TransactionLibraryInternalProxy.GetPaymentMethods(Country country)
at ASP._Page_macroScripts_uCommerce_Address_cshtml.Execute()
at System.Web.WebPages.WebPageBase.ExecutePageHierarchy()
at System.Web.WebPages.WebPage.ExecutePageHierarchy()
at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage)
at umbraco.MacroEngines.RazorMacroEngine.ExecuteRazor(MacroModel macro, INode currentPage)
at umbraco.MacroEngines.RazorMacroEngine.Execute(MacroModel macro, INode currentPage)
at umbraco.macro.loadMacroScript(MacroModel macro)
at umbraco.macro.renderMacro(Hashtable pageElements, Int32 pageId)
at umbraco.presentation.templateControls.Macro.CreateChildControls()
at System.Web.UI.Control.EnsureChildControls()
at System.Web.UI.Control.InitRecursive(Control namingContainer)
at System.Web.UI.Control.InitRecursive(Control namingContainer)
at System.Web.UI.Control.InitRecursive(Control namingContainer)
at System.Web.UI.Control.InitRecursive(Control namingContainer)
at System.Web.UI.Control.InitRecursive(Control namingContainer)
at System.Web.UI.Control.InitRecursive(Control namingContainer)
at System.Web.UI.Control.InitRecursive(Control namingContainer)
at System.Web.UI.Control.InitRecursive(Control namingContainer)
at System.Web.UI.Control.InitRecursive(Control namingContainer)
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.ProcessRequest(HttpContext context)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
at System.Web.HttpApplication.PipelineStepManager.ResumeSteps(Exception error)
at System.Web.HttpApplication.BeginProcessRequestNotification(HttpContext context, AsyncCallback cb)
at System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context)
at System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr rootedObjectsPointer, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)
at System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr rootedObjectsPointer, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)
at System.Web.Hosting.UnsafeIISMethods.MgdIndicateCompletion(IntPtr pHandler, RequestNotificationStatus& notificationStatus)
at System.Web.Hosting.UnsafeIISMethods.MgdIndicateCompletion(IntPtr pHand...
Hi Kim,
This is because paymentmethods are configured to have a list of enabled countries of which the paymentmethod is available because you can have multiple stores and customers globally.
So whenever you send a country it would get a list of paymentmethods available for that country. No problem.
If you don't send anything it would find the shippingaddress on the basket and look for that country. So if no context is found (country), no paymentmethods could be found. So if there's no country on the shippingaddress (or the shippingaddress is null), you'll get a problem.
Hi Morten,
When I call it with a country like this "TransactionLibrary.GetPaymentMethods(TransactionLibrary.GetCountries().FirstOrDefault())" the internal function still looks for a shippingAddressName so I don't think that is the solution.
It defaults to GetPaymentMethods() if TransactionLibrary.Getcountries().FirstOrDefault() returns null, so my guess is that it does so, and defaults to GetPaymentMethods(). Can you verify what GetCountries().FirstOrDefault() returns?
I got it to work now by calling the TransactionLibrary.GetPaymentMethods(TransactionLibrary.GetCountries().FirstOrDefault()) so I don't know what was wrong in the first place :)
Allright Good to know :)
is working on a reply...