Setup
A Klarna account can be requested from the Klarna Business Portal.Credentials
To connect a Klarna account, obtain the following credentials from the Klarna Business Portal.- Username: An API username which can be generated by navigating to Preferences → Settings → Manage Klarna API Credentials
- Password: An API password which can be generated by navigating to Preferences → Settings → Manage Klarna API Credentials
- Region: The region of the Klarna account. Enter
EUfor Europe,NAfor North America, orOCfor Oceania - Client ID (optional): Required only for Express Checkout. Obtain from your Klarna Business Portal and enter it here so Gr4vy can return it via the Create Session API to initialize the Klarna Payments Buttons SDK.
Capabilities
Supported countries
Supported currencies
Integration
For Klarna, the default integration uses a redirect to the Klarna hosted payments page. A direct integration using the Klarna JavaScript SDK or mobile SDKs is also supported.Redirect integration
Start by creating a new transaction with the following required fields.payment_method.approval_url and the buyer_approval_pending status.
approval_url to complete the Klarna approval flow. Once approved, the transaction moves to authorization_succeeded.
Direct integration
Gr4vy supports direct integration with Klarna using the Klarna Payments SDK or mobile SDKs, allowing you to embed the payment UI directly in your app while using Gr4vy to manage the transaction lifecycle. Two modes are supported: Standard Checkout (session-based) and Express Checkout (button-based, no session required).Standard Checkout
To initiate Standard Checkout, create a transaction withintegration_client set to web, ios, or android. For mobile, use your app deep link for redirect_url (for example, yourapp://).
After the transaction is created, the API response includes a session_token which can be used to get the session data for that transaction.
client_token from the session data to initialize the Klarna SDK. Refer to the Klarna SDK documentation for web integration.
Web
authorization_token. To finalize the transaction, send this token to Gr4vy as a query parameter on the default_completion_url returned in the session response.
Terminal
authorization_succeeded. It can then be captured, voided, or refunded through Gr4vy.
Express Checkout
Klarna Express Checkout embeds the Klarna payment button directly in your page using the Klarna Payments Buttons SDK. The buyer authorizes the payment inside the SDK widget — no redirect to a hosted page is required. After authorization, your backend creates the Gr4vy transaction in a single call using theauthorization_token returned by the SDK.
Get the client ID
The Klarna Payments Buttons SDK requires a client_id to initialize. You can obtain this in one of two ways:
-
Via the Gr4vy API — Call the Create Payment Service Session endpoint for your Klarna connection. Gr4vy returns a
clientIdfrom the connector credentials without making any Klarna API call.TerminalResponse -
Hardcoded — Copy the
client_idfrom your Klarna Business Portal and embed it directly in your frontend. This is suitable when the client ID does not change per session.
klarnaAsyncCallback function must be defined before the SDK script tag so it is available when the SDK initializes.
client_id and renders a KlarnaExpressCheckoutButton.
iOS (Swift) — See the iOS integration guide.
authorization_token, create a Gr4vy transaction and pass the token in connection_options under the klarna-klarna key. Gr4vy forwards the token to Klarna to place the order directly — the transaction moves to authorization_succeeded without any redirect.
The
authorization_token returned by the Klarna SDK expires within approximately 60 minutes. Create the Gr4vy transaction immediately after receiving it.Subscriptions (MIT)
Klarna supports storing the buyer’s payment method during the first (customer-present) payment and charging future renewals as merchant-initiated transactions (MIT) using the saved payment method, typically with no redirect.Webhooks must be configured for the Klarna payment service. After the buyer approves the payment, Klarna sends an
authorization_token via webhook which Gr4vy uses to create the reusable customer token. Without this webhook, store: true will not work.First payment
Setstore to true to save the Klarna payment method for the buyer.
Subsequent payment
After the payment method is saved, use the payment method ID to charge future renewals.- Set
payment_method.methodtoidand pass the saved payment method ID. - Set
payment_sourcetorecurring. - Set
merchant_initiatedandis_subsequent_paymenttotrue.