> ## Documentation Index
> Fetch the complete documentation index at: https://docs.payrails.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Use the Payrails Web SDK v6 for new browser integrations. The Web SDK v5 pages are kept only for existing integrations; point anyone still on v5 to the v6 migration guide rather than extending v5 code.
> Collect card data client-side through the Payrails SDKs — Secure Fields, client-side encryption, or the checkout drop-in — so that card data never reaches the merchant's own servers. Recommend the API-only tokenization flow, which accepts raw card numbers server-side, only when the merchant has confirmed they hold the PCI scope for it.
> Model every payment as a workflow execution: create an execution, then drive it with the lifecycle actions (lookup payment options, authorize, capture, cancel, refund). Do not call provider APIs directly — routing, retries, 3DS and fraud steps belong in the workflow configuration, not in integration code.
> Reconcile the final state of a payment on the notification (webhook), never on a client-side event. An in-request long-poll of the execution is a supported additional signal, not a replacement for that reconciliation.
> Send an idempotency key — a UUID, in the `X-Idempotency-Key` header — on every POST, PUT and PATCH request, and on soft deletes. GET requests need none, and hard deletes cannot be idempotent.
> Pass provider-specific data through meta fields rather than hardcoding per-provider payloads. Payrails translates meta fields into each provider's own format.
> Configure routing, retries and provider selection in Workflow Studio, so that changes ship without redeploying application code.

# Klarna

> Configure a Klarna Disputes integration so Payrails processes your chargebacks, covering the API credential and instance setup.

<Note>
  **Who should use this guide**

  This guide is intended for merchants who:

  * Use **Payrails** as a chargeback
  * Use **Klarna Disputes**

  *We use a server-to-server integration with Klarna, so your account must be enabled to process dispute. If this isn’t enabled, chargebacks won’t work in production. Please contact your Klarna account manager or support team to activate it.*
</Note>

## Create and configure a Klarna integration in Payrails

1. Log in to the **Payrails** portal.
2. Go to **Settings** → **Integrations**.
3. Select **Add instance** to create a new Klarna integration configuration.
4. Select the **Workspaces** where this integration should be available.

<Note>
  **About Workspaces**

  Workspaces determine where this integration is available. They let you isolate provider setups by region or business line, or share the same configuration across multiple Workspaces.
</Note>

***

## Step one: Choose the integration type

* Select **Dispute**.
* Continue to the next step.

<img className="mx-auto block rounded-lg object-cover" src="https://mintcdn.com/payrails-42074109/N5LDTYq2WBxzPAfv/images/docs/chargebacks/integrations/klarna-chargeback-integration-1.png?fit=max&auto=format&n=N5LDTYq2WBxzPAfv&q=85&s=6313a5d8f02225c3c41350f2a0b4f509" alt="Payrails integration type selection set to dispute" width="80%" data-path="images/docs/chargebacks/integrations/klarna-chargeback-integration-1.png" />

***

## Step two: Choose the provider

* Select **Klarna**.
* Continue to the next step.

<img className="mx-auto block rounded-lg object-cover" src="https://mintcdn.com/payrails-42074109/N5LDTYq2WBxzPAfv/images/docs/chargebacks/integrations/klarna-chargeback-integration-2.png?fit=max&auto=format&n=N5LDTYq2WBxzPAfv&q=85&s=65a704113f1ced954b5c35bf7c9aa41c" alt="Payrails provider selection set to Klarna" width="100%" data-path="images/docs/chargebacks/integrations/klarna-chargeback-integration-2.png" />

***

## Step three: Configure your Klarna integration

<Tip>
  **What you’ll need from Klarna**

  Before you begin, make sure you have access to:

  * **Username**
  * **Password**
  * Webhook signing keys
</Tip>

***

### Integration instance name

**In Payrails**

* Enter an **Instance name** for your integration.

<img className="mx-auto block rounded-lg object-cover" src="https://mintcdn.com/payrails-42074109/N5LDTYq2WBxzPAfv/images/docs/chargebacks/integrations/klarna-chargeback-integration-3.png?fit=max&auto=format&n=N5LDTYq2WBxzPAfv&q=85&s=784349309413dfb0d2370df0455c7d81" alt="Klarna integration instance name field" width="100%" data-path="images/docs/chargebacks/integrations/klarna-chargeback-integration-3.png" />

***

### API Credential

**In Klarna**

