PHPackages                             fredrik01/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. fredrik01/swish-php

ActiveLibrary

fredrik01/swish-php
===================

PHP-wrapper for the Swish api

1.1.1(7y ago)05.6kMITPHPPHP &gt;=5.5.9

Since Feb 18Pushed 7y ago1 watchersCompare

[ Source](https://github.com/Fredrik01/swish-php)[ Packagist](https://packagist.org/packages/fredrik01/swish-php)[ RSS](/packages/fredrik01-swish-php/feed)WikiDiscussions master Synced 3d ago

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

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

[](#swish-php)

This is a fork of [helmutschneider/swish-php](https://github.com/helmutschneider/swish-php) that supports Docker.

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

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

[](#dependencies)

- PHP 5.5.9 or newer
- curl
- openssl

Dev dependencies
----------------

[](#dev-dependencies)

- Just Docker and Docker Compose

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

[](#installation)

```
git clone https://github.com/Fredrik01/swish-php.git
docker-compose run --rm swish composer install
```

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

[](#obtaining-test-certificates)

Swish documentation as of 2018-06-27: [https://developer.getswish.se/content/uploads/2017/04/MerchantsAPI\_Getswish\_180517\_v1.91.pdf](https://developer.getswish.se/content/uploads/2017/04/MerchantsAPI_Getswish_180517_v1.91.pdf)Test certificate bundle as of 2018-06-27: [https://developer.getswish.se/content/uploads/2017/04/Merchants\_Test-1.zip](https://developer.getswish.se/content/uploads/2017/04/Merchants_Test-1.zip)

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 2018-06-27 the test certificates are called `Swish Merchant Test Certificate 1231181189.key`, `Swish Merchant Test Certificate 1231181189.pem` and `Swish TLS Root CA.pem`. **You must concatenate `Swish Merchant Test Certificate 1231181189.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 string payment request id
     * @throws \GuzzleHttp\Exception\GuzzleException
     * @throws ValidationException
     */
    public function createPaymentRequest(PaymentRequest $request): string;

    /**
     * @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\Util;

// 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'];

$client = Client::make($rootCert, $clientCert);

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

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

var_dump($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`.

```
docker-compose run --rm swish ./extract.sh bundle.p12 swish swish
```

Place the generated certs in `tests/_data` and run the tests.

```
docker-compose run --rm swish composer install
docker-compose run --rm swish phpunit

```

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 71.9% 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 ~123 days

Total

5

Last Release

2878d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/937c44ecc0220db0a7c4a7aaf321cb64b988dc106af95881a4a657de84081abb?d=identicon)[Fredrik01](/maintainers/Fredrik01)

---

Top Contributors

[![helmutschneider](https://avatars.githubusercontent.com/u/6281919?v=4)](https://github.com/helmutschneider "helmutschneider (23 commits)")[![Fredrik02](https://avatars.githubusercontent.com/u/13484006?v=4)](https://github.com/Fredrik02 "Fredrik02 (5 commits)")[![fredrik01](https://avatars.githubusercontent.com/u/1613222?v=4)](https://github.com/fredrik01 "fredrik01 (4 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

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

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

###  Alternatives

[neuron-core/neuron-ai

The PHP Agentic Framework.

1.8k245.3k21](/packages/neuron-core-neuron-ai)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3731.2M42](/packages/tencentcloud-tencentcloud-sdk-php)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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