KLARNA- tags provide exactly the building blocks this exchange needs: the two tokens, the field names for the hidden input fields, the return address and the order data as JSON. In addition, there are three area tags that query the state of the Klarna session.
The tags are distributed across three pages of the order process. The basket contains the tags for express checkout, while the payment and shipping method page and the order overview contain the widget and the authorization.
Guide: Klarna Payments · Guide: JSON interface
Displaying the widget
The Klarna script needs the client token to build its widget.Always wrap the integration in an area tag. Without a valid Klarna session, the token is empty, and the script builds an empty widget that the buyer cannot use.
KLARNA-ShowKlarnaAtPayDeliv is not described in the previous documentation. The tag combines two conditions: the setting that Klarna should already appear on the payment and shipping method page, and that the session is not locked. This lets you decide in one place whether the widget appears there or only on the order overview.Retrieving the authorization
After authorization, the Klarna script returns a token that the shop needs. To do this, the template sends the buyer to a dedicated return address and appends the token as a parameter.The field name is fixed in the shop system. Don’t write it by hand; always take it from
KLARNA-AuthTokenName, otherwise the shop won’t recognize the returned token.KLARNA-AuthTokenValue is only filled after the return. As an area tag, it is suitable for building the order overview differently depending on the state of the authorization.When the order data has changed
The Klarna session contains a copy of the order and address data. If the buyer then changes something, for example the quantity or the delivery address, the two no longer match.KLARNA-NeedUpdate takes effect in exactly this case.
In the mode with a locked Klarna session, the area tag never takes effect, because a new session is set up for each pass anyway. The template may still contain the area tag; it then simply has no effect.
The order data as JSON
KLARNA-OrderDataJSON outputs the data that the shop passes to Klarna, including billing and delivery address. This is especially useful for express checkout, where the address comes from Klarna and is to be displayed in the shop.
The JSON is regenerated from the current basket and address data each time the tag is evaluated. It is therefore always up to date, but it also has a cost. Evaluate it once and then continue working with the JSON interface instead of placing the tag several times.
The output is converted from UTF-8 to the shop’s character set. Umlauts in the addresses supplied by Klarna therefore appear in the encoding that the rest of the page also uses.
Express checkout in the basket
With express checkout, the buyer starts the payment process in the basket, and Klarna supplies the address data.This field name is also fixed. The Klarna script writes the address data to the field, and the shop reads it on submission under exactly this name.
The old integration
KLARNA-ObsoleteMode distinguishes between the two operating modes of the integration. The area tag takes effect if the shop is not running in the mode with a locked Klarna session, that is, in the older variant.
You only need this area tag as long as a template has to serve both variants. Once the migration is complete, you can remove the branch that is no longer needed and dissolve the area tag.
The tags at a glance
KLARNA-MerchantID and KLARNA-AddressDataName belong on the basket page ws_basket.htm, KLARNA-AuthTokenName and KLARNA-AuthCallbackURL on the order overview page ws_place_order.htm, and KLARNA-ClientToken on both pages of the payment process. The other tags are permitted on all templates.
Related topics
- Guide: Klarna Payments
- Reference: EJD- (JSON interface)
- Reference: ST- (Page states)
- Reference: MSG- (Messages)
