PHPackages                             oaklabs/psd2 - 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. oaklabs/psd2

ActiveLibrary[API Development](/categories/api)

oaklabs/psd2
============

API client for banks supporting psd2 APIs.

v1.0(8y ago)317.6k↓33.3%4MITPHPPHP &gt;=7.1

Since Nov 24Pushed 8y ago4 watchersCompare

[ Source](https://github.com/oak-labs-io/psd2)[ Packagist](https://packagist.org/packages/oaklabs/psd2)[ RSS](/packages/oaklabs-psd2/feed)WikiDiscussions master Synced 1mo ago

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

Psd2
====

[](#psd2)

[![License](https://camo.githubusercontent.com/542c5e6be8483685d18dc565f98b6e325966328311336e6e8d4f9e9f8bf3d534/68747470733a2f2f706f7365722e707567782e6f72672f6f616b6c6162732f707364322f6c6963656e7365)](https://packagist.org/packages/oaklabs/psd2)[![Latest Stable Version](https://camo.githubusercontent.com/70eafb99e25cf31f83f0deb18f3769faffb81ff6d833966e881070ffd746f56d/68747470733a2f2f706f7365722e707567782e6f72672f6f616b6c6162732f707364322f762f737461626c65)](https://packagist.org/packages/oaklabs/psd2)[![Latest Unstable Version](https://camo.githubusercontent.com/e62d411fcb5294c9f4c82c4c1fe03263096c5fe8924d2a7d8c0a1ec88ecdbe0b/68747470733a2f2f706f7365722e707567782e6f72672f6f616b6c6162732f707364322f762f756e737461626c65)](https://packagist.org/packages/oaklabs/psd2)[![Build Status](https://camo.githubusercontent.com/30b36708d39774d1edb6f1b04f8c05379e2be15034595d9827f5ccfd4b4804b5/68747470733a2f2f7472617669732d63692e6f72672f6f616b2d6c6162732d696f2f707364322e737667)](https://travis-ci.org/oak-labs-io/psd2)

Introduction
------------

[](#introduction)

> Psd2 is a API client for Banks supporting PSD2 APIs with Oauth2 authentication.

PHP 7.1+ is required.

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

[](#installation)

Psd2 can be installed through Composer, just include `"oaklabs/psd2": "^1.0"` to your composer.json and run `composer update` or `composer install`.

Supported Banks
---------------

[](#supported-banks)

- [Fidor Bank](https://www.fidor.de/) ([API Documentation](https://api-docs.fidor.de))

Usage
-----

[](#usage)

> Examples will be described using the Fidor Bank Gateway, but all Bank Gateways use the same methods.

Once we use fills in his/her own Bank details in the Bank OAuth2 screen, we must handle the callback to with the `state` and `code` variables in order to retrieve the Access Token and therefore being able to use the Bank API.

The `Connector` class is the class that will take care of instantiate the Bank Gateway. Creating a Connector instance is the first step to use Psd2.

### Sandbox

[](#sandbox)

All Bank Gateways can be used in a sandbox mode, which will make the Banks hit the sandbox API endpoints to allow testing.

### Retrieving the Access Token

[](#retrieving-the-access-token)

```
// Let's suppose we saved the state token in a $state variable,
// the random code in $code and we have a boolean $useSandbox variable

// First of all we need to create an Authorization instance

$authorization = new \OakLabs\Psd2\Authorization\Authorization([
    'code' => $code,
    'state' => $state,
    'redirect_uri' => 'the redirect_uri your set in your Bank API configuration,
    'client_id' => 'the client_id of the bank API,
    'client_secret' => 'the client secret of the bank API'
]);

// Let's now instantiate the Bank Gateway through the Connector
$tokens = (new Connector($authorization))
    ->getBankGateway(
        'fidor',
        $useSandbox
    )
    ->retrieveTokens()
    ->getTokens();

// $tokens is now an instance of \League\OAuth2\Client\Token

$accessToken = $tokens->getToken();
$refreshToken = $tokens->getRefreshToken();
$expiration = $tokens->getExpires();
$hasExpired = $tokens->hasExpired();
$jsonSerialized = $tokens->jsonSerialize();
```

### Retrieving the Accounts

[](#retrieving-the-accounts)

```
// After we got the Access Token and we saved it in a $tokens variable
// we can interact with the Bank API

// In case of a new request, create again the Authorization instance,
// but this time we don't need state and code

$authorization = new Authorization([
    'redirect_uri' => 'the redirect_uri your set in your Bank API configuration,
    'client_id' => 'the client_id of the bank API,
    'client_secret' => 'the client secret of the bank API'
]);

$accounts = (new Connector($authorization))
    ->getBankGateway(
        'fidor',
        $useSandbox
    )
    ->setAccessToken($accessToken)
    ->getAccountDetails();

// $accounts is an array of \OakLabs\Psd2\Psd\AccountDetail

foreach ($accounts as $account) {
    // $account->getAccountNumber()
    // $account->getBic()
    // $account->getBalance()
    // $account->getBalanceAvailable()
    // $account->getCreatedAt()
    // $account->getCurrency()
    // $account->getCustomers()
    // $account->getIban()
    // $account->getId()
}
```

### Retrieving SEPA Transactions

[](#retrieving-sepa-transactions)

```
// After we got the Access Token and we saved it in a $tokens variable
// we can interact with the Bank API

// In case of a new request, create again the Authorization instance,
// but this time we don't need state and code

$authorization = new Authorization([
    'redirect_uri' => 'the redirect_uri your set in your Bank API configuration,
    'client_id' => 'the client_id of the bank API,
    'client_secret' => 'the client secret of the bank API'
]);

// Let's now retrieve the SEPA Transactions using the API Pagination

$transactions = (new Connector($authorization))
    ->getBankGateway(
        'fidor',
        $useSandbox
    )
    ->setAccessToken($accessToken)
    ->getSepaTransactions($page, $limit);

// $transactions is an array of \OakLabs\Psd2\Transaction

foreach ($transactions as $transaction) {
    // $transaction->getExternalUid()
    // $transaction->getAccountUid()
    // $transaction->getTransactionUid()
    // $transaction->getAmount()
    // $transaction->getIban()
    // $transaction->getBic()
    // $transaction->getDescription()
    // $transaction->getCreatedAt()
}
```

### Creating a SEPA Transaction

[](#creating-a-sepa-transaction)

```
// After we got the Access Token and we saved it in a $tokens variable
// we can interact with the Bank API

// In case of a new request, create again the Authorization instance,
// but this time we don't need state and code

$authorization = new Authorization([
    'redirect_uri' => 'the redirect_uri your set in your Bank API configuration,
    'client_id' => 'the client_id of the bank API,
    'client_secret' => 'the client secret of the bank API'
]);

// Let's suppose we have a $data array with the transaction we want to create
$data = [
    'external_uid' => '1234567890', // Some uid defined by us
    'account_id' => '12345', // The account_id comes from the Bank API and must be retrieved through getAccountDetails . It is NOT the account number
    'amount' => 10, // Amount of the transfer
    'remote_iban' => 'DE0000000000000000', // IBAN to transfer the money to
    'bic' => 'ABCDEFGH', // BIC
    'subject' => 'My Description' // Description
];

$transaction = (new Connector($authorization))
    ->getBankGateway(
        'fidor',
        $useSandbox
    )
    ->setAccessToken($accessToken)
    ->createSepaTransaction($data);

// Transaction is an instance of \OakLabs\Psd2\Transaction

// $transaction->getExternalUid()
// $transaction->getAccountUid()
// $transaction->getTransactionUid()
// $transaction->getAmount()
// $transaction->getIban()
// $transaction->getBic()
// $transaction->getDescription()
// $transaction->getCreatedAt()
```

Testing
-------

[](#testing)

Just call `vendor/bin/phpunit tests` to run the tests.

Contribution guidelines
-----------------------

[](#contribution-guidelines)

PSD2 follows PSR-1, PSR-2 and PSR-4 PHP coding standards, and semantic versioning.

Pull requests are welcome.

License
-------

[](#license)

PSD2 is free software distributed under the terms of the MIT license.

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity35

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

Unknown

Total

1

Last Release

3098d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/83a0a95c6db0a7ed82ed34b21f3c642caea6e8076044001029215c214671a84e?d=identicon)[OakLabs GmbH](/maintainers/OakLabs%20GmbH)

---

Top Contributors

[![micheleangioni](https://avatars.githubusercontent.com/u/7933034?v=4)](https://github.com/micheleangioni "micheleangioni (17 commits)")

---

Tags

api-clientbankingbanking-applicationsoauth2oauth2-clientphppsd2Bankingpsd2

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/oaklabs-psd2/health.svg)

```
[![Health](https://phpackages.com/badges/oaklabs-psd2/health.svg)](https://phpackages.com/packages/oaklabs-psd2)
```

###  Alternatives

[dcblogdev/laravel-microsoft-graph

A Laravel Microsoft Graph API (Office365) package

168285.5k1](/packages/dcblogdev-laravel-microsoft-graph)[nordigen/nordigen-php

Nordigen official API client for PHP

42336.9k3](/packages/nordigen-nordigen-php)[dcblogdev/laravel-xero

A Laravel Xero package

53129.1k1](/packages/dcblogdev-laravel-xero)[mhujer/fio-api-php

Fio API PHP implemention

37199.1k1](/packages/mhujer-fio-api-php)[starkbank/sdk

SDK to facilitate PHP integrations with Stark Bank

15167.8k](/packages/starkbank-sdk)

PHPackages © 2026

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