Integrate Klarna's Payment Tokenization for server-side scenarios. This guide shows how to request a customer token, handle tokenization outcomes including step-up flows, and securely store tokens for future transactions.
This guide covers how to create a customer token with Klarna using a server-side integration when the customer is present to provide consent. As an Acquiring Partner, the backend collects payment context from a Partner, calls the Payment Authorize API with a tokenization request, handles the STEP_UP_REQUIRED initial response, manages the step-up flow, and securely stores the token for future use.
For conceptual understanding of tokenization, token scopes, use cases, and authorization patterns, see the Payment Tokenization resource.
Once the customer initiates tokenization (for example, during subscription signup or account setup):
1.
The Partner initiates tokenization through the Acquiring Partner
2.
The Acquiring Partner forwards the tokenization request to Klarna by calling the authorizePayment
3.
Klarna returns STEP_UP_REQUIRED because customer consent is always required for tokenization
4.
The Acquiring Partner returns the payment_request_url to the Partner
5.
The customer completes the Klarna Purchase Journey to provide consent
6.
Klarna sends a webhook upon step-up completion. The payload differs by scenario:
6.1.
Tokenization only: The webhook contains the customer_token. No further API call is needed. The Acquiring Partner securely stores the customer token issued by Klarna, maps it to an internal identifier, and returns that internal customer token identifier to the Partner.
6.2.
Tokenization combined with authorization: The webhook contains both the customer_token and a klarna_network_session_token. The Acquiring Partner calls the Payment Authorize API again with the klarna_network_session_token to complete the initial Payment Authorization. Klarna returns the final result (APPROVED or DECLINED). The Acquiring Partner then securely stores the customer token issued by Klarna, maps it to an internal identifier, and returns the internal customer token identifier and payment result to the Partner.
sequenceDiagram
autonumber
participant Customer
participant Partner
participant AcquiringPartner as Acquiring Partner
participant Klarna
Customer->>Partner: Initiate tokenization
Partner->>AcquiringPartner: Request tokenization
Note over Partner,AcquiringPartner: payment context according to the tokenization scenario
Note over Partner,AcquiringPartner: Tokenization settings matching Klarna customer token scopes
Note over Partner,AcquiringPartner: return_url, app_return_url for step-up
AcquiringPartner->>Klarna: Call Payment Authorize API
Note over AcquiringPartner,Klarna: payment context according to the tokenization scenario
Note over AcquiringPartner,Klarna: request_customer_token with scopes
Note over AcquiringPartner,Klarna: step_up_config configured with HANDOVER
Klarna->>AcquiringPartner: STEP_UP_REQUIRED
Note over Klarna,AcquiringPartner: Customer consent always required for tokenization
AcquiringPartner->>Partner: Return payment_request_url
Partner->>Customer: Redirect to Klarna's Purchase Journey
Customer->>Klarna: Customer provides consent
alt Tokenization only
Klarna-->>AcquiringPartner: Webhook: Payment Request completed
Note over AcquiringPartner,Klarna: Payload contains customer_token, no further API call needed
Note over AcquiringPartner: Store customer_token securely, map to internal identifier
AcquiringPartner->>Partner: Return internal customer token identifier
Partner->>Customer: Token saved successfully
else Tokenization combined with authorization
Klarna-->>AcquiringPartner: Webhook: Payment Request completed
Note over AcquiringPartner,Klarna: Payload contains customer_token + klarna_network_session_token
AcquiringPartner->>Klarna: Complete initial Payment Authorization
Note over AcquiringPartner,Klarna: Call Payment Authorize API with Klarna Network Session Token
Klarna->>AcquiringPartner: Payment Authorization result (APPROVED / DECLINED)
alt APPROVED
Note over AcquiringPartner: Store customer_token securely, map to internal identifier
AcquiringPartner->>Partner: Return internal customer token identifier + Payment Authorization result
Partner->>Customer: Token saved, Payment Authorization completed
else DECLINED
AcquiringPartner->>Partner: Return failure indicator
Partner->>Customer: Token saved, Payment Authorization failed
end
end
Determine which tokenization scenario applies to the use case:
Tokenization only: Save a payment method without an immediate charge
Tokenization combined with authorization: Create a token while processing the first Payment Authorization
The appropriate request structure for each scenario is shown in Step 3. See the Payment Tokenization resource for detailed scenario descriptions and use cases.
Collect the necessary information from the Partner to request a customer token. The required fields depend on the tokenization scenario.
Update the Partner-facing API to collect the following fields for tokenization without an initial Payment Authorization:
Parameter
Required (Acquiring Partner)
Required (Partner)
Description
currency
Yes
Yes
Currency in ISO 4217 format for future transactions using the token.
scopes
Yes
Yes
Token scope defining the authorization pattern: payment:customer_present or payment:customer_not_present. See Token Scopes for guidance.
supplementary_purchase_data
Yes
Recommended
Additional details about the tokenization use case. Include this data to improve fraud assessment and customer communication.
supplementary_purchase_data.subscriptions
Yes
Conditional
Subscription details including subscription reference, billing plans, and free trial status. Mandatory when the token will be used for subscription charges, i.e. when token scope = payment:customer_not_present.
supplementary_purchase_data.ondemand_service
Yes
Conditional
On-demand service details describing the service the token will be used for. Mandatory when the token will be used for on-demand charges, i.e. when token scope = payment:customer_present.
supplementary_purchase_data.customer
Yes
Recommended
Information about the customer based on their previous interactions with the Partner. Used by Klarna to simplify sign-up and for fraud assessment.
klarna_network_session_token
Yes
Conditional
Encodes Klarna Network Session Token context (prequalification, sign-in state, or approval). Optional on the initial tokenization request; required for finalization after step-up completion.
klarna_network_data
Yes
Recommended
Additional data to enable custom features or data exchange supported by the Partner. Klarna accepts this passthrough field in a structured JSON format and forwards it to relevant systems for interoperability. Treat this value as an opaque string; do not validate or infer its structure.
return_url
Yes
Recommended
URL to redirect the customer after completing the step-up flow. Recommended for web flows.
app_return_url
Yes
Recommended
Mobile application return URL (app scheme with no action deeplink). The customer will be redirected to this URL after third-party redirects. Recommended for mobile app flows.
Token scope selection is critical
The token scope must match your intended tokenization pattern. See Token Scopes for detailed guidance on choosing between payment:customer_present and payment:customer_not_present.
Requirements
Use exact parameter names klarna_network_session_token and klarna_network_data in the Partner-facing API to ensure Partners can easily identify and use them.
Forward all parameters unmodified to Klarna.
Parameter validation must not be more restrictive than Klarna's authorizePayment.
Support all printable UTF-8 characters.
Supplementary purchase data handling:
Map your existing Tokenization settings to Klarna customer token scopes.
Map your existing Partner-facing fields (line items, customer billing address, shipping, order reference) into supplementary_purchase_data when calling Klarna.
Don't add new Partner-facing fields "just for Klarna" if you already have equivalent fields in your existing schema. Avoid forcing Partners to submit the same data twice using parallel structures
Do
Map existing line items into supplementary_purchase_data.line_items.
Map existing customer details into supplementary_purchase_data.customer.
Map existing shipping data into supplementary_purchase_data.shipping.
Map your existing purchase reference into supplementary_purchase_data.purchase_reference.
Don't
Introduce a parallel line-item structure such as klarna_line_items.
Duplicate customer fields you already collect from Partners.
Add a separate shipping object "just for Klarna".
Force Partners to submit the same purchase reference twice.
Supplementary purchase data scenarios
Acquiring Partners may receive supplementary purchase data (including line items, L2/L3 data for Card Network optimization, and transaction context) in one or both of the following ways:
Embedded in klarna_network_data: Forward as received without parsing or mapping
Provided as individual API fields: Map to the supplementary_purchase_data object when calling authorizePayment
flowchart LR
Partner[Partner]:::tertiaryEntity
LineItems[Line items,\nL2/L3 data,\netc]:::secondaryEntity
KlarnaNetLeft[Klarna Network Data]:::secondaryEntity
AP[Acquiring Partner's API]:::primaryEntity
Supplementary[Supplementary\nPurchase Data]:::secondaryEntity
KlarnaNetRight[Klarna Network Data]:::secondaryEntity
Auth[Payment Authorization]:::primaryEntity
%% Main flows
Partner --> LineItems --> AP --> Supplementary --> Auth
Partner --> KlarnaNetLeft --> AP --> KlarnaNetRight --> Auth
Optionally set step_up_config.customer_interaction_config.interaction_expiry to override the default 3-hour Payment Request lifetime. See Custom Payment Request expiry.
The initial Payment Authorize API call always returns STEP_UP_REQUIRED for tokenization requests.
When requesting tokenization through the authorizePayment, Klarna returns response objects that correspond to the elements included in the request. The response contains a customer_token_response, and if an initial Payment Authorization was also requested, a payment_transaction_response will be included as well.
Result
Description
Next steps
STEP_UP_REQUIRED
Customer consent is always required for tokenization. Klarna creates a payment_request containing the payment_request_url for the Klarna Purchase Journey.
Return the payment_request_url to the Partner to redirect the customer. Customer interaction is required to complete tokenization.
What you receive:
customer_token_response.result: STEP_UP_REQUIRED
payment_request object containing:
payment_request_id: Unique identifier for the step-up request
payment_request_url: URL to launch the Klarna Purchase Journey
Acquiring Partners must include return URLs in the step_up_config when calling authorizePayment to enable the step-up scenario.
These URLs, set inside the customer_interaction_config object, tell Klarna where to redirect the customer after they complete or stop the Klarna Purchase Journey.
If the Klarna Purchase Journey is launched in a web environment, Klarna redirects the customer to the return_url after they finish — whether they complete or stop the flow. This can be a URL managed by the Acquiring Partner (which handles redirection logic) or one collected directly from the Partner.
On mobile, the customer may be redirected to a third-party app (such as a bank app) or the Klarna app during the Klarna Purchase Journey. The app_return_url brings the customer back to the Partner's mobile app when this happens.
Partners must register a URL scheme (e.g., yourapp://klarna) or a universal link that resumes the payment flow. Klarna invokes this URL after the customer completes a native app-based step, such as biometric authentication or Klarna app login. Partners are expected to resume the mobile app in its last state without applying state changes or deep link navigations.
The return_url and app_return_url are not mutually exclusive. Depending on the device and environment, either or both may be triggered:
Scenario
Description
Pure web flow
The customer starts the Klarna Purchase Journey in a desktop browser. After completing the flow, Klarna redirects them to return_url.
App-to-app flow
The Partner's native app opens the Klarna Purchase Journey using a universal link. If the Klarna app is installed, the customer goes directly into it. After completion, Klarna redirects them to app_return_url.
WebView flow with app handover
The Partner's native app starts the Klarna Purchase Journey in a System WebView. If the customer must authenticate via an external banking app, app_return_url returns them to the Partner's app mid-flow. They then resume in the WebView and, on completion, are redirected to return_url.
If the Acquiring Partner already collects a suitable return_url or app_return_url from the Partner, do not request a second one — this would increase the minimum integration requirements for Klarna to work.
Map the Klarna authorization result to the Partner-facing API response according to the authorization outcome. The response may include a payment_request_url and/or a klarna_network_response_data parameter.
Requirements
payment_request_urlMUST be returned directly to the Partner in an existing field and MUST NOT be wrapped or hidden behind Acquiring Partner-managed redirects.
Use exact parameter name klarna_network_response_data in the Partner-facing API to ensure Partners can easily identify and use the parameter. Treat this value as an opaque string; do not validate or infer its structure.
Below are examples of how Acquiring Partners can return the klarna_network_response_data parameter in their Partner-facing APIs depending on the authorization outcome.
When step-up is triggered, authorizePayment returns a STEP_UP_REQUIRED result along with a Payment Request containing the payment_request_url and klarna_network_response_data which the Partner needs in order to launch the Klarna Purchase Journey, either through a redirect or a pop-up experience.
The Klarna Purchase Journey allows the customer to authenticate with Klarna (via login, one-time passwords, etc.), choose a payment method, and accept the payment.
Phone collection in the Klarna Purchase Journey
What happens next:
When the customer completes step-up, Klarna sends a webhook with the token(s). Your next step depends on the scenario:
Tokenization only: Extract the customer_token from klarna_customer.customer_token in the webhook payload, store it securely, and return the internal token identifier to the Partner. No further API call is needed.
Tokenization combined with authorization: Use the klarna_network_session_token from the webhook to call the Payment Authorize API and complete the initial Payment Authorization, then store the customer_token securely (Step 6).
When the payment.request.state-change.completed webhook arrives, tokenization is complete — the customer_token is available in the payload regardless of scenario. For the Tokenization only scenario, no further API call is needed: store the token and return the result to the Partner. For the Tokenization combined with authorization scenario, proceed to Step 6 to finalize the initial Payment Authorization.
To retrieve the required token(s), Klarna provides multiple integration methods. Subscribing to Klarna webhook events is required and may be combined with additional methods to improve resilience.
Using webhooks ensures reliable completion handling, particularly when the customer closes the browser before returning, network interruptions occur during redirects, or post-processing is required before notifying the customer.
Subscribe to the payment.request.state-change.completed webhook event using the Klarna webhook guidelines. Klarna sends this event when the Payment Request reaches the COMPLETED state.
This event indicates that the customer has finished the step-up interaction and that the Acquiring Partner can proceed with finalizing the authorization.
This step applies only to the Tokenization combined with authorization scenario. Tokenization is already complete after step-up — the customer_token is delivered in the webhook payload.
To process the initial Payment Authorization, call the authorizePayment using:
The newly obtained klarna_network_session_token in the Klarna-Network-Session-Token request header
The same payment context (amount, currency, supplementary_purchase_data, klarna_network_data) used in the initial request
The same payment_transaction_reference to link the requests
If the klarna_network_session_token has expired (1-hour validity) or the payment context doesn't match the initial request, the finalization call returns DECLINED.
Klarna evaluates the Payment Request and returns one of the following results for payment_transaction_response:
Result
Description
Next steps
APPROVED
The Payment Authorization succeeded and a payment_transaction was created. The customer_token is returned in customer_token_response and is ready for future use.
Store the customer_token securely and return the payment result to the Partner.
DECLINED
The Payment Authorization failed. No payment_transaction was created. The customer_token is still returned in customer_token_response and is valid for future use.
Return the failure result to the Partner. Store the customer_token securely — it remains valid despite the Payment Authorization failure.