PHPackages                             helmutschneider/swish-php - 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. [API Development](/categories/api)
4. /
5. helmutschneider/swish-php

ActiveLibrary[API Development](/categories/api)

helmutschneider/swish-php
=========================

PHP-wrapper for the Swish api

v3.0.2(3y ago)4218.7k↓33.3%20[1 issues](https://github.com/helmutschneider/swish-php/issues)MITPHPPHP &gt;=7.3

Since Dec 19Pushed 1y ago9 watchersCompare

[ Source](https://github.com/helmutschneider/swish-php)[ Packagist](https://packagist.org/packages/helmutschneider/swish-php)[ RSS](/packages/helmutschneider-swish-php/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (7)Used By (0)

Swish-PHP
=========

[](#swish-php)

Swish-PHP is a small wrapper for the swish merchant api. See  for more information.

Dependencies
------------

[](#dependencies)

- php 7.3 or newer with curl &amp; openssl
- composer

Upgrade notes
-------------

[](#upgrade-notes)

### 3.0.0

[](#300)

- The function `createPaymentRequest` now returns an object with the two properties `id` and `paymentRequestToken`. In earlier versions the id was returned directly.

Installation via git
--------------------

[](#installation-via-git)

```
git clone https://github.com/helmutschneider/swish-php.git
composer install
```

Installation via composer
-------------------------

[](#installation-via-composer)

```
composer require helmutschneider/swish-php:^3.0
```

Obtaining test certificates
---------------------------

[](#obtaining-test-certificates)

As of 2024-09-22, a test certificate bundle (mss\_test\_2.0.zip) can be found by visiting:

Begin by obtaining the SSL certificates required by Swish. The Swish server itself uses a self-signed root certificated so a CA-bundle to verify its origin is needed. You will also need a client certificate and corresponding private key so the Swish server can identify you.

As of 2024-09-22 the test certificates are called `Swish_Merchant_TestCertificate_1234679304.key`, `Swish Merchant Test Certificate 1231181189.pem` and `Swish_TLS_RootCA.pem`. **You must concatenate `Swish_Merchant_TestCertificate_1234679304.key` and `Swish Merchant Test Certificate 1231181189.pem` together, otherwise they will not work with cURL. This bundle is your client certificate.**

Usage
-----

[](#usage)

The client closely mirrors the swish api:

```
class Client
{

    /**
     * @param PaymentRequest $request
     * @return CreatePaymentRequestResponse
     * @throws \GuzzleHttp\Exception\GuzzleException
     * @throws ValidationException
     */
    public function createPaymentRequest(PaymentRequest $request): CreatePaymentRequestResponse;

    /**
     * @param string $id Payment request id
     * @return PaymentRequest
     * @throws \GuzzleHttp\Exception\GuzzleException
     */
    public function getPaymentRequest(string $id): PaymentRequest;

    /**
     * @param Refund $refund
     * @return string refund id
     * @throws \GuzzleHttp\Exception\GuzzleException
     * @throws ValidationException
     */
    public function createRefund(Refund $refund): string;

    /**
     * @param string $id Refund id
     * @return Refund
     * @throws \GuzzleHttp\Exception\GuzzleException
     */
    public function getRefund(string $id): Refund;
}
```

When you have the SSL certificates ready you may instantiate the client:

```
use HelmutSchneider\Swish\Client;
use HelmutSchneider\Swish\PaymentRequest;

// Swish CA root cert
$rootCert = 'path/to/swish-root.crt'; // forwarded to guzzle's "verify" option

// .pem-bundle containing your client cert and it's corresponding private key. forwarded to guzzle's "cert" option
// you may use an empty string for "password" if you are using the test certificates.
$clientCert = ['path/to/client-cert.pem', 'password'];

// Create a client for the production environment. To connect to the test environment
// instead, you must pass the constant Client::SWISH_TEST_URL as the third parameter.
$client = Client::make($rootCert, $clientCert);

$pr = new PaymentRequest([
    'callbackUrl' => 'https://localhost/swish',
    'payeePaymentReference' => '12345',
    'payerAlias' => '4671234768',
    'payeeAlias' => '1231181189',
    'amount' => '100',
])

$res = $client->createPaymentRequest($pr);

var_dump($res->id);

//
//  string(32) "0D3AD8F1AE484A57B82A87FAB8C602EB"
//
```

Notes for OSX
-------------

[](#notes-for-osx)

The bundled PHP in OSX 10.12 and earlier is not compatible with the above approach of forwarding SSL certificates. You must obtain a PHP-version that is compiled with cURL linked against OpenSSL or similar.

Run the tests
-------------

[](#run-the-tests)

To run the tests you need certificates for the Swish test server. Place the root certificate in `tests/_data/root.pem` and the client certificate in `tests/_data/client.pem`.

```
vendor/bin/phpunit
```

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance28

Infrequent updates — may be unmaintained

Popularity39

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 63% 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 ~317 days

Recently: every ~190 days

Total

6

Last Release

1121d ago

Major Versions

v1.0.0 → v2.0.02021-03-21

v2.0.1 → v3.0.02022-01-24

PHP version history (3 changes)v1.0.0PHP &gt;=5.5.9

v2.0.0PHP &gt;=7.2.5

v3.0.1PHP &gt;=7.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/04ff5ed60b488df4268fb3f0c1ed375dcda05019cbefe332ff204eda8f16c4e1?d=identicon)[mladjom](/maintainers/mladjom)

---

Top Contributors

[![helmutschneider](https://avatars.githubusercontent.com/u/6281919?v=4)](https://github.com/helmutschneider "helmutschneider (29 commits)")[![dhedberg](https://avatars.githubusercontent.com/u/279067?v=4)](https://github.com/dhedberg "dhedberg (16 commits)")[![Livijn](https://avatars.githubusercontent.com/u/349311?v=4)](https://github.com/Livijn "Livijn (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/helmutschneider-swish-php/health.svg)

```
[![Health](https://phpackages.com/badges/helmutschneider-swish-php/health.svg)](https://phpackages.com/packages/helmutschneider-swish-php)
```

###  Alternatives

[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3731.2M42](/packages/tencentcloud-tencentcloud-sdk-php)[convertkit/convertkitapi

Kit PHP SDK for the Kit API

2167.1k1](/packages/convertkit-convertkitapi)[mapado/rest-client-sdk

Rest Client SDK for hydra API

1125.9k2](/packages/mapado-rest-client-sdk)

PHPackages © 2026

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