mezai/swish-php

Swish API-wrapper. Compatible with Laravel. Adds support for recurring.

Maintainers

Package info

github.com/Mezai/swish-php

pkg:composer/mezai/swish-php

Transparency log

Fund package maintenance!

olssonm

marcusolsson.me/kontakta

Statistics

Installs: 4

Dependents: 0

Suggesters: 0

Stars: 0

v1.0.1 2026-08-21 14:04 UTC

This package is auto-updated.

Last update: 2026-08-21 14:07:29 UTC


README

Fork of https://github.com/olssonm/swish-php. Adds recurring functionality according to Swish api docs.

https://developer.swish.nu/api/recurring-payments/v1

In order to make a recurring payment you will first have to issue a consent. It supports create, retrieve and cancel flow.

use Olssonm\Swish\Consent;

$consent = new Consent([
        'payer' => [
            'alias' => '46711111111',
        ],
        'callbackUrl' => 'https://example.com/callback',
]);
$response = $client->create($consent);

$id = $response->consentId;

// get a consent
$response = $client->get(new Consent(['consentId' => $id]));

//cancel a consent
$response = $client->cancel(new Consent(['consentId' => $id]));

The recurring resource supports create and retrieve.

use Olssonm\Swish\Recurring;
use Olssonm\Swish\Consent;

$consent = $client->create(new Consent([
        'payer' => [
            'alias' => '46711111111',
        ],
        'callbackUrl' => 'https://example.com/callback',
    ]));

// Create a recurring payment
$recurring = new Recurring([
        'amount' => [
            'value' => '10',
            'currency' => 'SEK',
        ],
        'consentId' => $consent->consentId, //consent has to be made before request
        'message' => 'Test',
        'payeePaymentReference' => '150928d55af234236812863a',
        'callbackUrl' => 'https://swish.nu',
]);

$response = $client->create($recurring);
$id = $response->paymentId;

// get a recurring payment
$response = $client->get(new Recurring(['paymentId' => $id]));