# Klarna
source: https://developer.mastercard.com/mastercard-gateway/documentation/payment-methods/alt-pay-methods/buynow-paylater/klarna/index.md

Klarna AB is a popular Swedish bank offering payers in Europe, a range of flexible financing options when purchasing goods online. Through Klarna payment methods, payers can pay immediately, delay the payment until after delivery, or spread the cost over a number of installments.

Klarna payment methods are supported in the Mastercard Gateway. This page describes integration details specific to Klarna payment methods. It is recommended that you read the [integration guidelines for browser payments](https://developer.mastercard.com/mastercard-gateway/documentation/payment-methods/imp-brow-pay-int/index.md), before building a Klarna integration.

## Prerequisites {#prerequisites}

To offer Klarna payment methods through the Mastercard Gateway,

* Be registered with your browser payments service provider
* your merchant profile on the Mastercard Gateway must be configured using the details of your account with the browser payments service provider, and
* you must have a bank account in one of the supported currencies registered against your merchant account at your browser payments service provider.

## Klarna Pay Later {#klarna-pay-later}

Klarna AB is a Swedish bank that offers Klarna Pay Later, which is a delayed payment option. Payers review the items that the merchant delivers to them and keep only those items that they intend to purchase and pay for, and return all the unwanted items. For the approved payments, Klarna AB assumes all credit and fraud risk, and pays you the full amount for an order. Ensure to refund each item that payers return to you through the [Refund](https://developer.mastercard.com/mastercard-gateway/documentation/api-reference/v100/rest/api-ops/index.md#transaction) operation. Payers can cancel orders by performing a Refund for the full purchased amount. Klarna subsequently invoices payers and collects the payment, providing email notifications and reminders in advance of the payment due date.

Klarna Pay Later supports transactions originating from multiple countries with their corresponding currencies.

|       Country       | Currency |
|---------------------|----------|
| Austria (AUT)       | EUR      |
| Germany (DEU)       | EUR      |
| Netherlands (NLD)   | EUR      |
| Finland (FIN)       | EUR      |
| Sweden (SWE)        | SEK      |
| Norway (NOR)        | NOK      |
| Great Britain (GBR) | GBP      |
| Denmark (DNK)       | DKK      |

## Klarna Financing {#klarna-financing}

Klarna AB is a Swedish bank that offers Klarna Financing, which is a flexible payment option. It is a long-term financing agreement wherein payers can purchase an item and pay in installments. You can choose to repay in six to thirty-six equal monthly installments including interest (if any), pay a minimum amount each month, or pay off the entire amount within a month.

Klarna Financing supports transactions originating from multiple countries with their corresponding currencies.

|       Country       | Currency |
|---------------------|----------|
| Austria (AUT)       | EUR      |
| Germany (DEU)       | EUR      |
| Netherlands (NLD)   | EUR      |
| Finland (FIN)       | EUR      |
| Sweden (SWE)        | SEK      |
| Norway (NOR)        | NOK      |
| Great Britain (GBR) | GBP      |
| Denmark (DNK)       | DKK      |

## Klarna Pay Now {#klarna-pay-now}

Klarna AB is a Swedish bank that offers Klarna Pay Now, which is an immediate payment option. Payers can pay either through a bank transfer, a direct debit, or any card.

Klarna Pay Now supports transactions originating from multiple countries with their corresponding currencies.

|      Country      | Currency |
|-------------------|----------|
| Austria (AUT)     | EUR      |
| Germany (DEU)     | EUR      |
| Netherlands (NLD) | EUR      |
| Sweden (SWE)      | SEK      |

## Klarna Integration {#klarna-integration}

### Klarna through Hosted Checkout {#klarna-through-hosted-checkout}

Hosted Checkout integration allows you to collect payment details from your payers through an interaction that the Mastercard Gateway hosts and displays.

#### Klarna Pay Later {#klarna-pay-later-1}

From Mastercard Gateway API version 52 and later, Klarna Pay Later is automatically available as a payment method once your payment service provider enables and configures you for this payment method.

#### Klarna Financing {#klarna-financing-1}

From Mastercard Gateway API version 62 and later, Klarna Financing is automatically available as a payment method once your payment service provider enables and configures you for this payment method.

#### Klarna Pay Now {#klarna-pay-now-1}

Klarna Pay Now through Hosted Checkout will be available soon. Contact your payment service provider for further information.

For details, see [Browser Payments through Hosted Checkout Integration](https://developer.mastercard.com/mastercard-gateway/documentation/payment-methods/imp-brow-pay-int/index.md#browser-payments-through-hosted-checkout-integration).

### Klarna through Direct Payment {#klarna-through-direct-payment}

Direct Payment integration allows you to offer the Klarna payment methods on your own checkout page.

#### Klarna Pay Later {#klarna-pay-later-2}

Klarna Pay Later is supported from Mastercard Gateway API version 52 and later.

Make the Initiate Browser Payment request where `sourceOfFunds.type` = KLARNA_PAY_LATER and `browserPayment.operation` = PAY (the Authorize operation is not supported by Klarna).

Warning: If your API version is lower than 61, use the `sourceOfFunds.type` = KLARNA when you make the Initiate Browser Payment request.

<br />

### Sample Code to Initiate Klarna Pay Later Payment {#sample-code-to-initiate-klarna-pay-later-payment}

```json
{
  "apiOperation": "INITIATE_BROWSER_PAYMENT",
  "browserPayment": {
    "operation": "PAY",
    "returnUrl": "<your_merchant_URL>"
  },
  "customer": {
    "email": "john.smith@example.com",
    "firstName": "John",
    "lastName": "Smith",
    "mobilePhone": "01234567890"
  },
  "billing": {
    "address": {
      "street": "10 Upper Bank Street",
      "postcodeZip": "E14 5NP",
      "city": "London",
      "country": "GBR"
    }
  },
  "order": {
    "amount": 57.2,
    "currency": "GBP",
    "item": [
      {
        "name": "Blue Jeans",
        "quantity": "1",
        "unitPrice": 70.83,
        "unitDiscountAmount": 48.16,
        "unitTaxAmount": 4.53,
        "detail": {
          "unitTaxRate": 0.2
        }
      },
      {
        "name": "Red Shirt",
        "quantity": "1",
        "unitPrice": 20.83,
        "unitTaxAmount": 4.17,
        "detail": {
          "unitTaxRate": 0.2
        }
      },
      {
        "name": "Shipping & Handling",
        "quantity": "1",
        "unitPrice": 4.17,
        "unitTaxAmount": 0.83,
        "detail": {
          "unitTaxRate": 0.2
        }
      }
    ]
  },
  "sourceOfFunds": {
    "type": "KLARNA_PAY_LATER"
  }
}
```

#### Klarna Financing {#klarna-financing-2}

Klarna Financing is supported from Mastercard Gateway API version 61 and later.

Make an Initiate Browser Payment request where sourceOfFunds.type = KLARNA_FINANCING and browserPayment.operation = PAY (the Authorize operation is not supported by Klarna).

### Sample Code to Initiate Klarna Financing Payment {#sample-code-to-initiate-klarna-financing-payment}

```json
{
  "apiOperation": "INITIATE_BROWSER_PAYMENT",
  "browserPayment": {
    "operation": "PAY",
    "returnUrl": "<your_merchant_URL>"
  },
  "customer": {
    "email": "john.smith@example.com",
    "firstName": "John",
    "lastName": "Smith",
    "mobilePhone": "01234567890"
  },
  "billing": {
    "address": {
      "street": "10 Upper Bank Street",
      "postcodeZip": "E14 5NP",
      "city": "London",
      "country": "GBR"
    }
  },
  "order": {
    "amount": 99.2,
    "currency": "GBP",
    "item": [
      {
        "name": "Blue Jeans",
        "quantity": "1",
        "unitPrice": 70.83,
        "unitDiscountAmount": 48.16,
        "unitTaxAmount": 4.53,
        "detail": {
          "unitTaxRate": 0.2
        }
      },
      {
        "name": "Red Shirt",
        "quantity": "1",
        "unitPrice": 20.83,
        "unitTaxAmount": 4.17,
        "detail": {
          "unitTaxRate": 0.2
        }
      },
      {
        "name": "Leather Belt",
        "quantity": "1",
        "unitPrice": 25,
        "unitTaxAmount": 5,
        "detail": {
          "unitTaxRate": 0.2
        }
      },
      {
        "name": "Baseball Cap",
        "quantity": "1",
        "unitPrice": 10,
        "unitTaxAmount": 2,
        "detail": {
          "unitTaxRate": 0.2
        }
      },
      {
        "name": "Shipping and Handling",
        "quantity": "1",
        "unitPrice": 4.17,
        "unitTaxAmount": 0.83,
        "detail": {
          "unitTaxRate": 0.2
        }
      }
    ]
  },
  "sourceOfFunds": {
    "type": "KLARNA_FINANCING"
  }
}
```

#### Klarna Pay Now {#klarna-pay-now-2}

Klarna Pay Now is supported from Mastercard Gateway API version 63 and later.

Make an Initiate Browser Payment request where `sourceOfFunds.type` = KLARNA_PAY_NOW and browserPayment.operation = PAY (the Authorize operation is not supported by Klarna).

### Sample Code to Initiate Klarna Pay Now Payment {#sample-code-to-initiate-klarna-pay-now-payment}

```json
{
  "apiOperation": "INITIATE_BROWSER_PAYMENT",
  "billing": {
    "address": {
      "city": "Edinburgh",
      "company": "MPGS",
      "country": "DEU",
      "postcodeZip": "EH123AB",
      "stateProvince": "Scotland",
      "street": "OceanPoint",
      "street2": "OceanDrive"
    }
  },
  "browserPayment": {
    "operation": "PAY",
    "returnUrl": "<your_merchant_URL>"
  },
  "customer": {
    "account": {
      "id": "custoAccount"
    },
    "dateOfBirth": "1999-12-31",
    "email": "john.smith@example.com",
    "firstName": "John",
    "lastName": "Smith",
    "mobilePhone": "01234567890",
    "nationalId": "X4RTBPFW4"
  },
  "order": {
    "amount": "154.16",
    "currency": "EUR",
    "item": [
      {
        "name": "Diesel Jeans",
        "quantity": "1",
        "unitPrice": "70.83"
      },
      {
        "name": "Adidas Trainers",
        "quantity": "1",
        "unitPrice": "83.33"
      }
    ]
  },
  "shipping": {
    "address": {
      "city": "Shipsville",
      "country": "GBR",
      "postcodeZip": "EH67DX",
      "stateProvince": "Scotland",
      "street": "2ShippingHeights",
      "street2": "ShipsDrive"
    },
    "contact": {
      "email": "john.smith@example.com",
      "firstName": "John",
      "lastName": "Smith"
    }
  },
  "sourceOfFunds": {
    "type": "KLARNA_PAY_NOW"
  }
}
```

### Klarna Payment Processing Details {#klarna-payment-processing-details}

In addition to the [standard fields](https://developer.mastercard.com/mastercard-gateway/documentation/payment-methods/imp-brow-pay-int/index.md#browser-payments-through-direct-payment-integration) required in a browser payment request, provide the following required information for the processing of Klarna payments.

#### Billing Address and Contact Details {#billing-address-and-contact-details}

These fields are mandatory unless otherwise stated and are required to support the Klarna risk assessment and credit checking processes. The payer's contact information is used to communicate with the payer and to provide electronic invoices and payment notifications.

* `billing.address.city`
* `billing.address.country`
* `billing.address.postcodeZip`
* `billing.address.street`
* `customer.email`
* `customer.firstName`
* `customer.lastName`
* `customer.mobilePhone`: This field is required when customer.phone is not provided.
* `customer.phone`: This field is required when customer.mobilePhone is not provided.
* `customer.nationalId`: This field is optional.

#### Shipping Address and Contact Details {#shipping-address-and-contact-details}

These fields are mandatory when a value for any `shipping.address.*` or `shipping.contact.*` field is provided.

* `shipping.address.city`
* `shipping.address.country`
* `shipping.address.postcodeZip`
* `shipping.address.street`
* `shipping.contact.email`
* `shipping.contact.firstName`
* `shipping.contact.lastName`

#### Order Item Details {#order-item-details}

Provide complete details about each order item that is purchased so that Klarna can correctly validate and display this information to payers and support the risk and credit checking processes of Klarna.

* `order.item[n].name`
* `order.item[n].quantity`: The value of this field must be an integer.
* `order.item[n].unitPrice`
* `order.item[n].unitDiscountAmount`: This field is required when the item has been discounted and must be provided if a value is provided in the `order.discount.amount` field.
* `order.item[n].unitTaxAmount`: This field is required when a payer has to pay tax on the item.
* `order.item[n].detail.unitTaxRate`: This field is required when a value for the unit tax amount has been provided.

#### Shipping and Handling {#shipping-and-handling}

The total tax amount payable for the order is displayed to payers during the payment flow. If the amount payable for shipping and handling includes tax, then you must create an order line to represent shipping and handling so that the discrete tax amount can be provided. If tax does not apply then the shipping, and handling amount can be provided in the `order.shippingAndHandlingAmount` field.

#### Preferred Language {#preferred-language}

You can set the language that you prefer Klarna to use for pages displayed to payers by providing the browserPayment.preferredLanguage field in the Initiate Browser Payment request. However, for Klarna only the primary national language of the `billing.address.country` or English will be supported.

#### Chargebacks {#chargebacks}

Klarna payments are at risk of chargebacks. If payers successfully dispute a payment with Klarna, then a chargeback transaction will be created on the order.

Warning: If the Klarna chargeback is reversed, it does not reflect in the Mastercard Gateway.

<br />

## How to Interpret the Transaction Result {#how-to-interpret-the-transaction-result}

The table below shows the transaction Response Codes for the possible scenarios that you may encounter after initiating a Klarna payment.

|                   **Initiate Browser Payment Response**                   |                                                                                                                **What This Means...**                                                                                                                |
|---------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `response.gatewayCode=SUBMITTED` `result=SUCCESS`                         | Redirect the payer using the URL provided in the response.                                                                                                                                                                                           |
| **Retrieve Transaction/Retrieve Order Response**                          | **What This Means...**                                                                                                                                                                                                                               |
| `response.gatewayCode=APPROVED` `result=SUCCESS`                          | The payment is successful.                                                                                                                                                                                                                           |
| `response.gatewayCode=PENDING` `result=PENDING`                           | The Mastercard Gateway is waiting for a notification from the acquirer about the payment result. Try `RETRIEVE_TRANSACTION` again later or listen to notifications from the Mastercard Gateway.                                                      |
| `response.gatewayCode=CANCELLED` `result=FAILURE`                         | The payer has canceled the interaction for this payment. Offer the payer the option to try another payment method.                                                                                                                                   |
| `response.gatewayCode=DECLINED or ACQUIRER_SYSTEM_ERROR` `result=FAILURE` | The payment was declined. Offer the payer the option to try another payment method. In the case of an `ACQUIRER_SYSTEM_ERROR` you may want to inquire with the acquirer the reason for payment failure, or you can try `RETRIEVE_TRANSACTION` again. |
| `response.gatewayCode=TIMED_OUT` `result=FAILURE`                         | Treat this as a declined payment. The Mastercard Gateway will attempt to ensure that the transaction is not successful or will revert the transaction.                                                                                               |

## Klarna Order ID {#klarna-order-id}

For approved payments, the Mastercard Gateway will provide you with the ID that Klarna has assigned to this order in the field `transaction.acquirer.additionalResponseData`. This may be useful information for communications you may have directly with Klarna.

## Web Hook Notifications {#web-hook-notifications}

If you have subscribed to Mastercard Gateway web hook notifications, you may receive additional notifications for funding status updates and chargebacks.

## Testing your Integration {#testing-your-integration}

The Mastercard Gateway provides a browser payments emulator that allows you to \[test your Klarna integration\].
