# Adyen payment error when payment gets captured

**URL:** <https://forum.litium.com/t/adyen-payment-error-when-payment-gets-captured/3054>\
**Category:** Questions\
**Tags:** litium-8\
**Created:** [September 15, 2023, 3:14pm UTC](https://forum.litium.com/t/adyen-payment-error-when-payment-gets-captured/3054 "2023-09-15T15:14:13Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![samuel](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/samuel/32/479_2.png) [@samuel](https://forum.litium.com/u/samuel)\
**Post date:** [September 15, 2023, 3:14pm UTC](https://forum.litium.com/t/adyen-payment-error-when-payment-gets-captured/3054/1 "2023-09-15T15:14:13Z")

</div>

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.

```auto
  _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

```auto
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.

```auto
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

---

<div class="post-metadata">

**Author:** ![samuel](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/samuel/32/479_2.png) [@samuel](https://forum.litium.com/u/samuel)\
**Post date:** [September 26, 2023, 10:47am UTC](https://forum.litium.com/t/adyen-payment-error-when-payment-gets-captured/3054/2 "2023-09-26T10:47:27Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![anusha.ganegoda](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/anusha.ganegoda/32/58_2.png) [@anusha.ganegoda](https://forum.litium.com/u/anusha.ganegoda)\
**Post date:** [October 12, 2023, 6:33am UTC](https://forum.litium.com/t/adyen-payment-error-when-payment-gets-captured/3054/3 "2023-10-12T06:33:06Z")

</div>

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)](https://docs.litium.com/support/bugs/bug_details?id=61730)

---

<div class="post-metadata">

**Author:** ![samuel](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/samuel/32/479_2.png) [@samuel](https://forum.litium.com/u/samuel)\
**Post date:** [October 12, 2023, 10:13am UTC](https://forum.litium.com/t/adyen-payment-error-when-payment-gets-captured/3054/4 "2023-10-12T10:13:43Z")

</div>

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

---

<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:** [October 12, 2023, 4:30pm UTC](https://forum.litium.com/t/adyen-payment-error-when-payment-gets-captured/3054/5 "2023-10-12T16:30:25Z")

</div>

That was an answer on 1.

For the 2 we have [Bug Details - 66258 - Shipment without id fails (litium.com)](https://docs.litium.com/support/bugs/bug_details?id=66258) that I think can be related.

---

<div class="post-metadata">

**Author:** ![samuel](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/samuel/32/479_2.png) [@samuel](https://forum.litium.com/u/samuel)\
**Post date:** [October 13, 2023, 9:01am UTC](https://forum.litium.com/t/adyen-payment-error-when-payment-gets-captured/3054/6 "2023-10-13T09:01:56Z")

</div>

OK. I asked a question about that here but didn’t any answer. [AutoMapper error when trying to create Shipment - #3 by samuel](https://forum.litium.com/t/automapper-error-when-trying-to-create-shipment/3046/3)

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?

---

<div class="post-metadata">

**Author:** ![anusha.ganegoda](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/anusha.ganegoda/32/58_2.png) [@anusha.ganegoda](https://forum.litium.com/u/anusha.ganegoda)\
**Post date:** [October 19, 2023, 6:41am UTC](https://forum.litium.com/t/adyen-payment-error-when-payment-gets-captured/3054/7 "2023-10-19T06:41:55Z")

</div>

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)

---

<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:** [November 16, 2023, 6:42am UTC](https://forum.litium.com/t/adyen-payment-error-when-payment-gets-captured/3054/8 "2023-11-16T06:42:06Z")

</div>

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