npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@frontend-sdk/klarna

v0.26.1

Published

Klarna integration for Shogun Frontend.

Downloads

215

Readme

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.