Save Klarna HTML Snippet on order in Litium

Hi,

I want to save the order confirmation snippet from klarna on the order itself so it won’t stop working suddenly.

I have tried using both the documentation way and the way suggested in the thread: Klarna Order confirmation in Accelerator - #3 by Ericsj11

Issue with doc version is that refresh clears the cart and thus also clears the confirmation page. The latter by fetching the order each time from Klarna sometimes it fails with something went wrong / not supported page error or unauthorized

For this reason i want to store the snippet on AdditionalPaymentInfo, AdditionalOrderInfo, or anywere that will make it work through fetching it in Litium.

I have tried with in PaymentWidgetService.cs

public void PlaceOrder([NotNull] IPaymentWidgetOrder paymentWidgetOrder, bool isConfirmation)
...
... //Stock Litium code
...
var paymentInfo = order.PaymentInfo
    .FirstOrDefault(x => x.PaymentProviderName == paymentWidgetOrder.PaymentProviderName);

if (paymentInfo != null)
{
....
.... // Stock Litium code
....
    var klarnaHtmlSnippetInfo = paymentInfo.AdditionalPaymentInfo
        .FirstOrDefault(x =>
            x.AdditionalPaymentInfoKey == 
            AdditionalPaymentInfoConstants.KlarnaHtmlSnippet);

    if (klarnaHtmlSnippetInfo == null)
    {
        paymentInfo.AdditionalPaymentInfo
            .Create(new AdditionalPaymentInfoCarrier(
                    AdditionalPaymentInfoConstants.KlarnaHtmlSnippet,
                    paymentInfo.ID,
                    paymentWidgetOrder.HtmlSnippet),
                _securityToken);
    }
}

Then in OrderController instead of using checkoutFlow using the PaymentInfo
Though the stored snippet looks like this:

Is it because it’s trying to fetch it too early?

Litium version: 7.6.1

I talked to Klarna support regarding this and the snippet will only work for 2hours from purchase so anything after that will show an un-authorized error.

We didn’t go into “Something went wrong” but since we cannot store the snippet anyhow we will use the second solution by fetching it every time we want to show.

4 Likes

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