2017 © Pedro Peláez
 

library tatrabanka-api

Tatra Banka - Open banking TB - REST API Client

image

pavolbiely/tatrabanka-api

Tatra Banka - Open banking TB - REST API Client

  • Saturday, January 27, 2018
  • by pavolbiely
  • Repository
  • 2 Watchers
  • 1 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Tatra Banka - Open banking TB

Build Status Coverage Status Donate, (*1)

PHP REST API Client for Tatra Banka's Open Banking TB., (*2)

Sign up at developer.tatrabanka.sk to get access to the API., (*3)

Installation

Use composer to install this package., (*4)

Example of usage

Accounts API

Ask for the OAuth2 authorization, (*5)

use TatraBankaApi\Accounts;

$clientId = '';
$clientSecret = '';
$redirectUri = '';

$tb = new Accounts($clientId, $clientSecret, $redirectUri);
$tb->useSandbox(true);
header('Location: ' . $tb->getAuthorizationUrl());

Exchange the OAuth2 authorization code for an access token, (*6)

use TatraBankaApi\Accounts;
use TatraBankaApi\TatraBankaApiException;

$clientId = '';
$clientSecret = '';
$redirectUri = '';

try {
    $tb = new Accounts($clientId, $clientSecret, $redirectUri);
    $tb->useSandbox(true);
    $tb->requestAccessToken($_GET['code']); // using authorization_code grand type
} catch (TatraBankaApiException $e) {
    // ...
}

General usage, (*7)

use TatraBankaApi\Accounts;
use TatraBankaApi\TatraBankaApiException;

$clientId = '';
$clientSecret = '';
$redirectUri = '';

try {
    $tb = new Accounts($clientId, $clientSecret, $redirectUri);
    $tb->useSandbox(true);

    if ($tb->isAuthorized()) {
        // The operation provides the relevant data about bank customer's accounts in form of a list.
        print_r($tb->getAccounts());

        // The operation provides the relevant data from a bank customer's account identified by IBAN.
        print_r($tb->postAccountInfo('SK0511000000002600000054'));

        // The list of financial transactions perfomed on a customer's bank account withing a date period.
        print_r($tb->postTransactions('SK0511000000002600000054', Accounts::STATUS_ALL, new \DateTime('-1 month'),  new \DateTime('now'), 1, 10));
    }
} catch (TatraBankaApiException $e) {
    // ...
}

Payments API

Get the OAuth2 access token and prepare the payment instructions, (*8)

use TatraBankaApi\Payments;
use TatraBankaApi\PaymentAmount;
use TatraBankaApi\PaymentParticipant;
use TatraBankaApi\TatraBankaApiException;

$clientId = '';
$clientSecret = '';
$redirectUri = '';

try {
    $tb = new Payments($clientId, $clientSecret, $redirectUri);
    $tb->useSandbox(true);
    $tb->requestAccessToken(); // using client_credentials grand type
    $debtor = new PaymentParticipant('John Doe', 'SK0511000000002600000054');
    $creditor = new PaymentParticipant('John Doe', 'DE89370400440532013000');
    $amount = new PaymentAmount(100.15);
    $response = $tb->postPaymentSba(md5(uniqid('', true)), $debtor, $creditor, $amount, new \DateTime('tomorrow'), new \DateTime('now'), '/VS123/SS456/KS0308', 'Test');
    $authUrl = $tb->getAuthorizationUrl(['orderId' => $response->orderId]);
    header('Location: ' . $authUrl);
    exit;
} catch (TatraBankaApiException $e) {
    // ...
}

Exchange the OAuth2 authorization code for an access token and submit the payment, (*9)

use TatraBankaApi\Payments;
use TatraBankaApi\TatraBankaApiException;

$clientId = '';
$clientSecret = '';
$redirectUri = '';

try {
    $tb = new Payments($clientId, $clientSecret, $redirectUri);
    $tb->useSandbox(true);
    $tb->requestAccessToken($_GET['code']); // using authorization_code grand type
    print_r($tb->postPaymentSubmission());

} catch (TatraBankaApiException $e) {
    // ...
}

Get payment status, (*10)

use TatraBankaApi\Payments;
use TatraBankaApi\TatraBankaApiException;

$clientId = '';
$clientSecret = '';
$redirectUri = '';
$orderId = ''; // order ID is generated by the postPaymentSba method

try {
    $tb = new Payments($clientId, $clientSecret, $redirectUri);
    $tb->useSandbox(true);
    $tb->requestAccessToken(); // using client_credentials grand type
    print_r($tb->getPaymentStatus(['orderId' => $orderId]));

} catch (TatraBankaApiException $e) {
    // ...
}

How to run tests?

Tests are build with Nette Tester. You can run it like this:, (*11)

php -f tester ./ -c php.ini-mac --coverage coverage.html --coverage-src ../src

Minimum requirements

  • PHP 7.1+
  • php-curl

License

MIT License (c) Pavol Biely, (*12)

Read the provided LICENSE file for details., (*13)

The Versions

27/01 2018

dev-master

9999999-dev

Tatra Banka - Open banking TB - REST API Client

  Sources   Download

MIT

The Requires

 

by Pavol Biely