Developer forum

Forum » Development » Problem med Cartv2

Problem med Cartv2


Reply
It sounds weird but nevertheless here is our case:

I have build a content-module that subscribes a user to an external system and then afterwards adds a specific product from the ecommerce catalog to a new CART

URL:
http://www.alderspiloterne.dk/Forside/Bliv-medlem/Tilmelding.aspx?ProductId=900792e0-29ca-49ce-8e13-88960df8da22 

Code:

Dynamicweb.eCommerce.Products.Product plusProduct = new Dynamicweb.eCommerce.Products.Product( "PROD7" );
Order o = Dynamicweb.eCommerce.Common.Context.Cart;
if ( o == null )
{
o = new Order();
o.IsCart = true;
o.LanguageID = "LANG1";
o.IP = HttpContext.Current.Request.ServerVariables[ "REMOTE_ADDR" ];
o.ShopID = "SHOP1";
o.StateID = "OS1";
o.Save();
}
o.CustomerAddress = sub.Address1;
o.CustomerAddress2 = sub.Address2;
o.CustomerCell = sub.Mobile;
o.CustomerCity = sub.City;
o.CustomerCountry = sub.Country;
o.CustomerEmail = sub.Email;
o.CustomerName = sub.Name;
o.CustomerNumber = sub.id.ToString();
o.CustomerPhone = sub.Phone;
o.CustomerZip = sub.Zipcode;

o.OrderLines.Add( new OrderLine( plusProduct ) { Order = o, Type = "0", Reference = "", BOMItemID = "", ParentLineID = "", DiscountID = "" } );
o.Save();
Dynamicweb.eCommerce.Common.Context.SetCart( o );
HttpContext.Current.Session[ "subscription" ] = sub;
HttpContext.Current.Response.Redirect( "/Default.aspx?ID=146", true);

Now the user gets redirected to the cart and has to go through standard checkout in the CartV2 module.

But the problem is that we go succesfull through payment but no one ever gets an email out of the completed order.

We have this orderextender:

[Dynamicweb.Extensibility.Subscribe( Dynamicweb.Ecom7.Cart.Notifications.CheckoutDoneOrderIsComplete )]
public class OrderExtenderPlusMembership : Dynamicweb.Extensibility.NotificationSubscriber
{
public override void OnNotify( string notification, Dynamicweb.Extensibility.NotificationArgs args )
{
Dynamicweb.Ecom7.Cart.Notifications.CheckoutDoneOrderIsCompleteArgs arg = args as Dynamicweb.Ecom7.Cart.Notifications.CheckoutDoneOrderIsCompleteArgs;
List<Dynamicweb.eCommerce.Orders.OrderLine> ols = arg.Order.OrderLines.Cast<Dynamicweb.eCommerce.Orders.OrderLine>().ToList();
if ( ols.Where( ol => ol.ProductID.Equals( "PROD7" ) ).Count() > 0 )
{
subscription s = new subscription();
wsSubscriptions.Subscription sub = HttpContext.Current.Session[ "subscription" ] as wsSubscriptions.Subscription;
s.SendConfirmationMail( sub );
}

base.OnNotify( notification, args );
}
public override void OnNotify( string notification, object[] args )
{
}

}

In the Order LOG we get this information:

[10/26/2010 9:15:01 PM]:
Order AP-77: Unexpected exception with the message: Object reference not set to an instance of an object.

Logging 'Session':
DW_Statv2Session_Statv2SessionID: 1525
SessionStatDone: True
Ecom.Units: 
Ecom.SelectedLangID: 'LANG1'
Ecom.CurrencyCode: 'DKK'
AddIn_xmlPar: '<?xml version="1.0" encoding="utf-8"?><Parameters><Parameter addin="Dynamicweb.Ecom7.Cart.QuickPay3" name="Merchant" value="*******" /><Parameter addin="Dynamicweb.Ecom7.Cart.QuickPay3" name="Secret key" value="***************" /><Parameter addin="Dynamicweb.Ecom7.Cart.QuickPay3" name="Card type" value="" /><Parameter addin="Dynamicweb.Ecom7.Cart.QuickPay3" name="Post mode" value="Template" /><Parameter addin="Dynamicweb.Ecom7.Cart.QuickPay3" name="Post template" value="eCom7/CheckoutHandler/QuickPay 3/Post/Alderspiloterne_Post.html" /><Parameter addin="Dynamicweb.Ecom7.Cart.QuickPay3" name="Cancel template" value="eCom7/CheckoutHandler/QuickPay 3/Cancel/alderspiloterne_checkouthandler_cancel.html" /><Parameter addin="Dynamicweb.Ecom7.Cart.QuickPay3" name="Error template" value="eCom7/CheckoutHandler/QuickPay 3/Error/alderspiloterne_checkouthandler_error.html" /><Parameter addin="Dynamicweb.Ecom7.Cart.QuickPay3" name="Test mode" value="False" /></Parameters>'
------------------------------------------------------------


