All Projects → oak-labs-io → psd2

oak-labs-io / psd2

Licence: MIT license
API client for banks supporting PSD2 APIs with OAuth2 authentication.

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to psd2

powerauth-crypto
PowerAuth - Open-source solution for authentication, secure data storage and transport security in mobile banking.
Stars: ✭ 48 (+84.62%)
Mutual labels:  banking, banking-applications, psd2
Auth
Authenticator via oauth2
Stars: ✭ 118 (+353.85%)
Mutual labels:  oauth2, oauth2-client
Hoauth2
haskell oauth2 binding
Stars: ✭ 111 (+326.92%)
Mutual labels:  oauth2, oauth2-client
Okhttp Oauth2 Client
Android OAuth2 client using OkHttp
Stars: ✭ 193 (+642.31%)
Mutual labels:  oauth2, oauth2-client
Linkedin Api Php Client
LinkedIn API PHP SDK with OAuth 2 support. Can be used for social sign in or sharing on LinkedIn. Has a good usage examples
Stars: ✭ 88 (+238.46%)
Mutual labels:  oauth2, oauth2-client
Flask Oauthlib
YOU SHOULD USE https://github.com/lepture/authlib
Stars: ✭ 1,429 (+5396.15%)
Mutual labels:  oauth2, oauth2-client
Oidc.example
OIDC (OpenID Connect) Example for http://openid.net/connect/
Stars: ✭ 190 (+630.77%)
Mutual labels:  oauth2, oauth2-client
Oauth2
OAuth2 framework for macOS and iOS, written in Swift.
Stars: ✭ 983 (+3680.77%)
Mutual labels:  oauth2, oauth2-client
retail-banking
Consumer Banking Application
Stars: ✭ 25 (-3.85%)
Mutual labels:  banking, banking-applications
sbankenclient-ios
A small but enjoyable iOS framework to connect to the Sbanken API
Stars: ✭ 21 (-19.23%)
Mutual labels:  api-client, banking
AlphaBankUI-Android
Check out the new style for App Design aims for the Banking Applications...😉😀😁😎
Stars: ✭ 45 (+73.08%)
Mutual labels:  banking, banking-applications
Capacitor Oauth2
Capacitor OAuth 2 client plugin with support for the Web, iOS and Android! Show your appreciation with a Github ★
Stars: ✭ 84 (+223.08%)
Mutual labels:  oauth2, oauth2-client
Psmsgraph
A PowerShell module for the Microsoft Graph API
Stars: ✭ 71 (+173.08%)
Mutual labels:  oauth2, oauth2-client
Laqul
A complete starter kit that allows you create amazing apps that look native thanks to the Quasar Framework. Powered by an API developed in Laravel Framework using the easy GraphQL queries language. And ready to use the Google Firebase features.
Stars: ✭ 110 (+323.08%)
Mutual labels:  oauth2, api-client
Psraw
PowerShell Reddit API Wrapper
Stars: ✭ 42 (+61.54%)
Mutual labels:  oauth2, oauth2-client
Loginpass
Login with Google, GitHub, Twitter, Facebook and many other networks.
Stars: ✭ 177 (+580.77%)
Mutual labels:  oauth2, oauth2-client
powerauth-mobile-sdk
PowerAuth Mobile SDK for adds capability for authentication and transaction signing into the mobile apps (ios, watchos, android).
Stars: ✭ 27 (+3.85%)
Mutual labels:  banking, psd2
Pizzly
The simplest, fastest way to integrate your app with an OAuth API 😋
Stars: ✭ 796 (+2961.54%)
Mutual labels:  oauth2, api-client
Oauth2
OAuth2 client in Go
Stars: ✭ 20 (-23.08%)
Mutual labels:  oauth2, oauth2-client
Gam
command line management for Google Workspace
Stars: ✭ 2,558 (+9738.46%)
Mutual labels:  oauth2, oauth2-client

Psd2

License Latest Stable Version Latest Unstable Version Build Status

Introduction

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

PHP 7.1+ is required.

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

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

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

// 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

// 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

// 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

// 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

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

Contribution guidelines

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

Pull requests are welcome.

License

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].