nordigen / nordigen-php
Nordigen官方PHP API客户端
1.1.2
2024-02-13 14:06 UTC
Requires
- php: >=7.4
- ext-curl: *
- ext-json: *
- guzzlehttp/guzzle: ^7.3
Requires (Dev)
- blastcloud/guzzler: ^2.0
- phpunit/phpunit: ^9.5
This package is not auto-updated.
Last update: 2024-09-11 11:33:58 UTC
README
这是GoCardless银行账户数据的官方PHP客户端库GoCardless Bank Account Data。
有关端点和参数的完整列表,请参阅文档。
在开始使用API之前,您需要创建一个新的密钥并从Nordigen的开放银行门户获取您的SECRET_ID
和SECRET_KEY
。
要求
- PHP >= 7.4
安装
使用Composer安装库
composer require nordigen/nordigen-php
示例应用程序
Laravel示例应用程序位于example
目录中
快速入门
要使用此库,请使用Composer的自动加载
require_once('vendor/autoload.php');
// Get secretId and secretKey from bankaccoutndata.gocardless.com portal and pass them to NordigenClient $secretId = "YOUR_SECRET_ID"; $secretKey = "YOUR_SECRET_KEY"; $client = new \Nordigen\NordigenPHP\API\NordigenClient($secretId, $secretKey); // Generate new access token. Token is valid for 24 hours // Token is automatically injected into every response $token = $client->createAccessToken(); // Get access token $accessToken = $client->getAccessToken(); // Get refresh token $refreshToken = $client->getRefreshToken(); // Exchange refresh token for new access token $newToken = $client->refreshAccessToken($refreshToken); // Get list of institutions by country. Country should be in ISO 3166 standard. $institutions = $client->institution->getInstitutionsByCountry("LV"); // Institution id can be gathered from getInstitutions response. // Example Revolut ID $institutionId = "REVOLUT_REVOGB21"; $redirectUri = "https://nordigen.com"; // Initialize new bank connection session $session = $client->initSession($institutionId, $redirectUri); // Get link to authorize in the bank // Authorize with your bank via this link, to gain access to account data $link = $session["link"]; // requisition id is needed to get accountId in the next step $requisitionId = $session["requisition_id"];
在成功授权银行后,您可以获取您的数据(详细信息、余额、交易)
获取账户元数据、余额、详细信息和交易
// Get account id after completed authorization with a bank $requisitionData = $client->requisition->getRequisition($requisitionId); // Get account id from the array of accounts $accountId = $requisitionData["accounts"][0]; // Instantiate account object $account = $client->account($accountId); // Fetch account metadata $metadata = $account->getAccountMetaData(); // Fetch account balances $balances = $account->getAccountBalances(); // Fetch account details $details = $account->getAccountDetails(); // Fetch account transactions $transactions = $account->getAccountTransactions(); // Optional. You can filter transactions by specific date range $transactions = $account->getAccountTransactions("2021-12-01", "2022-01-30"); // Get premium transactions // Optional parameters country, dateFrom, dateTo $premiumTransactions = $account->getPremiumAccountTransactions();
要使用高级端点,请联系我们的[email protected]
测试
./vendor/bin/phpunit
支持
如有任何疑问,请联系[email protected]或创建存储库中的问题。