Worldline

Mobile SDK integration

Integrate Klarna via Mobile SDK by embedding the payment form, tracking payment status, and completing authorization flows for a smoooth mobile checkout experience.

Prerequisites

Before you integrate, check that you meet the following prerequisites:

  1. 1.
    Ensure that you have Klarna enabled with your Acquiring Partner.
  2. 2.
    Confirm you have access to the Klarna Portal.
  3. 3.
    Inside Klarna Portal:
    1. 3.1.
      Confirm that you have generated a client identifier.
    2. 3.2.
      Confirm that you have generated an API key.
  4. 4.
    Confirm that you have registered webhooks for payment.request.state-change.completed events following Webhooks guidelines.
  5. 5.
    Add Terms and Conditions for client-side SDK usage.
  6. 6.
    Your Acquiring Partner supports interoperability_token exchange for client-side use with Klarna.

Integration overview

This guide will cover both iOS (Swift) and Android (Kotlin) integrations.

Here's an overview of all the steps to processing a payment with Klarna via the Mobile SDK:

  1. 1.
    Present Klarna as a payment option in the payment form.
  2. 2.
    Customer clicks the Klarna payment button in your checkout.
  3. 3.
    You create either a server-side payment request with your Acquiring Partner or use the Klarna Mobile SDK to initiate the payment request, sharing all available interoperability data points.
  4. 4.
    If customer interaction is required:
    • 4.1.
      The Klarna Purchase Journey is launched.
    • 4.2.
      The customer completes the Klarna Purchase Journey.
  5. 5.
    Klarna returns an interoperability_token via a webhook.
  6. 6.
    You create an authorization request with your Acquiring Partner and share the required interoperability data points.
  7. 7.
    Acquiring Partner responds with an approval and order completion.
  8. 8.
    Customer is redirected to your confirmation page.
sequenceDiagram participant C as Customer participant P as Partner participant K as Klarna participant AP as Acquiring Partner C->>P: Visit checkout page P->>K: Initialize Klarna Mobile SDK P->>K: Request presentation instructions K->>P: Return assets and instructions P->>P: Render payment selector C->>P: Select Klarna payment method P->>P: Update Klarna presentation<br>Show Klarna payment button C->>P: Click Klarna payment button Note over P,AP: Handle the "Pay with Klarna" button click P->>K: Initiate Payment Request K->>C: Start Klarna purchase flow C->>K: Complete Klarna purchase flow K->>P: Payment request completed event via webhook Note over P,K: interoperability_token P->>AP: Authorize payment Note over P,AP: Share interoperability data points AP->>P: Respond with approval Note over P,AP: Order completed P->>C: Redirect to confirmation page

Integration details

Present Klarna in the payment form

Integrate the Klarna Mobile SDK to display Klarna as a payment option within your own payment form. This approach lets you fully control the checkout experience while using Klarna’s ready-made UI components for secure payment handling.

This guide explains how to present Klarna in your payment form, both during the initial load and after the customer selects Klarna. By following these steps, you’ll ensure the payment flow meets Klarna’s design and functionality standards:

undefined
undefined
Initial presentationWhen Klarna is selected

It's crucial that Klarna payment presentation is dynamic and not hardcoded on your server to deliver the best conversion outcome.

Klarna's best practice To ensure the best user experience and optimal conversion rates when presenting Klarna as a payment option, please apply the following recommendations:

  • Present Klarna dynamically alongside other payment options in your payment form.
  • Embed Klarna’s UI elements directly in your frontend for a consistent and responsive design.

The next sections in this guideline will walk through how this can be achieved using Klarna Mobile SDK [link to public APIs].

Import the Mobile SDK

iOS

Swift Package Manager

To add the required dependency, do the following steps:

  1. 1.
    In Xcode, select File → Add Package Dependencies...
  2. 2.
    In the opened window, enter https://github.com/klarna/klarna-mobile-sdk-ios in the search bar.
  3. 3.
    For Dependency Rule, select Up to Next Major Version and leave the default version as is.
  4. 4.
    For Add to Project, select your project.
  5. 5.
    Click Add Package.
  6. 6.
    In the new window that opens, add KlarnaNetworkPayment to your desired target.

