@frontend-sdk/klarna
v0.26.1
Published
Klarna integration for Shogun Frontend.
Downloads
215
Keywords
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.
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;
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:
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.
- Lastly, follow the instructions in the 3rd section found here. As shown below;
- When installing on shopify side, using the instructions above, it should look like this:
- You should now have the Klarna Payments app installed on Shopify.
> Bigcommerce Installation steps
- To install Klarna on Bigcommerce follow the steps outlined here in the official support pages.
> 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.