swedbank-pay / swedbank-pay-sdk-php
The Swedbank Pay SDK for PHP simplifies integrations against Swedbank Pay's API Platform by providing native PHP interface towards the REST API.
Package info
github.com/SwedbankPay/swedbank-pay-sdk-php
pkg:composer/swedbank-pay/swedbank-pay-sdk-php
Requires
- ext-curl: *
- ext-json: *
Requires (Dev)
- codeception/codeception: ^4.1
- codeception/module-asserts: ^2.0.1
- codeception/module-phpbrowser: ^2.0.3
- codeception/module-webdriver: ^2.0.4
- phpmd/phpmd: ^2.6
- phpunit/php-code-coverage: ^9.2
- phpunit/phpunit: ~9.6
- squizlabs/php_codesniffer: ^3.4
- dev-main
- 6.3.0
- 6.2.0
- 6.1.0
- 6.0.0
- 5.6.0
- 5.5.0
- 5.4.1
- 5.4.0
- 5.3.0
- 5.2.0
- 5.1.0
- 5.0.0
- 4.0.2
- 4.0.1
- 4.0.0
- 4.0.0-beta.6
- v4.0.0-beta.5
- v4.0.0-beta.4
- v4.0.0-beta.3
- v4.0.0-beta.2
- 4.0.0-beta.1
- 3.4.0
- 3.0.0
- 2.0.1
- 2.0.0
- 1.0.2
- v1.0.1
- v1.0.0
- dev-dependabot/github_actions/actions/checkout-6.0.3
- dev-dependabot/github_actions/softprops/action-gh-release-3.0.0
- dev-dependabot/github_actions/gittools/actions-4.5.0
- dev-feature/RestrictedToInstruments
- dev-feature/trollweb-magento2-changes
- dev-support/legacy
This package is auto-updated.
Last update: 2026-06-03 19:21:19 UTC
README
About
UNSUPPORTED: This SDK is at an early stage of development and is not supported as of yet by Swedbank Pay. It is provided as a convenience to speed up your development, so please feel free to play around. However, if you need support, please wait for a future, stable release.
The Swedbank Pay SDK for PHP simplifies integrations against Swedbank Pay's API Platform by providing native PHP interface towards the REST API.
This SDK includes the following payments options:
- Checkout
- Credit and debit cards (Visa, Mastercard, Visa Electron, Maestro etc).
- Invoice
- Swish
- Vipps
- MobilePay Online
- Trustly
Documentation
Documentation about Swedbank Pay's API Platform can be found on the Swedbank Pay Developer Portal for now.
Installation
The recommended way to install the Swedbank Pay SDK for PHP library is with Composer. You can also download the source code from one of the releases here on GitHub or simply clone this repository.
Composer
The preferred method is via Composer. Follow the installation instructions if you do not already have composer installed.
Once composer is installed, execute the following command in your project root to install this SDK:
composer require swedbank-pay/swedbank-pay-sdk-php
Examples
You can find examples in /tests directory or check out Swedbank Pay Core for WooCommerce code.
Using Online Payments v3.1
Version 6.3.0 introduces typed response support for Online Payments v3.1. The v3.1 surface
lives under the SwedbankPay\Api\Service\Paymentorder\V3 namespace and is fully additive —
existing v2 classes are unchanged.
Opt in by setting the API version on the Client (this switches the Content-Type header
to application/json;version=3.1):
use SwedbankPay\Api\Client\Client; use SwedbankPay\Api\Service\Paymentorder\V3\Request\Purchase; use SwedbankPay\Api\Service\Paymentorder\V3\Request\TransactionCapture; $client = new Client(); $client->setAccessToken('...')->setPayeeId('...'); $client->setApiVersion('3.1'); // Create paymentOrder $purchase = new Purchase($paymentOrderObject); $purchase->setClient($client); $response = $purchase->send(); $paymentOrder = $response->getResponseResource()->getPaymentOrder(); echo $paymentOrder->getStatus(); // "Initialized" / "Paid" / "Aborted" / ... echo $paymentOrder->getId();
For post-purchase actions (Capture, Cancel, Reversal), call setExpands(['financialtransactions', 'paid'])
when you want the freshly-created transaction inlined in the response:
$capture = new TransactionCapture($transactionObject); $capture->setClient($client); $capture->setPaymentOrderId($paymentOrderId); $capture->setExpands(['financialtransactions', 'paid']); $response = $capture->send(); $latest = $response->getResponseResource()->getLatestFinancialTransaction(); echo $latest->getType(); // "Capture" echo $latest->getNumber();
Typed callback parsing:
use SwedbankPay\Api\Service\Paymentorder\V3\Resource\Response\CallbackPayload; $payload = new CallbackPayload($webhookBody); $orderRef = $payload->getOrderReference(); $paymentOrderId = $payload->getPaymentOrder()->getId();