Klarna Payments

Klarna Payments

Follow this guide to add Klarna Installments, Financing, Pay Now or Pay with Klarna right to your checkout.

Brand constants to be used:
  • KLARNA_PAYMENTS_PAYLATER - Installments,
  • KLARNA_PAYMENTS_SLICEIT - Financing,
  • KLARNA_PAYMENTS_PAYNOW - Pay Now,
  • KLARNA_PAYMENTS_ONE - Pay with Klarna.

Klarna payment methods availability:

  • Native integration - since mSDK version 2.65.0;
  • Integration via redirect - mSDK version 2.58.0 and older.


Configuration

Ready-to-Use UI

When you use our ready-to-use UI, everything works out-of-box. Just set payment brands and shopper result url in the Checkout Settings class and you are done. Proceed with the presenting checkout as for standard transaction.

NOTE: To learn more about shopper result url refer to Asynchronous Payments guide.


SDK & Your Own UI

If you use our mSDK just for backend communication, you will have to go through the Klarna SDK integration as well. In this guide we assume you already implemented all steps for performing standard mSDK transaction. Then there are 4 main steps:

1. Create Klarna session

First of all, create KlarnaInlinePaymentParams object and submit a transaction. This is just an account discovery transaction (AD) without initiating a payment. Server will return:

  • client token id to authorize the session,
  • initial transaction id to be sent with the payment transaction on step 3,
  • callback urls to complete the transaction after all.

NOTE: To learn more about shopper result url refer to Asynchronous Payments guide.

2. Proceed with the Klarna Mobile SDK

As soon as client token is received, you can initialize and load Klarna view. Just follow the steps from up to "Authorizing the Session".

Mapping of brand constants:

mSDK constantKlarna category
"KLARNA_PAYMENTS_PAYLATER""pay_later"
"KLARNA_PAYMENTS_SLICEIT""pay_over_time"
"KLARNA_PAYMENTS_PAYNOW""pay_now"
"KLARNA_PAYMENTS_ONE""klarna"

Here is how KlarnaPaymentsView initialization will look like with the data received from the mSDK:

3. Configure Pay button action

When shopper is ready and taps your Pay button, you should:

  • Submit payment transaction with an additional parameter first;
  • Then call Klarna SDK API to authorize the session (see ).

You can reuse KlarnaInlinePaymentParams object created in the step 1. Set initialTransactionId that was received earlier in the payment params and submit the transaction. It will initiate pre-authorization on the backend.

4. Notify Server about payment completion

In order to complete the transaction you have to send additional request to backend.

  • If Klarna authorization is successful, check authToken is not empty and use callbackUrl to notify backend about transaction completion by sending a GET request.

  • If some error occurred, then use failureCallbackUrl to notify server about it.

NOTE: Expected response from callback urls is a redirect to the shopper result url. You might want to check that status and location of redirect url are valid, or it's also an option just to ignore the response. Request payment status as usual to get final result of the transaction.