Adyen payment error when payment gets captured

I have two strange thing happening when using the Litium Adyen payment app.

I subscribe to the SalesOrderConfirmed event and when that happens I create a shipment and push it to processing state.

  _eventBroker.Subscribe<SalesOrderConfirmed>(async x =>
  {               
      var shipment = await _shipmentManager.Create(x.Item.SystemId, new CreateShipmentArgs
      {
          Rows = x.Item.Rows.Where(salesOrderRow => salesOrderRow.OrderRowType == OrderRowType.Product)
              .Select(salesOrderRow => new ProductToShipRow
              {
                  Quantity = salesOrderRow.Quantity,
                  ArticleNumber = salesOrderRow.ArticleNumber
              }).ToList(),
          ShippingMethod = x.Item.ShippingInfo.First().ShippingOption.OptionId,
          Address = shippingAddress
      });

      using (_securityContextService.ActAsSystem())
      {
          _shipmentService.Create(shipment);
      }

      var stateTransitionResult = _stateTransitionsService.SetState<Sales.Shipment>(shipment.SystemId, ShipmentState.Processing);
  });
  1. Everything looks fine but this can be seen in the logs
2023-09-15 15:47:33.4371 [App:01] [0153291ab07650b962e98e425b93cb37] [DEBUG] [.NET ThreadPool Worker] Litium.StateTransitions.StateTransitionsService - Changing state to Processing on Litium.Sales.SalesReturnOrder (38402101-b076-48af-bd71-fd5116cfeb83) for state machine SalesReturnOrder result in failure for Litium.Sales.Shipment (843ccf9f-241d-4c0e-9f6a-7166e4d8062d) at Litium.Application.StateTransitions.State`1[Litium.Sales.Shipment], Invalid transition, there is no transition from Init to Processing Litium.Application.StateTransitions.InvalidStateTransitionException: Invalid transition, there is no transition from Init to Processing
   at Litium.Application.StateTransitions.FiniteStateMachine`1.TransitionAction(String nextStateId, Guid entitySystemId)
   at Litium.Application.StateTransitions.StateTransitionsServiceImpl.StateTransitionEngine`1.SetState(Guid entitySystemId, String nextStateId)

I don’t get why it thinks it’s a Litium.Sales.SalesReturnOrder??? Everything seems to be fine. Both the order and the shipment is in Processing. Payment has Attention though but everything good in the logs from what I can see (except for the strange message above).

  1. This is the real issue. A few minutes later this shows up in the logs. Seems to be at the same time as the payment gets SentForSettle state in Adyen.
2023-09-15 15:49:06.2301 [App:01] [] [ERROR] [.NET ThreadPool Worker] Litium.Application.Events.EventBrokerImpl - Value cannot be null. (Parameter 'shipment') System.ArgumentNullException: Value cannot be null. (Parameter 'shipment')
   at Litium.Connect.Application.Erp.OrderFulfilmentServiceImpl.PaymentCapturedForShipment(OrderOverview orderOverview, Shipment shipment)
   at Litium.Connect.Application.Erp.LitiumConnectEventsListener.OnCaptured(PaymentCaptured paymentCaptured)
   at Litium.Connect.Application.Erp.LitiumConnectEventsListener.<Litium.Runtime.IAsyncAutostart.StartAsync>b__6_0(PaymentCaptured x)
   at Litium.Events.EventBroker.<>c__DisplayClass4_0`1.<Subscribe>g__execution|0(T x)
   at Litium.Application.Events.EventBrokerImpl.<>c__DisplayClass11_1`1.<PublishAsync>b__4()
   at Litium.Application.Common.FifoExecution.WorkItem.Execute()
   at Litium.Application.Common.FifoExecution.ProcessQueuedItems(Object ignored)

Payment is Completed.

Litium version: 8.10.0

Is it possible to get some feedback on what could be wrong?

This is a misleading error message shown from Litium API, which will be corrected in a coming version. You can ignore this error.
Reason for this message: Litium attempts the state transition, which in this case should not happen. It is not correct to show an error here from Litium API side.

This is tracked by Bug Details - 61730 - Improve state transition exceptions (litium.com)

@anusha.ganegoda Is that an answer to 1 or 2?

That was an answer on 1.

For the 2 we have Bug Details - 66258 - Shipment without id fails (litium.com) that I think can be related.

OK. I asked a question about that here but didn’t any answer. AutoMapper error when trying to create Shipment - #3 by samuel

So what’s the plan then. Force id to be set or make things work without an id?

What would be the preferred way to create an id for a shipment be? Would using the order number with a different prefix and add a sequential number as suffix work?

You need to set an Id.
The usual way to set an Id easily is, as you had said, to use the OrderId and prefix it and adding a sequential number. for the sequential number, you can just use the Number of shipment objects already present. (use the OrderOverview object which gets the shipments connected to the order)

1 Like

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