1. Go to this page and download the library: Download oaklabs/psd2 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/ */
oaklabs / psd2 example snippets
// 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();
// 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()
}
// 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()
}
// 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()
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.