Litum initiate klarna capture flow

I want to initiate Klarna capture flow via code, but how do I initiate the state engine?

The general flow of the application is:
Order -> Handle -> Payment -> Confirm -> Capture

In other terms:
Litium -> Erp -> Klarna -> Erp -> Litium -> Klarna

I cannot find any documentation how to trigger state change?

https://docs.litium.com/documentation/add-ons/payments/klarna/develop

Litium version: 7.4.2

order.SetOrderStatus((short) OrderState.Completed, token);
order.SetDeliveryStatus((short) DeliveryState.Delivered, token);
order.SetPaymentStatus((short) PaymentStatus.ExecuteCapture, token);

I guess I set one off these?
Do need to set them in a specific order?

You mean, do you want to automatically capture orders, when Erp notify you that the order is shipped?

Yes in principle. We have built an WebApi controller that sends ordernumber etc in a post.
Does a search for the correct ordernumber etc etc.

If you havent modified the litium accelerator orderstatebuilder then you really only need to set deliverystate to delivered and that will trigger the rest.

Delivery state delivered will trigger capturepayment and trigger paymentstate move to paid and that in turn will trigger orderstate to go to completed if delivery state = delivered and paymentstate paid.

In the default implementation of the accelerator these states are related but if you have a customer orderflow you might have to add cinfguration for the related states.

Ok great. Thanks! :slight_smile:

On the same topic. IF the customer wants to change the total amount withdrawn from the end user.

Is this code enough to accomplish this?

            if (model.Amount.HasValue)
            {
                order.PaymentInfo.FirstOrDefault()?.SetTotalAmountWithVAT(model.Amount.Value, token);
            }

Then do the loop on deliveries.

 foreach (var delivery in order.Deliveries)
            {
                delivery.SetDeliveryStatus((short) DeliveryState.Processing, token);
                delivery.SetDeliveryStatus((short) DeliveryState.Delivered, token);
            }

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