0.26.1 • Published 2 years ago

@frontend-sdk/klarna v0.26.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Klarna

Klarna integration for Shogun Frontend.

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

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

2 years ago

0.26.0

2 years ago

0.25.0

2 years ago

0.24.2

3 years ago

0.24.1

3 years ago

0.24.0

3 years ago

0.23.0

3 years ago

0.22.0

3 years ago

0.21.0

3 years ago

0.20.0

3 years ago

0.19.0

3 years ago

0.18.0

3 years ago

0.17.0

3 years ago

0.16.0

3 years ago

0.15.1

3 years ago

0.14.0

3 years ago

0.15.0

3 years ago

0.11.0

3 years ago

0.12.0

3 years ago

0.13.0

3 years ago

0.10.0

3 years ago

0.9.0

3 years ago