# Litium 8 CartContext problems

**URL:** <https://forum.litium.com/t/litium-8-cartcontext-problems/2543>\
**Category:** Questions\
**Created:** [April 15, 2022, 7:20am UTC](https://forum.litium.com/t/litium-8-cartcontext-problems/2543 "2022-04-15T07:20:55Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Robin.w](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/robin.w/32/75_2.png) [@Robin.w](https://forum.litium.com/u/Robin.w)\
**Post date:** [April 15, 2022, 7:20am UTC](https://forum.litium.com/t/litium-8-cartcontext-problems/2543/1 "2022-04-15T07:20:55Z")

</div>

Hi, if for some reason, a payment fails and the cart dose not get fully cleared. The cart, checkout and all its actions start to return 500 error. I think this is a problem with:

var cartContext = HttpContext.GetCartContext();  
But am not sure how to handle it when this state happends.

**Edit: (atleast sometimes) calling: await cartContext.CalculatePaymentsAsync(); with an empty cart causes the samer error**

```auto
Mapping types:
PaymentFlowResult -> PaymentFlowResult
Litium.Connect.Payments.PaymentFlowResult -> Litium.Sales.Payments.PaymentFlowResult

Type Map configuration:
PaymentFlowResult -> PaymentFlowResult
Litium.Connect.Payments.PaymentFlowResult -> Litium.Sales.Payments.PaymentFlowResult

Destination Member:
PaymentFlowAction

 ---> System.InvalidOperationException: There is no result(CreateOrUpdateIframeCheckoutPaymentResult=null).
   at Litium.Connect.Application.Payments.AutoMapperProfiles.Converters.PaymentFlowActionConverter.Convert(PaymentFlowResult sourceMember, ResolutionContext context)
   at lambda_method11554(Closure , PaymentFlowResult , PaymentFlowResult , ResolutionContext )
   --- End of inner exception stack trace ---
   at lambda_method11554(Closure , PaymentFlowResult , PaymentFlowResult , ResolutionContext )
   at lambda_method11555(Closure , Object , Object , ResolutionContext )
   at Litium.Runtime.AutoMapper.AutoMapperExtensions.MapTo[TResult](Object source)
   at Litium.Connect.Application.Payments.PaymentServiceBase.InitializePaymentAsync(Guid paymentSystemId, CartContextSession cartContext, InitializePaymentArgs args)
   at Litium.Application.Sales.Checkout.CheckoutServiceImpl.BuildPaymentFlowResults(CartContextSession cartContext)
   at Litium.Application.Sales.Checkout.CheckoutServiceImpl.InitializePaymentsAsync(CartContextSession cartContext, InitializePaymentsArgs args)
   at Litium.Application.Sales.CartContextSessionServiceImpl.CalculatePaymentsAsync(CartContextSession cartContextSession)
   at Litium.Application.Sales.CartContextSessionServiceImpl.CalculatePaymentsAsync(Guid systemId)
   at Litium.Application.Sales.CartContextImpl.CalculatePaymentsAsync(CancellationToken cancellationToken)
   at Litium.Accelerator.Mvc.Controllers.Api.CartController.Update(AddToCartViewModel model) in D:\a\1\s\Src\Litium.Accelerator.Mvc\Controllers\Api\CartController.cs:line 109

```

Litium version: 8

---

<div class="post-metadata">

**Author:** ![anton.marklars](https://avatars.discourse-cdn.com/v4/letter/a/8e8cbc/32.png) [@anton.marklars](https://forum.litium.com/u/anton.marklars)\
**Post date:** [May 1, 2022, 7:58pm UTC](https://forum.litium.com/t/litium-8-cartcontext-problems/2543/2 "2022-05-01T19:58:05Z")

</div>

We’ve experienced this as well. After it occurs the cartcontext gets “corrupt” preventing users from going to the checkout.

Don’t have much to add in regards to recreating the issue.  
We are using Svea Checkout. Litium version 8.2.3.

---

<div class="post-metadata">

**Author:** ![Robin.w](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/robin.w/32/75_2.png) [@Robin.w](https://forum.litium.com/u/Robin.w)\
**Post date:** [May 10, 2022, 10:15am UTC](https://forum.litium.com/t/litium-8-cartcontext-problems/2543/3 "2022-05-10T10:15:46Z")

</div>

@NilsN Någon ide om hur vi kan komma ut detta state när det händer?

---

<div class="post-metadata">

**Author:** ![jinesh](https://avatars.discourse-cdn.com/v4/letter/j/3e96dc/32.png) [@jinesh](https://forum.litium.com/u/jinesh)\
**Post date:** [May 13, 2022, 6:38am UTC](https://forum.litium.com/t/litium-8-cartcontext-problems/2543/4 "2022-05-13T06:38:30Z")

</div>

This happens from Qliro checkout, as well.  
It seems, this happens when ‘cart-context’ is expired/invalid/corrupted. May be, we need to reset ‘cart-context’ cookie when this happens, if no other way. Ofcourse cart items will be lost  
Qliro app throws error as well, when this happens and can’t load checkout page.  
Should we reset this cookie, in that case or what is the best solution?

---

<div class="post-metadata">

**Author:** ![Robin.w](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/robin.w/32/75_2.png) [@Robin.w](https://forum.litium.com/u/Robin.w)\
**Post date:** [May 13, 2022, 6:44am UTC](https://forum.litium.com/t/litium-8-cartcontext-problems/2543/5 "2022-05-13T06:44:54Z")

</div>

@patric.forsgard any ides?

---

<div class="post-metadata">

**Author:** ![Brandt](https://avatars.discourse-cdn.com/v4/letter/b/7c8e57/32.png) [@Brandt](https://forum.litium.com/u/Brandt)\
**Post date:** [May 19, 2022, 9:14am UTC](https://forum.litium.com/t/litium-8-cartcontext-problems/2543/6 "2022-05-19T09:14:27Z")

</div>

We have the same issue using Klarna and Litium 8.2.3.

We have it both production site and locally. Cant successfully reproduce it in production.  
We can reproduce it locally to get the same log error by cutting off the communication between the app and the local site.

---

<div class="post-metadata">

**Author:** ![Spotonkastebo](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/spotonkastebo/32/717_2.png) [@Spotonkastebo](https://forum.litium.com/u/Spotonkastebo)\
**Post date:** [June 10, 2022, 10:22am UTC](https://forum.litium.com/t/litium-8-cartcontext-problems/2543/7 "2022-06-10T10:22:24Z")

</div>

There is a confirmed bug that possibly is related to this issue [Login](https://docs.litium.com/support/bugs/bug_details?id=60635)

---

<div class="post-metadata">

**Author:** ![patric.forsgard](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/patric.forsgard/32/10_2.png) [@patric.forsgard](https://forum.litium.com/u/patric.forsgard)\
**Post date:** [June 10, 2022, 11:51am UTC](https://forum.litium.com/t/litium-8-cartcontext-problems/2543/8 "2022-06-10T11:51:29Z")

</div>

It have been found 2 other bugs that will be included in up-coming release,

- [Bug 60617](https://docs.litium.com/support/bugs/bug_details?id=60617)
- [Bug 60647](https://docs.litium.com/support/bugs/bug_details?id=60647)

We cant say that this bugs will fix the issue that is experience, we are working on this to capture more logs to get better insight in the underlaying problem.

If you have an active case where we can see this, please send me a message and I can see if that logs have more or other information.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex030/uploads/litium/original/1X/12eddac3b8b661de1db86af10ac8151b571e6fb9.png) [@system](https://forum.litium.com/u/system)\
**Post date:** [July 8, 2022, 11:51am UTC](https://forum.litium.com/t/litium-8-cartcontext-problems/2543/9 "2022-07-08T11:51:55Z")

</div>

Closed on July 8, 2022, 11:51am UTC

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