Cocoapods

First, add the Klarna Mobile SDK's Payment module dependency to your Podfile by running the following command:

SH
 pod "KlarnaMobileSDK/KlarnaNetworkPayment"

Next, run the command below and then you should be able to import KlarnaMobileSDK module in your workspace and start using it.

SH
 pod install
Android

Kotlin

First, add the Klarna Mobile SDK Maven repository:

KOTLIN
repositories {
    maven("https://x.klarnacdn.net/mobile-sdk/")
}

Next, add the Klarna Mobile SDK's Payment library as a dependency to your application:

KOTLIN
dependencies {
     implementation("com.klarna.mobile.sdk:klarna-network-payment:<LATEST_VERSION>")
}

To find the latest version you can always refer to this link.

Groovy

First, add the Klarna Mobile SDK Maven repository:

GROOVY
repositories {
    maven {
        url 'https://x.klarnacdn.net/mobile-sdk/'
    }
}

Next, add the Klarna Mobile SDK's Payment library as a dependency to your application:

GROOVY
dependencies {
    implementation 'com.klarna.mobile.sdk:klarna-network-payment:<LATEST_VERSION>'
}

To find the latest version you can always refer to this link.

Initialize the Mobile SDK

The first step to add Klarna Payment to your application is to initialize the Klarna SDK:

SWIFT
// Create an instance of KlarnaConfiguration
let configuration = KlarnaConfiguration(
    clientId: <CLIENT_ID>,
    locale: <LOCALE>,
    sdkToken: <SDK_TOKEN>
)

