Thanks, but following those steps would result in an Litiums confirmation page on reload, right?
I hade the same idea, but ended up getting the Html Snippet In the OrderController. Do you see any downside with this?
public ActionResult Confirmation(PageModel currentPageModel, Guid? orderId, bool isEmail = false)
{
// ...
GetKlarnasOrderConfirmationSnippet(model);
_cartService.Clear();
return View(model);
// ...
}
private void GetKlarnasOrderConfirmationSnippet(OrderConfirmationViewModel model)
{
// Has to be placed here. The decorators or original builder can't access _klarnaPaymentConfigV3.
var order = _moduleECommerce.Orders.GetOrder(model.Order.ExternalOrderID, _securityToken)?
.GetAsCarrier(false, false, false, false, false, true);
var paymentInfoCarrier = order?.PaymentInfo?.FirstOrDefault(x => x.PaymentProvider.StartsWith("Klarna"));
if (!string.IsNullOrWhiteSpace(paymentInfoCarrier?.PaymentMethod))
{
var paymentAccountId = _paymentWidgetService.GetPaymentAccountId(paymentInfoCarrier.PaymentMethod);
var klarnaCheckout = LitiumKcoApi.CreateFrom(paymentAccountId, (order, payment, kcoOrder) =>
_klarnaPaymentConfigV3.UpdateDataSentToKlarna(new UrlHelper(), order, payment, kcoOrder));
var checkoutOrder = klarnaCheckout.FetchKcoOrder(paymentInfoCarrier.TransactionNumber);
if (checkoutOrder.KlarnaOrderStatus == KlarnaOrderStatus.Complete)
{
model.HtmlSnippet = checkoutOrder.HtmlSnippet;
}
}
}