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.
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:
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.?
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.?