PHP code example of pavelmaca / open-banking

1. Go to this page and download the library: Download pavelmaca/open-banking library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

pavelmaca / open-banking example snippets


class BankB implements \PavelMaca\OpenBanking\Auth\Authentication
{

    public function getAuthHeaders(): array
    {
        return [
            'X-Special-Header' => 'foo',
            'Authorization' => 'Bearer ' . $this->getAccessToken(),
        ];
    }

    protected function getAccessToken(){
        // Get access token via OAUth 2.0
    }

    public function getCertificate()
    {
        // Custom certificate handling
    }
}

$auth = new \PavelMaca\OpenBanking\Auth\StandardAuthentication();
$auth->setCertificate(__DIR__ . '/../data/cert.crt', 'secretPassword');
$auth->setAccessToken('timeLimitedToken');

$connector = new \PavelMaca\OpenBanking\Bank\StandardConnector($auth, 'http://banka.cz/', 'v1'); 


try {
    $ais = new \PavelMaca\OpenBanking\Standard\AccountInformation($connector);
    $accountList = $ais->getAccountList();
    var_dump($accountList);
    
    $cisp = new \PavelMaca\OpenBanking\Standard\BalanceCheck($connector);
    $transactionDetail = new \PavelMaca\OpenBanking\Standard\CISP\Parts\TransactionDetail('CZK', 100);
    $balanceCheckRequest = new \PavelMaca\OpenBanking\Standard\CISP\BalanceCheckRequest('id', 'CZ010046464', $transactionDetail);
    $cisp->getBalanceCheck($balanceCheckRequest);

    $pisp = new \PavelMaca\OpenBanking\Standard\PaymentInitialization($connector);
    $paymentRequest = new \PavelMaca\OpenBanking\Standard\PISP\DomesticPaymentRequest('id', 100, 'CZK', 'CZ0123', 'CZ0456');
    $accountBalance = $pisp->createPayment($paymentRequest);
} catch (\PavelMaca\OpenBanking\Standard\Exception\StandardException $ex) {
    var_dump($ex);
}