Developer forum

Forum » Development » Complete order by code gets invalid state error

Complete order by code gets invalid state error

Jose Caudevilla
Reply

Hi:

I am trying to get the orders complete using c# code.

The reason is that the TPV that we use sometimes does not redirect to our website.

So what i do is receive the transaction log of the TPV and complete the order by code with the log information.

The way that i complete the order is the next:

 

                    if (order != null)
                    {
                        //orderService.UpdateCartToOrder(order);
                        orderService.Complete(order);
                        order.StateId = "OS1";
                        orderService.Save(order);
                        Dynamicweb.Logging.LogManager.Current.GetLogger("RedsysLog").Log("Order Complete");
                    }

If i use the updateCartToOrder function it does not complete the order and generates other orderId.

With this code, order are complete but i get this error:

 

The error is in the line  orderService.Save(order);

 

Is there any way to complete the order with initial state?

 

Regards ,

Jose

 


Replies

 
Jose Caudevilla
Reply

Hi:

 

Does anyone have any ideas?

This error appear a lot of times on the monitor server and it makes the server run slow.

 

Regards,

Jose.

 

 

You must be logged in to post in the forum