Developer forum

Forum » Ecommerce - Standard features » The Context.GetCart() is not a cart and cannot be updated.

The Context.GetCart() is not a cart and cannot be updated.

Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi guys,

We have an issue updating one of our integration with a payment provider.

We used to have a problem with concurrent access to the order, posted here: https://doc.dynamicweb.com/forum/development/development/system-data-dbconcurrencyexception-concurrency-violation-in-payment-provider

Based on the feedback we got, we have updated the solution to the latest version, hoping that the fix for Context.GetCart(0 would solve our problem.

Now, we get a permanent error about updating the order: 

The Context.GetCart() is not a cart and cannot be updated. (Order.IsCart = False, Order.Complete = True, Order.AutoId = 1477, SessionCartKey = EcomCart)
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.Exception Details: System.Exception: The Context.GetCart() is not a cart and cannot be updated. (Order.IsCart = False, Order.Complete = True, Order.AutoId = 1477, SessionCartKey = EcomCart)Source Error:An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[Exception: The Context.GetCart() is not a cart and cannot be updated. (Order.IsCart = False, Order.Complete = True, Order.AutoId = 1477, SessionCartKey = EcomCart)]
   Dynamicweb.Ecommerce.Common.Context.GetCart(OrderContext orderContext) +479
   Dynamicweb.Ecommerce.LiveIntegration.NotificationSubscribers.PageLoaded.OnNotify(String notification, NotificationArgs args) +727
   Dynamicweb.Extensibility.Notifications.NotificationManager.Notify(String notification, NotificationArgs eventArgs) +875
   Dynamicweb.Frontend.PageView.Load() +2545
   Dynamicweb.Frontend.DynamicwebHttpHandler.ProcessRequest(HttpContext context) +186
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +542
   System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +75
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +93

I have attached 2 files, one with a screenshot of the error and the other with a log.
Somehow, it seems there is a cookie still present that might confuse the code into thinking there is still a cart active:

Dynamicweb:Ecom:Cart12576

I am wondering if this is a DW bug or if we do something wrong.

Thank you,
Adrian

 

image_(1).png

Replies

 
Nicolai Pedersen
Reply

I think something is wrong in your checkouthandler. It seems like you do not handle the completion of the order correct. Can we see your code?

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Nicolai,

After reading your message we have started cleaning up the code in order to provide it to you and we have possibly found the issue.

We have not called SetOrderComplete on the right Redirect call of the checkout handler.
There are two types of response from the payment provider :
- one that redirects the user to our site (Default.aspx?ID=3429&CheckoutHandlerOrderID=ORDER828&returnUrl=true) ; this had the context and the User
- and one (or many) that notifies the status (/Default.aspx?ID=3429&CheckoutHandlerOrderID=ORDER828&returnUrl=false); this does not have the context and the User

When SetOrderComplete is called the cart is cleared with its cookies and cart session information.
The function that clears the cart tries to find the User but the User can be found only from the redirect that returns the user to our site;
the notifications do not have the context information and the user.
The initial setup was to call SetOrderComplete on the notifications because that was the first one received. 

In the documentation, I have seen that SetOrderComplete is called on "Callback" and we have considered that the notifications for this provider are the equivalent of the "Callback". 

For now, the problem seems to be gone.

Thank you for enabling me :)

Adrian

 
Jose Caudevilla
Reply

Hi,

 

I have the same problem with a credit cart TPV but i cant solve it.

I have a custom checkoutHandler that generates a form action. One of this TPV parameters is a ok/error url redirection.

This form call to a externar TPV url, when the buy process is correct i redirect to my cart website.

Then is when the checkoutHandler executes again and i check the cart step to set the order complete.

 

   public override string StartCheckout(Order order)
   {
            if (order.CartV2StepIndex == 3)
            {
                SetOrderComplete(order);
                return "";
            }
                //rest of the code

   }

 

 

It doesn´t work. Do you know whats wrong? 

Thank you,

Jose.

 

 

 
Nicolai Pedersen
Reply

Can we see more of your code. Using a check on stepindex is not a good idea as that can change etc.

On your callback arrives and where you process that, you have to call SetOrderComplete - not on startcheckout

 
Mario Santos Dynamicweb Employee
Mario Santos
Reply

Hi guys,

We are experiencing a similar issue with CyberSource on DW 9.8.9 - https://www.screencast.com/t/rAnwaHCdP 

On the callback the user is no longer logged in - it also logs out from backoffice. This is standard CyberSource, any idea?

BR, Mario

 

 
Scott Forsyth Dynamicweb Employee
Scott Forsyth
Reply

Hello,

I just had this same issue reported today too. It's on a recently upgraded site, from 9.5.5 to 9.8.9. The error message is below.

The order completed; payment was received (authorize.net) and the cart changed to an order and OrderComplete from 0 to 1. The emails went out, and the order was successfully transferred to the ERP. However, the end customer received the error message in the image below.  I would be happy to pass along the log files for this order if it would help. I didn't see any exceptions or anything unusual except for one thing that appears unusual. After the order completed and the email notification completed, there was an extra redirect back to the payment processor: Dynamicweb.Ecommerce.CheckoutHandlers.AuthorizeNet.AuthorizeNet Printing relay template

Along with the other information in this thread, maybe this adds something. Otherwise, I can provide further info.

Thanks,

Scott

 
Nicolai Pedersen
Reply

Hi

We have created TFS#83368 and is looking into the issue. It can be errors in the gateways. 

BR Nicolai

 
Nicolai Pedersen
Reply

Hi Again

Apparently TFS#82352 should fix this: https://www.nuget.org/packages/Dynamicweb.Ecommerce/1.8.96

 
Mario Santos Dynamicweb Employee
Mario Santos
Reply

Hi Nicolai,

Unfortunately it doesn't seem to have fixed it - https://www.screencast.com/t/VQka3p5BoMja

BR, Mario

 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi Nicolai,

 

Any news on this. We have a pending website going live and some other live websites with this error.

  • We still experience getting logged out (frontend and backend) after an order being placed with a brand new user
    The SessionId is different after the callback from a Payment Provider

 

Best Regards,

Nuno Aguiar

 
Nicolai Pedersen
Reply

TFS#83368, Dynamicweb Ecommerce 1.8.99, see https://doc.dynamicweb.com/downloads/releases/bug-fixes/known-bugs#2052

 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi Nicolai,

 

Thanks. That looks promising. We'll keep an eye out for that version to be released.

 

Nuno

 
Nicolai Pedersen
Reply

It is: https://www.nuget.org/packages/Dynamicweb.Ecommerce

 
Kristian Kirkholt Dynamicweb Employee
Kristian Kirkholt
Reply

Hi All

This is fixed in Package : Dynamicweb.Ecommerce
Version : 1.8.99

Also this is part of Dynamicweb version 9.8.11 and 9.9.0

These in download section

https://doc.dynamicweb.com/downloads/releases

Kind Regards
Dynamicweb Support
Kristian Kirkholt 

 

You must be logged in to post in the forum