PHPackages                             myonlinestore/omnipay-klarna-checkout - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Payment Processing](/categories/payments)
4. /
5. myonlinestore/omnipay-klarna-checkout

AbandonedArchivedLibrary[Payment Processing](/categories/payments)

myonlinestore/omnipay-klarna-checkout
=====================================

Klarna Checkout gateway for Omnipay payment processing library

5.0(4y ago)13127.7k↓35.8%12[5 issues](https://github.com/MyOnlineStore/omnipay-klarna-checkout/issues)MITPHPPHP ^7.4 | ^8.0

Since May 5Pushed 2y ago12 watchersCompare

[ Source](https://github.com/MyOnlineStore/omnipay-klarna-checkout)[ Packagist](https://packagist.org/packages/myonlinestore/omnipay-klarna-checkout)[ Docs](https://github.com/MyOnlineStore/omnipay-klarna-checkout)[ RSS](/packages/myonlinestore-omnipay-klarna-checkout/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (5)Versions (54)Used By (0)

NO LONGER MAINTAINED
====================

[](#no-longer-maintained)

This repository is no longer being maintained.

Omnipay: Klarna Checkout
========================

[](#omnipay-klarna-checkout)

[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Scrutinizer Build](https://camo.githubusercontent.com/82f340fd8ac8ab137b83b82938ab793ee46ba309174345203479da719788bac2/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f6275696c642f672f4d794f6e6c696e6553746f72652f6f6d6e697061792d6b6c61726e612d636865636b6f75742e7376673f7374796c653d666c61742d737175617265)](https://github.com/MyOnlineStore/omnipay-klarna-checkout)[![Scrutinizer Coverage](https://camo.githubusercontent.com/35e92e21baebc6da3411547763577df1c854abda3211e2e3efc2f4d0a7d23b7c/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f4d794f6e6c696e6553746f72652f6f6d6e697061792d6b6c61726e612d636865636b6f75742e7376673f7374796c653d666c61742d737175617265)](https://github.com/MyOnlineStore/omnipay-klarna-checkout)[![Scrutinizer](https://camo.githubusercontent.com/0dc1077d08b9e6c4e04e1c7cce1ea55a63d120d93bc668fcf3532eee10025949/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f4d794f6e6c696e6553746f72652f6f6d6e697061792d6b6c61726e612d636865636b6f75742e7376673f7374796c653d666c61742d737175617265)](https://github.com/MyOnlineStore/omnipay-klarna-checkout)

Introduction
------------

[](#introduction)

[Omnipay](https://github.com/thephpleague/omnipay) is a framework agnostic, multi-gateway payment processing library for PHP 5.6+. This package implements Klarna Checkout support for Omnipay.

Installation
------------

[](#installation)

To install, simply add it to your `composer.json` file:

```
$ composer require myonlinestore/omnipay-klarna-checkout
```

Initialization
--------------

[](#initialization)

First, create the Omnipay gateway:

```
$gateway = Omnipay\Omnipay::create('\MyOnlineStore\Omnipay\KlarnaCheckout\Gateway');
// or
$gateway = new MyOnlineStore\Omnipay\KlarnaCheckout\Gateway(/* $httpClient, $httpRequest */);
```

Then, initialize it with the correct credentials:

```
$gateway->initialize([
    'username' => $username,
    'secret' => $secret,
    'api_region' => $region, // Optional, may be Gateway::API_VERSION_EUROPE (default) or Gateway::API_VERSION_NORTH_AMERICA
    'testMode' => false // Optional, default: true
]);
// or
$gateway->setUsername($username);
$gateway->setSecret($secret);
$gateway->setApiRegion($region);
```

Usage
-----

[](#usage)

For general usage instructions, please see the main [Omnipay](https://github.com/thephpleague/omnipay)repository.

### General flow

[](#general-flow)

1. [Create a Klarna order](#authorize)
2. [Update transaction](#update-transaction) (if required)
3. [Render the Iframe](#render-iframe)
4. Respond to redirects to `checkoutUrl` or `confirmation_url`
5. Respond to [checkout callbacks](https://developers.klarna.com/api/#checkout-api-callbacks-callbacks)
6. Respond to the request to `push_url` (indicates order was completed by client) with a [ackowledgement](#acknowledge)
7. [Extend authorization](#extend-authorization) (if required)
8. [Update the merchant address](#update-merchant-address) (if required)
9. Perform one or more [capture(s)](#capture), [refund(s)](#refund) or [void](#void) operations

### Authorize

[](#authorize)

To create a new order, use the `authorize` method:

```
$data = [
    'amount' => 100,
    'tax_amount' => 20,
    'currency' => 'SEK',
    'locale' => 'SE',
    'purchase_country' => 'SE',

    'notify_url' => '', // https://developers.klarna.com/api/#checkout-api__ordermerchant_urls__validation
    'return_url' => '', // https://developers.klarna.com/api/#checkout-api__ordermerchant_urls__checkout
    'terms_url' => '', // https://developers.klarna.com/api/#checkout-api__ordermerchant_urls__terms
    'validation_url' => '', // https://developers.klarna.com/api/#checkout-api__ordermerchant_urls__validation

    'items' => [
        [
            'type' => 'physical',
            'name' => 'Shirt',
            'quantity' => 1,
            'tax_rate' => 25,
            'price' => 100,
            'unit_price' => 100,
            'total_tax_amount' => 20,
        ],
    ],
];

$response = $gateway->authorize($data)->send()->getData();
```

This will return the order details as well as the checkout HTML snippet to render on your site.

[API documentation](https://github.com/MyOnlineStore/omnipay-klarna-checkout/blob/master/src/Message/AuthorizeRequest.php)

Render Iframe
-------------

[](#render-iframe)

Klarna Checkout requires an iframe to be rendered when authorizing payments:

```
$response = $gateway->fetchTransaction(['transactionReference' => 'a5bec272-d68d-4df9-9fdd-8e35e51f92ab'])
    ->send();

echo $response->getData()['checkout']['html_snippet'];
```

After submitting the form within the iframe, Klarna will redirect the client to the provided `confirmation_url` (success) or `checkout_url` (failure)`.

### Update transaction

[](#update-transaction)

While an order has not been authorized (completed) by the client, it may be updated:

```
$response = $gateway->updateTransaction([
    'transactionReference' => 'a5bec272-d68d-4df9-9fdd-8e35e51f92ab',
    'amount'           => 200,
    'tax_amount'       => 40,
    'currency'         => 'SEK',
    'locale'           => 'SE',
    'purchase_country' => 'SE',
    'items' => [/*...*/],
])->send();
```

The response will contain the updated order data.

[API documentation](https://developers.klarna.com/api/#checkout-api-update-an-order)

### Extend authorization

[](#extend-authorization)

Klarna order authorization is valid until a specific date, and may be extended (up to a maximum of 180 days). The updated expiration date may then be retrieved with a [fetch](#fetch) request

```
if ($gateway->extendAuthorization(['transactionReference' => 'a5bec272-d68d-4df9-9fdd-8e35e51f92ab'])->send()->isSuccessful()) {
    $expiration = new \DateTimeImmutable(
        $gateway->fetchTransaction(['transactionReference' => 'a5bec272-d68d-4df9-9fdd-8e35e51f92ab'])
            ->send()
            ->getData()['management']['expires_at']
    );
}
```

[API documentation](https://developers.klarna.com/api/#order-management-api-extend-authorization-time)

### Capture

[](#capture)

```
$success = $gateway->capture([
    'transactionReference' => 'a5bec272-d68d-4df9-9fdd-8e35e51f92ab',
    'amount' => '995',
])->send()
->isSuccessful();
```

[API documentation](https://developers.klarna.com/api/#order-management-api-create-capture)

### Fetch

[](#fetch)

A Klarna order is initially available through the checkout API. After it has been authorized, it will be available through the Order management API (and will, after some time, no longer be available in the checkout API). This fetch request will first check whether the order exitst in the checkout API. If that is not the case, or the status indicates the order is finished, it will also fetch the order from the order management API

```
$response = $gateway->fetchTransaction(['transactionReference' => 'a5bec272-d68d-4df9-9fdd-8e35e51f92ab'])
    ->send();

$success = $response->isSuccessful();
$checkoutData = $response->getData()['checkout'] ?? [];
$managementData = $response->getData()['management'] ?? [];
```

API documentation | [Checkout](https://developers.klarna.com/api/#checkout-api-retrieve-an-order) | [Order management](https://developers.klarna.com/api/#order-management-api-get-order)

### Acknowlegde

[](#acknowlegde)

Acknowledge a completed order

```
$success = $gateway->acknowledge(['transactionReference' => 'a5bec272-d68d-4df9-9fdd-8e35e51f92ab'])
    ->send()
    ->isSuccessful();
```

[API documentation](https://developers.klarna.com/api/#order-management-api-acknowledge-order)

### Refund

[](#refund)

```
$success = $gateway->refund([
    'transactionReference' => 'a5bec272-d68d-4df9-9fdd-8e35e51f92ab',
    'amount' => '995',
])->send()
->isSuccessful();
```

[API documentation](https://developers.klarna.com/api/#order-management-api-create-a-refund)

### Void

[](#void)

You may release the remaining authorized amount. Specifying a specific amount is not possible.

```
$success = $gateway->void(['transactionReference' => 'a5bec272-d68d-4df9-9fdd-8e35e51f92ab'])
    ->send()
    ->isSuccessful();
```

[API documentation](https://developers.klarna.com/api/#order-management-api-release-remaining-authorization)

### Update customer address

[](#update-customer-address)

This may be used when updating customer address details *after* the order has been authorized. Success op this operation is subject to a risk assessment by Klarna. Both addresses are required parameters.

```
$success = $gateway->refund([
    'transactionReference' => 'a5bec272-d68d-4df9-9fdd-8e35e51f92ab',
    'shipping_address' => [
        'given_name'=> 'Klara',
        'family_name'=> 'Joyce',
        'title'=> 'Mrs',
        'street_address'=> 'Apartment 10',
        'street_address2'=> '1 Safeway',
        'postal_code'=> '12345',
        'city'=> 'Knoxville',
        'region'=> 'TN',
        'country'=> 'us',
        'email'=> 'klara.joyce@klarna.com',
        'phone'=> '1-555-555-5555'
    ],
    'billing_address' => [
        'given_name'=> 'Klara',
        'family_name'=> 'Joyce',
        'title'=> 'Mrs',
        'street_address'=> 'Apartment 10',
        'street_address2'=> '1 Safeway',
        'postal_code'=> '12345',
        'city'=> 'Knoxville',
        'region'=> 'TN',
        'country'=> 'us',
        'email'=> 'klara.joyce@klarna.com',
        'phone'=> '1-555-555-5555'
    ],
])->send()
->isSuccessful();
```

[API documentation](https://developers.klarna.com/api/#order-management-api-update-customer-addresses)

### Update merchant reference(s)

[](#update-merchant-references)

If an order has been authorized by the client, its merchant references may be updated:

```
$response = $gateway->updateMerchantReferences([
    'merchant_reference1' => 'foo',
    'merchant_reference2' => 'bar',
])->send();
```

[API documentation](https://developers.klarna.com/api/#order-management-api-update-merchant-references)

Units
-----

[](#units)

Klarna expresses amounts in minor units as described [here](https://developers.klarna.com/api/#data-types).

###  Health Score

44

—

FairBetter than 92% of packages

Maintenance12

Infrequent updates — may be unmaintained

Popularity42

Moderate usage in the ecosystem

Community23

Small or concentrated contributor base

Maturity82

Battle-tested with a long release history

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~36 days

Recently: every ~207 days

Total

50

Last Release

1508d ago

Major Versions

v1.0.31 → v2.0.02018-06-22

v2.0.0 → v3.0.02018-09-21

v2.0.1 → v3.0.72019-03-06

3.1 → 4.02022-02-03

4.0 → 5.02022-04-01

PHP version history (2 changes)v3.0.0PHP ^7.0

4.0PHP ^7.4 | ^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/20622127?v=4)[lemon](/maintainers/lemonweb)[@lemonweb](https://github.com/lemonweb)

![](https://www.gravatar.com/avatar/506957a11a321def8195e395f0f6ed8a22cdaa9252d0e4342fcf9fcbfe6b49a0?d=identicon)[fred-jan](/maintainers/fred-jan)

---

Top Contributors

[![fred-jan](https://avatars.githubusercontent.com/u/2146611?v=4)](https://github.com/fred-jan "fred-jan (41 commits)")[![digibeuk](https://avatars.githubusercontent.com/u/5148394?v=4)](https://github.com/digibeuk "digibeuk (28 commits)")[![Feijs](https://avatars.githubusercontent.com/u/12059414?v=4)](https://github.com/Feijs "Feijs (14 commits)")[![kusozayka](https://avatars.githubusercontent.com/u/363388?v=4)](https://github.com/kusozayka "kusozayka (2 commits)")[![mattias-sanfridsson](https://avatars.githubusercontent.com/u/34786113?v=4)](https://github.com/mattias-sanfridsson "mattias-sanfridsson (2 commits)")[![shopblocks](https://avatars.githubusercontent.com/u/14819903?v=4)](https://github.com/shopblocks "shopblocks (1 commits)")[![jannejava](https://avatars.githubusercontent.com/u/543616?v=4)](https://github.com/jannejava "jannejava (1 commits)")[![davidrushton](https://avatars.githubusercontent.com/u/4039772?v=4)](https://github.com/davidrushton "davidrushton (1 commits)")

---

Tags

omnipayKlarna Checkout

###  Code Quality

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

![Health badge](/badges/myonlinestore-omnipay-klarna-checkout/health.svg)

```
[![Health](https://phpackages.com/badges/myonlinestore-omnipay-klarna-checkout/health.svg)](https://phpackages.com/packages/myonlinestore-omnipay-klarna-checkout)
```

###  Alternatives

[silverstripe/silverstripe-omnipay

SilverStripe Omnipay Payment Module

38106.0k15](/packages/silverstripe-silverstripe-omnipay)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
