Klarna

Klarna integration for Shogun Frontend.

Klarna is used by most merchants for Custom payment messages that promote payment in instalments or pay later.

⚠️ This package runs on Shogun Frontend and is in customer Beta. It might not currently support all ecommerce platforms or cover all use cases.

Official website

Overview

This package allows you to use Klarna on-site-messaging feature and has instructions to get Klarna checkout working on Shogun frontend.

Installation

yarn add @frontend-sdk/klarna

npm install @frontend-sdk/klarna

Klarna On Site Messaging

Add Klarna placements to the Shogun store.

Usage

Credentials

Retrieve your Klarna Client ID as described here from the Klarna services library script. As shown below;

Klarna client idKlarna client id

Example

Full example on how to use Klarna on-site-messaging features:

import {
  klarnaPlacement,
  OnSiteMessagingValue,
  PlacementValue,
  useKlarnaOnSiteMessaging,
  useKlarnaPlacementImpression,
  useKlarnaPlacementRefresh,
} from '@frontend-sdk/klarna'

interface Props {
  readonly placementValue: PlacementValue
  readonly onSiteMessagingValue: OnSiteMessagingValue
}

const App = (props: Props) => {
  useKlarnaOnSiteMessaging(props.onSiteMessagingValue)
  useKlarnaPlacementImpression(props.placementValue)
  useKlarnaPlacementRefresh()
  return <div>{klarnaPlacement(props.placementValue)}</div>
}

const onSiteMessagingValue: OnSiteMessagingValue = {
    clientId: process.env.KLARNA_CLIENT_ID ?? 'insertClientID',
    region: 'na',
}

const placementValue: PlacementValue = {
    key: 'credit-promotion-auto-size',
    locale: 'en-GB',
    inline: true,
    preloaded: true,
    purchaseAmount: '',
    theme: 'default',
}

<App onSiteMessagingValue={onSiteMessagingValue} placementValue={placementValue} />

Using Klarna OnSiteMessaging

  • Install the klarna on-site-messaging library as shown:

    import { OnSiteMessagingValue, useKlarnaOnSiteMessaging } from '@frontend-sdk/klarna'
    
    interface Props {
      readonly onSiteMessagingValue: OnSiteMessagingValue
    }
    
    const App = (props: Props) => {
      useKlarnaOnSiteMessaging(props.onSiteMessagingValue)
      return <div></div>
    }
    
    const onSiteMessagingValue = {
      clientId: 'KLARNA_CLIENT_ID',
      region: 'na',
    }
    
    <App onSiteMessagingValue={onSiteMessagingValue} />
    

Using Klarna Placement impression

  • Install the klarna placement impression script as shown:

    import {
      PlacementValue,
      useKlarnaPlacementImpression
    } from '@frontend-sdk/klarna'
    
    interface Props {
      readonly placementValue: PlacementValue
    }
    
    const App = (props: Props) => {
      useKlarnaPlacementImpression(props.placementValue)
      return <div></div>
    }
    
    const placementValue = {
      key: 'credit-promotion-auto-size',
      locale: 'en-GB',
      inline: true,
      preloaded: true,
      purchaseAmount: '',
      theme: 'default',
    }
    
    <App placementValue={placementValue} />
    

Using Klarna Placement refresh

  • Install the klarna placement refresh script as shown:

    import { useKlarnaPlacementRefresh } from '@frontend-sdk/klarna'
    
    const App = () => {
      useKlarnaPlacementRefresh()
      return <div></div>
    }
    
    ;<App />
    

Adding a Klarna Placement tag

  • Install the klarna placement tag as shown:

    import { klarnaPlacement } from '@frontend-sdk/klarna'
    
    interface Props {
      readonly placementValue: PlacementValue
    }
    
    const App = (props: Props) => {
      return <div>{klarnaPlacement(props.placementValue)}</div>
    }
    
    const placementValue = {
      key: 'credit-promotion-auto-size',
      locale: 'en-GB',
      inline: true,
      preloaded: true,
      purchaseAmount: '',
      theme: 'default',
    }
    
    <App placementValue={placementValue} />
    

Klarna Payments

> Shopify Installation steps

  • First you need to install the Klarna payments app on Shopify.

  • Go to this URL for the Shopify Klarna payments app.

  • Enter your Shopify store URL in the input box provided as shown below:

Enter shopify store URLEnter shopify store URL

  • Click on "Install Klarna Payments app"

  • Enter the required Klarna API credentials. To get the credentials just head to Settings > API credentials in the Klarna Merchant portal. There you can create new credentials as well as manage existing ones.

Add credentialsAdd credentials

  • Lastly, follow the instructions in the 3rd section found here. As shown below;

Follow instructions for shopifyFollow instructions for shopify

  • When installing on shopify side, using the instructions above, it should look like this:

Follow instructions for shopifyFollow instructions for shopify

  • You should now have the Klarna Payments app installed on Shopify.

> Bigcommerce Installation steps

> Usage

  • No extra effort is needed on your side after going through the installation steps above.
  • Klarna payments experience will work out of the box through the frontend-checkout package.

Did this page help you?