Describes an API proposal for Stripe Messaging to leverage OSM API.
This document describes the integration steps needed to leverage Klarna's On-site Messaging API by Stripe for the Payment Method Messaging Element
To ensure secure communication, the API mandates the inclusion of two crucial headers for authentication. First, Stripe must pass an Authentication header containing the requisite credentials. Second, a Klarna-Account header is required to specify the Merchant ID (MID) of the sub-account on which operations are intended.
Initiate an HTTPS GET request to the OSM API using the programming language you prefer. Example:
Please ensure you target the appropriate API endpoint based on both the environment and the geographic region.
The endpoint response will look like:
Warning: Do not rely on the presence or absence of fields that are not publicly documented in our API. While we strive to maintain backwards compatibility and stability for publicly documented fields, additional fields may be added in the future. Please ensure that any validation of API responses is limited to the publicly documented fields.
Utilize the content payload from the API response to render the message. This can be accomplished through the programming language or framework of your preference.
The API endpoint returns a Cache-Control
header, which should be adhered to whenever feasible. For web-based frontend integrations, this header is automatically managed by the browser.
Should the purchase amount undergo any changes, it necessitates a subsequent API call to update the displayed messaging. Once the new data is retrieved, the message should be re-rendered to reflect the current purchase amount.
As placement key `stripe-messaging-element` should be passed.
Make sure you are calling the right endpoint per environment and region, the following query parameters are required:
Name | Required | Description |
---|---|---|
placement_key | Yes | The only allowed placement types is:
|
locale | Yes | The language and the billing country as locale, supported: "en-AU","en-NZ","en-AT","de-AT","nl-BE","en-BE","fr-BE","en-CH","de-CH","it-CH","fr-CH","en-CZ","cs-CZ","de-DE","en-DE","da-DK","en-DK","es-ES","en-ES","fi-FI","sv-FI","en-FI","fr-FR","en-FR","en-GB","en-GR","el-GR","en-HU","hu-HU","en-IE","en-IT","it-IT","nl-NL","en-NL","no-NO","nb-NO","en-NO","en-PL","pl-PL","en-PT","pt-PT","en-RO","ro-RO","sv-SE","en-SE","en-CA","fr-CA","es-MX","en-MX","en-US","es-US" |
channel | Yes | 'web' or 'app' . Used to identify the platform where the message will be shown. |
purchase_amount | Yes | The amount of money in minor units ($120.00 = 12000), minor currency units are defined in ISO-4217. |
The API will also return response headers, for debugging and caching purposes.
Name | Description |
---|---|
klarna-correlation-id | UUID v4 formatted string. Unique identifier for the request. Used for debugging. |
cache-control | Specifies how long the response should be cached. Integrator needs to honor this header when possible. Default value is: private, max-age=86400 |
Depending on your request the API will return the relevant status code
Status Code | Description |
---|---|
200 | Successful request with content. |
204 | Successful request, no content to display. This can happen if the purchase_amount is out of range for all of your product configuration. |
400 | Bad Request, check that all the required parameters are being sent and that their format is valid. |
403 | Forbidden. Authentication error. |
404 | placement_key not found or locale not available. |
500 | Internal error, please contact us and send us the klarna-correlation-id present in the response headers so we can debug the issue. |
Once you get the response from the OSM API endpoint you can render the message using the content object present in the response.
The response will have an array of payment_options
. Each item in the array represents a possible payment option for the passed amount and contains:
payment_method_label
Each element within the payment_options array includes a payment_method_label field, designating the type of payment option it represents. Note that these labels are not unique.
Possible Values: Installments, Financing, Pay Now, Pay Later.
payment_option_id
This field serves as a unique identifier for each element in the payment_options array. Generated upon API invocation, this identifier is arbitrary in nature. In the context of Stripe's Messaging Element, this field can be ignored.
content
To facilitate seamless integration, each option is structured as a collection of nodes. These nodes encompass textual content, actionable elements (links), and images. The API has three node types:
It will have a name and value, as string.
The possible call-to-action buttons or links. These elements will contain a URL that should be opened when the user clicks on a button. In the context of Stripe's messaging element, this node can be ignored.
We currently support 2 types of action nodes:
ACTION_LEARN_MORE
: Link to a external page hosted on Klarna servers that displays more information to the customer about the advertised payment method ACTION_PREQUALIFY
: Link to an external page hosted on Klarna servers that allows the customer to perform a pre-qualify credit check. Note: This only applies if the merchant supports financing with Klarna.ACTION_OPEN_TERMS
: Link to the terms of the payment optionEach action node has a label property that can be used to find the word(s) in the TEXT nodes from which the provided url
should be linked. For example in the following snippet of terms:
The word "terms" inside the TEXT_TERMS
needs to be linked to the url defined in the ACTION_OPEN_TERMS
(defined as label)
This contains a link to the Klarna logo with relevant a11y alt text. Only SVG format is provided. If a different image format is needed, please see Branding images.