// Initialize Klarna
let klarnaResult = Klarna.initialize(configuration: config)
switch klarnaResult {
case .success(let klarnaInstance):
    // Initialization succeeded. klarnaInstance is a ready-to-use instance of Klarna.

The following table lists the properties of KlarnaConfiguration.

NameTypePresenceDescription
clientIdStringrequiredThe client ID of the partner account that is integrating the Mobile SDK. If the integration is done by a PSP/DP then this must be set to the distribution partners own client ID.
localeStringoptionalThe default locale (ISO 3166-1 alpha-2) that will be used by the SDK. If not set, the locale of the device will be used.
sdkTokenStringoptionalThe SDK token allows the SDK to be initialized with an existing session. Token is only retrievable server-side via the Interoperability API.

Exchange an interoperability token for an SDK token

This step is only applicable if you are in possession of an interoperability token.

The SDK token is a single-use, browser-bound credential that restores the customer’s checkout context when Klarna’s Mobile SDK is initialized. This token should be exchanged server-side before initializing the SDK and displaying the checkout view to the customer.

You must exchange the acquired interoperability token for a short-lived SDK token using the generateSdkTokenAPI endpoint.

Consult the API reference for generateSdkTokenAPI API call, to find a complete description of the parameters.

Klarna payment presentation request

Klarna payment presentation provides all the visual assets, localized texts, and instructions needed to correctly display Klarna in your checkout screen. To fetch the payment presentation, you need to call the KlarnaPaymentPresentation.fetch() method like below:

SWIFT
// Create an instance of KlarnaPaymentPresentationData
let paymentPresentationData = KlarnaPaymentPresentationData(
    amount = <AMOUNT>,
    currency = <CURRENCY>,
    intents = <INTENTS>,
    paymentProgramEnablementCodes = <PAYMENT_PROGRAM_ENABLEMENT_CODES>,
    subscriptionBillingInterval = <SUBSCRIPTION_BILLING_INTERVAL>,
    subscriptionBillingIntervalFrequency = <SUBSCRIPTION_BILLING_INTERVAL_FREQUENCY>
)

// Fetch the payment presentation
klarna.payment.presentation.fetch(data: paymentPresentationData) { (result: Result<KlarnaPaymentPresentationContent, KlarnaSDKError>) in

The following table lists the parameters of KlarnaPaymentPresentation.fetch() method.

NameTypePresenceDescription
dataKlarnaPaymentPresentationDatarequiredSpecifies the data that is used to tailor the payment presentation content.
callbackKlarnaPaymentPresentationCallbackrequiredThe callback to get notified of the result of payment presentation fetch.

The table below lists the properties of KlarnaPaymentPresentationData:

NameTypePresenceDescription
amountLong (Android), Int64 (iOS)requiredThe transaction amount in minor units following ISO 4217 exponents (e.g., $118.00 = 11800, ¥1400 = 1400).
currencyStringrequiredThree-letter ISO 4217 currency code (e.g. USD, EUR).
intentsList<KlarnaIntent> (Android), [KlarnaIntent] (iOS)optionalSpecifies the intent of the payment presentation content for your use case. It can be used when you need presentation elements tailored to specific payment scenarios.
subscriptionBillingIntervalKlarnaIntervaloptionalSpecifies the interval of which the customer is charged for the subscription.
subscriptionBillingIntervalFrequencyIntrequired if the interval is setDefines the subscription interval frequency.

Klarna payment presentation response

After a successful payment presentation fetch, you will get an instance of KlarnaPaymentPresentationContent containing the full Klarna branding package and instructions that can be used to present Klarna as a payment option.

Follow Klarna payment presentation instruction

This section explains how to handle Klarna’s payment presentation instructions, which define how Klarna should appear within the checkout form. Adhering to these instructions is essential to maintain a consistent and optimized user experience—whether Klarna is displayed alongside other payment methods, preselected, or shown as the only available option.

Compliance with Klarna’s presentation instructions is especially important when integrating Klarna Conversion Boost features, such as Express Checkout or Sign in with Klarna, to ensure a seamless and unified customer experience.

The instruction property available in KlarnaPaymentPresentationContent can have the following possible values:

NameDescription
SHOW_KLARNAShow Klarna alongside other payment methods.
PRESELECT_KLARNAShow Klarna pre-selected but still alongside other payment methods. This is returned when using the customer_token issued from the Sign in with Klarna feature or the tokenization flow.
SHOW_ONLY_KLARNAShow Klarna as the only payment method. This is returned when the customer has finished the first step of multi-step Klarna Express Checkout.

Skip this section if you don't use any Conversion Boost features from Klarna such as Klarna Express Checkout, Sign-in with Klarna, Klarna Messaging or Klarna Prequalification.

Here are example outcomes illustrating how Klarna should be displayed for each instruction:

undefined
undefined
undefined
Show KlarnaPreselect KlarnaShow only Klarna

The presentation instructions are derived from possible customer purchase journeys described in the following article.

The following code snippet shows an example of how instruction can be used to decide how to present Klarna as a payment option.

SWIFT
private func renderKlarnaPresentation(content: KlarnaPaymentPresentationContent) {
    let instruction: KlarnaPaymentPresentationInstruction = content.instruction
    switch instruction {
    case .showKlarna:
        // Show Klarna alongside other payment options
    case .preselectKlarna:
        // Preselect Klarna as the default payment option
    case .showOnlyKlarna:
        // Show only Klarna as the payment option
    }
    // The rest of the code for rendering Klarna presentation.
}
Mount Klarna payment option components

After fetching the payment presentation, you have access to an instance of KlarnaPaymentPresentationContent. It can be used to present Klarna as a payment option. The Klarna payment option must be rendered in the payment selector according to Klarna’s presentation guidelines.

The following table lists the properties of KlarnaPaymentPresentationContent.

NameTypePresenceDescription
instructionKlarnaPaymentPresentationInstructionrequiredSpecifies how Klarna should be displayed as a payment option (e.g., whether to show, preselect, or display as show-only). Adhering to these payment presentation instructions ensures customers have the best possible experience and optimizes conversion rates.
paymentOptionKlarnaPaymentPresentationPaymentOptionoptionalSpecifies the default payment option applicable to all purchase types. It includes the visual elements required to represent Klarna during checkout.
paymentStatusKlarnaPaymentPresentationPaymentStatusoptionalSpecifies the payment status of the presentation.

The KlarnaPaymentPresentationPaymentOption type has the following properties:

NamePresenceDescription
paymentOptionIdrequiredThe identifier of the payment option. This value is required to be sent to the Payment Authorize API or the Payment Request API when initiating the payment.
headeroptionalThe main descriptor that introduces Klarna in the payment form. The value will be dynamically adjusted based on the locale provided when you initialized the Klarna SDK.
subheaderoptionalThe sub-header descriptor that must be loaded inline below the main descriptor header. It's a short and enriched descriptive text that provides transparency on available options like installments, pay later, etc.
messageoptionalEnriched tailored description with link.
badgeoptionalBadge used for saved options or promotions.
termsoptionalDefines terms/disclosures potentially with links.
  1. 1.
    icon
  2. 2.
    badge
  3. 3.
    header
  4. 4.
    subheader
  5. 5.
    message
  6. 6.
    terms
  7. 7.
    button

Present the Klarna payment option elements within your Klarna payment method view to render them in the payment form. The code snippet below shows a very basic sample of how you can do so:

SWIFT
private func renderKlarnaPresentation(content: KlarnaPaymentPresentationContent) {
    if let headerText = content.paymentOption?.header, case .plainText(let text) = headerText {
        // Show the header text in the UI (for example in a UITextView)
    }
    if let subheaderText = content.paymentOption?.subheader, case .plainText(let text) = subheaderText {
        // Show the subheader text in the UI (for example in a UITextView)
    }
    if let badgeText = content.paymentOption?.badge, case .plainText(let text) = badgeText {
        // Show the badge text in the UI (for example in a UITextView)
    }
    if let messageText = content.paymentOption?.message, case .attributedText(let parts) = messageText {
        let message = getAttributedString(parts: parts)

Handle Klarna payment option selection and deselection

When a Klarna payment option is selected/deselected, ensure the additional visual components are shown/hidden properly.

SWIFT
// UIKit approach
func toggleKlarnaPaymentOptionSelection(isSelected: Bool) {
    // In this example, klarnaPresentationContainer is a view containing
    // presentation message, terms and button
    klarnaPresentationContainer.isHidden = !isSelected
}

// SwiftUI approach
struct KlarnaPaymentOption: View {
    @State var isSelected: Bool

    var body: some View {

The message contained within the payment object contains two different classifications of links as set forth by the context value.

Context ValuePurpose
infoThis indicates that the content of the URL is purely informational.
authThis value indicates that the content of the URL requires customer authentication.

Due to the authentication requirements associated with the auth context, it is necessary for the link to be opened in a non-ephemeral ASWebAuthenticationSession on iOS and a CustomTab on Android. By contrast, info context links can be opened in any WebView. To simply the requirements associated with properly handling these links, we have created the following method for you to call.

SWIFT
// Handle the presentation link
klarna.payment.presentation.handleLink(
    content: <PAYMENT_PRESENTATION_CONTENT>,
    url: <URL>)
{ (result: Result<KlarnaPaymentPresentationContent, KlarnaSDKError>) in
    switch result {
    case .success(let paymentPresentationContent):
        // Payment presentation link handling was successful. paymentPresentationContent contains
        // the latest payment presentation information.
        print("Payment presentation link handling succeeded.")
    case .failure(let error):
        // Payment presentation link handling failed. More information about the failure

The following table lists the parameters of KlarnaPaymentPresentation.handleLink() method.

NameTypePresenceDescription
activityActivityrequired for Android onlyThe Activity instance of your app.
contentKlarnaPaymentPresentationContentrequiredThe presentation content that you've already fetched using the KlarnaPaymentPresentation.fetch() method.
urlStringrequiredThe URL to handle.
callbackKlarnaPaymentPresentationCallbackrequiredThe callback to get notified of the result of payment presentation link handling.

Rendering the Klarna payment button

The Mobile SDK provides a native UI view called KlarnaPaymentButton that follows Klarna's visual identity.

Klarna payment button variants

Choose the theme and shape of the payment button to best fit into your online store in a way that complements your brand and encourages user engagement. More details on the button styling can be found here.

Creating Klarna payment button

To add the Klarna payment button to your app you can do something like below:

SWIFT
// Create an instance of KlarnaPaymentButtonConfiguration
let paymentButtonConfiguration = KlarnaPaymentButtonConfiguration(
    state: .default,
    intents: [.pay],
    shape: .pill,
    style: .outlined,
    theme: .light
)

// Create the payment button
let paymentButton = KlarnaPaymentButton(
    klarna: <KLARNA_INSTANCE>,

The table below list the properties of KlarnaPaymentButtonConfiguration:

NameTypePresenceDescription
stateKlarnaButtonStateoptionalSets the initial state of the button. If not set, "default" will be used.
shapeKlarnaButtonShapeoptionalDefines the shape of the button. If not set, "rounded rect" will be used.
styleKlarnaButtonStyleoptionalDefines the style of the button. If not set, "filled" will be used.
themeKlarnaThemeoptionalDefines the theme of the button. If not set, "dark" will be used.
intentsList<KlarnaIntent> (Android), [KlarnaIntent] (iOS)optionalDefines the intent(s) that the payment button will be used for.

Handle payment button tap

When the payment button is tapped, you should initiate the payment request process. This is done by calling the KlarnaPayment.initiate() method. There are two options for initiating the payment request using the initiate() method:

  • Client-side, sharing the details of customer's checkout session (paymentRequestData) when calling the initiate() method.
  • Using the Klarna payment_request_id associated with the customer's checkout session that was generated server-side via your Acquiring Partner.

Client-side payment request initiation

In client-side payment request initiation, you pass all the data needed to create and initiate a payment request to the Mobile SDK and the Mobile SDK takes care of creating and initiating the payment request. The following table lists the parameters of KlarnaPayment.initiate() method.

NameTypePresenceDescription
activityActivityrequired for Android onlyThe Activity instance of your app.
dataKlarnaPaymentRequestDatarequiredThe data needed to create and initiate the payment request.
callbackKlarnaPaymentRequestCallbackrequiredThe callback to get notified of the result of payment request initiation.

The table below lists all the properties of KlarnaPaymentRequestData.

ParameterPresenceDescription
currencyrequiredThree-letter ISO 4217 currency code (e.g., USD, EUR).
amountrequiredTotal amount of a one-off purchase, including tax and any available discounts. The value should be in non-negative minor units. Eg: 25 Dollars should be 2500.
paymentRequestReferenceoptionalReference to the payment session or equivalent resource created on the integrator's side.
supplementaryPurchaseDataoptionalProvides additional details about the transaction to help reduce fraud risk and enhance transparency.
shippingConfigoptionalConfigure how the shipping collection form will behave in the purchase flow. Without the shipping config, no shipping collection form will be displayed.
requestCustomerTokenoptionalObject to request customer account linking to be set up, effectively returning a token called customer_token on successful confirmation of the payment request.
SWIFT
// Create an instance of KlarnaPaymentRequestData
let paymentRequestData = KlarnaPaymentRequestData(
    amount: <AMOUNT>,
    currency: <CURRENCY>,
    paymentRequestReference: <PAYMENT_REQUEST_REFERENCE>,
    requestCustomerToken: <REQUETS_CUSTOMER_TOKEN>,
    shippingConfig: <SHIPPING_CONFIG>,
    collectCustomerProfile: <COLLECT_CUSTOMER_PROFILE>,
    supplementaryPurchaseData: <SUPPLEMENTARY_PURCHASE_DATA>
)

@objc func didTapPaymentButton() {

Server-side payment request initiation

Call the Payment Request API to initiate a transaction. If customer verification is required, Klarna processes the request and creates a unique payment identifier for tracking. The payment request is then returned in the SUBMITTED state with the interaction details needed to complete the payment flow.

Request

{{#lst:Klarna Docs - Payment Request - Content Source|payment request: create: request: one-time payment}}

Configure customer interaction parameters

When integrating Klarna’s purchase flow, it’s essential to define how the customer should be redirected after completing or exiting the Klarna experience. Depending on whether the flow runs in a web or mobile app environment, Klarna uses one or both return URLs to ensure a seamless handoff back to the Partner’s experience.

The parameters return_url and app_return_url specify where Klarna should redirect the customer once the interaction ends—whether they’ve approved or aborted the purchase. Correctly configuring these URLs ensures that customers always return to the appropriate context (webpage or mobile app) and can smoothly continue the checkout or post-purchase process.

Parameter nameDescription
[return_url](https://docs.klarna.com/api/kn/klarna-product-api-payment/klarna-product-api-payment-v2-r8/#tag/Payment-Authorize-API/operation/authorizePayment!path=step_up_config/customer_interaction_config/0/return_url&t=request)If the Klarna purchase flow is launched in a web environment, Klarna will redirect the customer to this URL after the customer finishes their interaction with Klarna, either by approving or aborting the purchase flow. This could either be a URL from the Acquiring Partner who will handle the redirection logic or a URL collected from the Partner.
[app_return_url](https://docs.klarna.com/api/kn/klarna-product-api-payment/klarna-product-api-payment-v2-r8/#tag/Payment-Authorize-API/operation/authorizePayment!path=step_up_config/customer_interaction_config/0/app_return_url&t=request)The customer may be redirected to a third party app (bank app) or the Klarna app during the Klarna purchase journey on mobile environments. This URL enables Klarna to return the customer back to the Partner’s mobile app. Ensure the app_return_url is set up to register a URL scheme (e.g., partnerapp://klarna) or universal link that resumes the payment flow. The Partner is expected to open the integrating mobile application in its last state (no state changes or deeplink navigations).

Visual representations for Web flow and App handover flow:

undefined
undefined
Web handoverApp handover

return_url and app_return_url are not mutually exclusive

In different scenarios, either or both of the return_url and app_return_url can be triggered:

Example 1: Only return_url is triggered – Pure web flow

The customer starts the Klarna purchase flow in a web browser on a desktop. After approving the purchase, they are redirected to the return_url.

Example 2: Only app_return_url is triggered – App-to-app flow

The Partner’s native mobile app opens the Klarna purchase flow using a universal link. If the Klarna app is installed, the customer is taken directly into the Klarna app. After approval, they are redirected to the app_return_url, returning them to the Partner's app.

Example 3: Both URLs are triggered – WebView flow with app handover

The Partner’s native mobile app starts the Klarna purchase flow in a System WebView. If the customer needs to authenticate via an external banking app, they’re handed back to the Partner's app using app_return_url. They then resume the purchase flow in the WebView and, upon completion, are redirected to the return_url.

Provide supplementary purchase data

Supplementary Purchase Data refers to additional transaction details shared with Klarna that provide greater context about a purchase. These data points—such as line items, subscription details, or industry-specific attributes—help improve underwriting accuracy, fraud assessment, and the customer’s post-purchase experience. They may be required in certain industries and support multiple use cases, including better acceptance rates, enhanced fraud prevention, improved customer experiences within the Klarna app, and more effective risk monitoring.

Data requirements

Depending on the business type, certain supplementary_purchase_data fields are required under the Klarna Network Rules. However, purchase_reference, line_items, customer and shipping whenever available must always be submitted, as they enable transaction-level traceability, power Klarna’s fraud prevention and underwriting models, dispute handling, and ensure a consistent customer experience across Klarna’s ecosystem.

Response

When the request succeeds, Klarna returns a payment request in the SUBMITTED state.

The response includes:

  1. 1.
    payment_request_id — a unique identifier for the payment request.
  2. 2.
    payment_request_url — the URL used to initiate the customer’s purchase journey.

Sample payload

JSON
{
  "payment_request_id": "krn:payment:eu1:request:10be1d49-7beb-6b24-b9dd-8c14d0528503",
  "state": "SUBMITTED",
  "state_context": {
    "customer_interaction": {
      "method": "HANDOVER",
      "payment_request_id": "krn:payment:eu1:request:10be1d49-7beb-6b24-b9dd-8c14d0528503",
      "payment_request_url": "https://pay.klarna.com/l/ZjW2Xipgh0tjbrBGD7hzJM"
    }
  },
  "expires_at": "2025-02-26T17:25:34.534721775Z",
  "created_at": "2025-02-24T17:25:34.534721775Z",

Once you have created the payment request, take the payment_request_id from the server-side response and provide it in the Mobile SDK initiate method as highlighted in the code below.

NameTypePresenceDescription
activityActivityrequired for Android onlyThe Activity instance of your app.
paymentRequestIdStringrequiredThe ID of the payment request that has been created server-side.
callbackKlarnaPaymentRequestCallbackrequiredThe callback to get notified of the result of payment request initiation.
SWIFT
@objc func didTapPaymentButton() {
    // Initiate the payment request
    klarna.payment.initiate(paymentRequestId: <PAYMENT_REQUEST_ID>) { (result: Result<KlarnaPaymentRequest, KlarnaSDKError>) in
        switch result {
        case .success(let paymentRequest):
            // Payment request initiation was successful. paymentRequest contains the
            // information about the payment request.
            print("Payment request initiation succeeded.")
        case .failure(let error):
            // Payment request initiation failed. More information about the failure
            // is available in the error object.
            print("Payment request initiation failed: \(error.localizedDescription)")

Optional functionality available via the Mobile SDK

Klarna payment request fetching

To get the information associated with a payment request, you can use the KlarnaPayment.fetch() method. The following code shows a sample implementation:

SWIFT
// Fetch the payment request
klarna.payment.fetch(paymentRequestId: <PAYMENT_REQUEST_ID>) { (result: Result<KlarnaPaymentRequest, KlarnaSDKError>) in
    switch result {
    case .success(let paymentRequest):
        // Payment request fetch was successful. paymentRequest contains the
        // information about the payment request.
        print("Payment request fetch succeeded.")
    case .failure(let error):
        // Payment request fetch failed. More information about the failure
        // is available in the error object.
        print("Payment request fetch failed: \(error.localizedDescription)")
    }

The following table lists the parameters of KlarnaPayment.fetch() method.

NameTypePresenceDescription
paymentRequestIdStringrequiredThe ID of the payment request to fetch.
callbackKlarnaPaymentRequestCallbackrequiredThe callback to get notified of the result of payment request fetch.

Klarna payment request cancelation

To cancel a payment request, you can use the KlarnaPayment.cancel() method. The following code shows a sample implementation:

SWIFT
// Cancel the payment request
klarna.payment.cancel(paymentRequestId: <PAYMENT_REQUEST_ID>) { (result: Result<KlarnaPaymentRequest, KlarnaSDKError>) in
    switch result {
    case .success(let paymentRequest):
        // Payment request cancelation was successful. paymentRequest contains the
        // information about the canceled payment request.
        print("Payment request cancelation succeeded.")
    case .failure(let error):
        // Payment request cancelation failed. More information about the failure
        // is available in the error object.
        print("Payment request cancelation failed: \(error.localizedDescription)")
    }

The following table lists the parameters of KlarnaPayment.cancel() method.

NameTypePresenceDescription
paymentRequestIdStringrequiredThe ID of the payment request to cancel.
callbackKlarnaPaymentRequestCallbackrequiredThe callback to get notified of the result of payment request cancelation.

Related articles

Register Webhooks

1. General

Present Klarna in your checkout

Checkout Styling

API & SDK references

API