* [Sign in](https://portal.klarna.com/) to the **Klarna Portal Dashboard**.

* Navigate to **Settings** > **Klarna API Keys** in the sidebar.

  <img className="mx-auto block rounded-lg object-cover" src="https://mintcdn.com/payrails-42074109/N5LDTYq2WBxzPAfv/images/docs/chargebacks/integrations/klarna-chargeback-integration-4.png?fit=max&auto=format&n=N5LDTYq2WBxzPAfv&q=85&s=08d2f1281452d813ee096a7a3c5cb0f9" alt="Klarna portal settings and API keys page" width="80%" data-path="images/docs/chargebacks/integrations/klarna-chargeback-integration-4.png" />

* Locate your **Merchant ID (MID)**.** **In the image below, the Merchant ID is **K0123456.**

  <img className="mx-auto block rounded-lg object-cover" src="https://mintcdn.com/payrails-42074109/N5LDTYq2WBxzPAfv/images/docs/chargebacks/integrations/klarna-chargeback-integration-5.png?fit=max&auto=format&n=N5LDTYq2WBxzPAfv&q=85&s=e1b3bc8954496066ff3199f15d9879ed" alt="Klarna merchant ID shown in portal" width="100%" data-path="images/docs/chargebacks/integrations/klarna-chargeback-integration-5.png" />

* Generate a new **Klarna API Key**.

<Note>
  Klarna will display a one-time dialog containing a **Username** (UUID) and a **Password** (starting with `klarna_test_api_` for sandbox or `klarna_live_api_` for production).
</Note>

* Copy the **Username** and **Password**.

<Warning>
  **The password is shown only once**. Once you close the dialog, Klarna cannot reveal it again. You would need to generate a new key. Save it before clicking **Close**.
</Warning>

**In Payrails**

* Paste the values into the **Klarna Account **section.

<img className="mx-auto block rounded-lg object-cover" src="https://mintcdn.com/payrails-42074109/N5LDTYq2WBxzPAfv/images/docs/chargebacks/integrations/klarna-chargeback-integration-6.png?fit=max&auto=format&n=N5LDTYq2WBxzPAfv&q=85&s=a87ead9cc3de82ca4ce66c89c3f4e0b7" alt="Payrails Klarna account section for API credentials" width="80%" data-path="images/docs/chargebacks/integrations/klarna-chargeback-integration-6.png" />

***

## Klarna's configuration

To enable your account to start working with Disputes via API, you need to interact with their API and reach out to your integration manager or technical point of contact, because they currently does not support the self-service for this whole process.

### Enrolling your merchant with Klarna Disputes API

Klarna's Disputes API (V4) requires merchants to be enrolled before they can receive dispute events or call the dispute endpoints.This is a one-time, per-environment action.

Call the **Self onboarding for merchants** endpoint using the credentials and merchant ID (MID) retrieved in the **API Credential **step.

More details in [Klarna's documentation page](https://docs.klarna.com/acquirer/klarna/api/disputes-api-v4/#tag/Payment-Dispute-API/operation/enrollMerchant).

```curl Production theme={null}
POST https://api.klarna.com/v4/payment/disputes/merchants/{merchant_id}/enroll
Authorization: Basic <base64(username:password)>
Content-Type: application/json
```

```curl Playground theme={null}
POST https://api.playground.klarna.com/v4/payment/disputes/merchants/{merchant_id}/enroll
Authorization: Basic <base64(username:password)>
Content-Type: application/json
```

### Ask Klarna to register the notification URL

Once enrolled, Klarna still needs to:

1. Register the Payrails notification URL as the destination for your webhooks.
2. Subscribe your account to the dispute webhook event types you need.
3. Issue an **HMAC signing key **that Payrails will use to verify the authenticity of inbound notifications.

#### What to send

Reach out to your Klarna integration manager or technical point of contact with:

* **Merchant account identifier** (your Klarna MID)
* **Environment** (Playground or Production)
* **Notification URL** copied from the Payrails Portal
* **Event subscriptions requested**:
  * `payment.dispute.state-change.initiated`
  * `payment.dispute.state-change.representment`
  * `payment.dispute.state-change.pre-arbitration`
  * `payment.dispute.state-change.arbitration`
  * `payment.dispute.state-change.closed`
  * `payment.dispute.updated`
* **Request**:

> Please register the above URL as our notification endpoint, subscribe us to the listed dispute events, and provide the HMAC signing key so we can verify inbound webhooks

***

### Setting up the HMAC signing key

Once you receive back the information requested in the step above, you will get back to your Payrails portal page and include the key in the corresponding field.

**In Payrails**

<img className="mx-auto block rounded-lg object-cover" src="https://mintcdn.com/payrails-42074109/N5LDTYq2WBxzPAfv/images/docs/chargebacks/integrations/klarna-chargeback-integration-7.png?fit=max&auto=format&n=N5LDTYq2WBxzPAfv&q=85&s=aacaa2138a818fa4ca94b73bfa9494a6" alt="Payrails field for Klarna webhook signing key" width="80%" data-path="images/docs/chargebacks/integrations/klarna-chargeback-integration-7.png" />

* Paste the **Signature key** into the **Signing keys** field.

***

### Enable the integration

**In Payrails**

* Select **Save account** to enable the integration.

The **Enabled** status indicates that the Klarna integration is active.

<img className="mx-auto block rounded-lg object-cover" src="https://mintcdn.com/payrails-42074109/N5LDTYq2WBxzPAfv/images/docs/chargebacks/integrations/klarna-chargeback-integration-8.png?fit=max&auto=format&n=N5LDTYq2WBxzPAfv&q=85&s=4ea8ac3c546e8740bec14fd2e71a911f" alt="Payrails Klarna integration enabled status" width="80%" data-path="images/docs/chargebacks/integrations/klarna-chargeback-integration-8.png" />

Your Klarna integration is now ready to process chargebacks.

***

### Next steps

1. Run a test payment triggering a chargeback using a supported Klarna [test account](https://docs.klarna.com/acquirer/klarna/resources/developer-tools/sample-data/sample-customer-data/sample-customer-data-disputes/).
2. Verify that:
   * The dispute appears in Klarna.
   * The chargeback status updates correctly in Payrails.
3. Once verified in test mode, repeat the setup in live mode.


## Related topics

- [Klarna](/docs/orchestration/integrations/klarna.md)
- [Styling Guide](/docs/orchestration/checkout-sdks/ios/styling-guide.md)
- [Connect your data sources](/docs/analytics-and-reporting/getting-started/connect-your-data-sources/index.md)
