PHPackages                             pigmentab/omnipay-klarna - 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. pigmentab/omnipay-klarna

ActiveLibrary[Payment Processing](/categories/payments)

pigmentab/omnipay-klarna
========================

Klarna Checkout gateway for Omnipay payment processing library

1.2.1(3y ago)010MITPHP

Since Dec 26Pushed 3y agoCompare

[ Source](https://github.com/pigmentGit/omnipay-klarna)[ Packagist](https://packagist.org/packages/pigmentab/omnipay-klarna)[ Docs](https://github.com/pigmentGit/omnipay-klarna)[ RSS](/packages/pigmentab-omnipay-klarna/feed)WikiDiscussions master Synced 4d ago

READMEChangelog (1)Dependencies (2)Versions (6)Used By (0)

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

[](#omnipay-klarna)

This package is a modified version of [omnipay-klarna-checkout](https://github.com/MyOnlineStore/omnipay-klarna-checkout) by [nyehandel](https://nyehandel.se) and [Intflow](https://intflow.se). With this package you can run on Laravel 8 and PHP 8. This package will also contain more functinallity then the original package.

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.

This package supports PHP 8

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

[](#installation)

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

```
$ composer require dalholm/omnipay-klarna
```

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

[](#initialization)

First, create the Omnipay gateway:

```
$gateway = Omnipay\Omnipay::create('\Dalholm\Omnipay\KlarnaCheckout\Gateway');
// or
$gateway = new Dalholm\Omnipay\Klarna\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' => 2500,
            'price' => 1000,
            'unit_price' => 1000,
            'total_tax_amount' => 200,
        ],
    ],
];

$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/Dalholm/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)

### Update Merchant References

[](#update-merchant-references)

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

```
$response = $gateway->updateMerchantReferences([
    'transactionReference' => 'a5bec272-d68d-4df9-9fdd-8e35e51f92ab',
    'merchant_reference1' => (String) 'Your reference or order id',
    'merchant_reference2' => (String) 'Another reference or order id',
])->send();
```

Response will be an Empty response (204)

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

### 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)

Units
-----

[](#units)

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

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 86.7% of commits — single point of failure

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 ~146 days

Total

5

Last Release

1377d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1f3582424c0b44da95cac9820c70b2993516c621667692a15a4fd92186fa3d4f?d=identicon)[pigmentGit](/maintainers/pigmentGit)

---

Top Contributors

[![dalholm](https://avatars.githubusercontent.com/u/426083?v=4)](https://github.com/dalholm "dalholm (13 commits)")[![pigmentGit](https://avatars.githubusercontent.com/u/1106446?v=4)](https://github.com/pigmentGit "pigmentGit (1 commits)")[![writeshh](https://avatars.githubusercontent.com/u/26714639?v=4)](https://github.com/writeshh "writeshh (1 commits)")

---

Tags

klarnaomnipayKlarna Checkout

### Embed Badge

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

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

###  Alternatives

[payum/payum-bundle

One million downloads of Payum already! Payum offers everything you need to work with payments. Check more visiting site.

59510.3M40](/packages/payum-payum-bundle)[payum/payum-laravel-package

Rich payment solutions for Laravel framework. Paypal, payex, authorize.net, be2bill, omnipay, recurring paymens, instant notifications and many more

12842.5k](/packages/payum-payum-laravel-package)[silverstripe/silverstripe-omnipay

SilverStripe Omnipay Payment Module

38106.0k15](/packages/silverstripe-silverstripe-omnipay)[recca0120/laravel-payum

Rich payment solutions for Laravel framework. Paypal, payex, authorize.net, be2bill, omnipay, recurring paymens, instant notifications and many more

741.5k](/packages/recca0120-laravel-payum)

PHPackages © 2026

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