@frontend-sdk/klarna
TypeScript icon, indicating that this package has built-in type declarations

0.26.1 • Public • Published

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 dashboard showing Klarna's script with data-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'

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

const klarnaClientID =
  process.env.KLARNA_CLIENT_ID !== null && process.env.KLARNA_CLIENT_ID !== undefined && process.env.KLARNA_CLIENT_ID;

const onSiteMessagingValue = {
    clientId: klarnaClientID || 'insertClientID',
    region: 'na',
}

const 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'
    
    const App = (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'
    
    const App = (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'
    
    const App = (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:

Klarna Payments App showing step 1 of 3: "Install Klarna Payments app". It contains an input to enter your Shopify store URL and a button that reads as "Install Klarna Payments app"

  • 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.

Klarna Payments App showing step 2 of 3: "Authenticate Klarna API Credentials". It contains two inputs and a "Save button" to retrieve Klarna's API credentials. The first input is for Klarna API username, and the second input is for Klarna API Password. Alongside the inputs there's a section with the Authentication Status

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

Klarna Payments App showing step 3 of 3: "Activate Payment Method(s). It contains instructions on how to "Activate the Klarna Alternative Payment Method(s)" and how to "Set email and phone number as required in Shopify Checkout"

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

Shopify dashboard showing Klarna Payments installation page

  • 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.

Readme

Keywords

none

Package Sidebar

Install

npm i @frontend-sdk/klarna

Weekly Downloads

79

Version

0.26.1

License

MIT

Unpacked Size

20.2 kB

Total Files

17

Last publish

Collaborators

  • facundoshogun
  • shogun-engineering
  • nino-majder
  • william-shogun
  • ivins
  • shogun-admin