Show Klarna receipt snippet
Litium default accelerator is showing the Litium order receipt. But when using Klarna checkout (KCO), Klarna is recommending to show the Klarna receipt snippet, instead of Litium order receipt.
Why Litium show the Litium order receipt:
Klarna did not have this recomendation at the time of releasing Litium Accelerator 7.4 release. We will take steps to change this in a future accelerator release.
Show Klarna confirmation snippet
Follow this example if you want to display Klarna confirmation instead of Litium confirmation.
The Klarna confirmation will be contained in ILitiumKcoOrder.HtmlSnippet after you fetch the Klarna order.
In the Confirmation action of KlarnaPaymentWidgetController, after fetching and placing order, store the html snippet into CheckoutFlowInfo.
public ActionResult Confirmation(string accountId, string transactionNumber)
{
// ...
// fetch the klarna order
var checkoutOrder = klarnaCheckout.FetchKcoOrder(transactionNumber.Split('/').Last());
if (checkoutOrder != null)
{
// place order
_paymentWidgetService.PlaceOrder(new PaymentWidgetOrder(klarnaCheckout, checkoutOrder), true);
// store confirmation snippet to display on confirmation page
_cartAccessor.Cart.CheckoutFlowInfo.SetValue<string>(nameof(OrderConfirmationViewModel.KlarnaHtmlSnippet), checkoutOrder.HtmlSnippet);
}
// ...
}
And then show the snippet in confirmation page. In Confirmation action of OrderController, get snippet from CheckoutFlowInfo, and then display it on the view
public ActionResult Confirmation(PageModel currentPageModel, Guid? orderId, bool isEmail = false)
{
// ...
model.KlarnaHtmlSnippet = _cartAccessor.Cart.CheckoutFlowInfo.GetValue<string>(nameof(model.KlarnaHtmlSnippet));
_cartService.Clear();
return View(model);
// ...
}
and to display the receipt snippet:
@if (string.IsNullOrEmpty(Model.KlarnaHtmlSnippet))
{
@Html.Partial("_OrderSummary", Model.Order)
}
else
{
@Html.Raw(Model.KlarnaHtmlSnippet)
}