Logging 'Stack Trace':
   at System.Environment.GetStackTrace(Exception e, Boolean needFileInfo)
   at System.Environment.get_StackTrace()
   at Dynamicweb.LogToFile.Log(String message, String folder, LogType newLogFile, Boolean useExtendedPropertyLogging, LogElements logElements)
   at Dynamicweb.Ecom7.Cart.Frontend.LogError(Order order, String message, Object[] params)
   at Dynamicweb.Ecom7.Cart.Frontend.CheckoutDone(Order order)
   at Dynamicweb.Ecom7.Cart.CheckoutHandler.CheckoutDone(Order order)
   at Dynamicweb.Ecom7.Cart.QuickPay3.Callback(Order order)
   at Dynamicweb.Ecom7.Cart.QuickPay3.Redirect(Order order)
   at Dynamicweb.Ecom7.Cart.CheckoutHandler.RedirectToCheckoutHandler()
   at Dynamicweb.Ecom7.Cart.Frontend.GetContent()
   at Dynamicweb.Frontend.Content.getModule(DataRow& ParagraphRow)
   at Dynamicweb.Frontend.Content.WriteParagraph(ParagraphTemplateJoinClass PTRecord)
   at Dynamicweb.Frontend.Content.CreateParagraph(StringBuilder strContent, ParagraphTemplateJoinClass PTRecord, Int32& TemplateParagraphsWriten, Int32& TemplateParagraphsNotWriten, Int32& TemplateParagraphsColumn, String& SpaceBeforeParagraph, Template& paragraphSetupTemplate, Properties& ModuleSettings)
   at Dynamicweb.Frontend.Content.CreateContentEXE()
   at Dynamicweb.Frontend.Content.CreateContent(Int32 PageID)
   at Dynamicweb.Frontend.Content.getContent(Int32 PageID)
   at Dynamicweb.Frontend.PageView.SetPageTemplateValues()
   at Dynamicweb.Frontend.PageView.Output()
   at Dynamicweb.Frontend.PageviewControl.ParseControls()
   at Dynamicweb.Admin.Load.Page_Load(Object sender, EventArgs e)
   at System.Web.UI.Control.OnLoad(EventArgs e)
   at System.Web.UI.Control.LoadRecursive()
   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.default_aspx.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.ApplicationStepManager.ResumeSteps(Exception error)
   at System.Web.HttpApplication.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData)
   at System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr)
   at System.Web.HttpRuntime.ProcessRequestNoDemand(HttpWorkerRequest wr)
   at System.Web.Hosting.ISAPIRuntime.ProcessRequest(IntPtr ecb, Int32 iWRType)
------------------------------------------------------------

It's pretty easy to reproduce but pretty hard to explain since:
1. If we go through checkout with standard Cart templates it WORKS!!!
2. If we go with custom Cart templates but with other products that are added to cart the normal DW way it also works.

How the heck do get information about WHAT object that causes the exception: 
Order AP-77: Unexpected exception with the message: Object reference not set to an instance of an object.?

Replies

 
Nicolai Høeg Pedersen
Reply
That was an evil one...

It looks like you are getting the stack trace from the logging method and not from the exception - that could be a bug in our exception handling.

In your Dynamicweb.Ecom7.Cart.Notifications.CheckoutDoneOrderIsComplete notification subscriber, try "try catching" the OnNotify method and write out the entire exception - that way you should be able to get the proper exception message.

It looks like that notification subscriber is the issues since you only have problem with that one product - and you run a piece of code in that for only that product:
if ( ols.Where( ol => ol.ProductID.Equals( "PROD7" ) ).Count() > 0 )
{
subscription s = new subscription();
wsSubscriptions.Subscription sub = HttpContext.Current.Session[ "subscription" ] as wsSubscriptions.Subscription;
s.SendConfirmationMail( sub );
}
 
Reply
Thanks for using time to solve this - the problem is solved.
What I didn't knew was that it is actually QuickPay that calls the Dynamicweb CheckoutHandler that fires the Notification "CheckoutDoneOrderIsCompleted" it's not the users browser that fires the Notification!

That means we can't use Session og Cookies to store temporary data, we need to have some infomation follow the order and look up the information needed.

 

You must be logged in to post in the forum