PHP code example of azaharizaman / nexus-payment-bank
1. Go to this page and download the library: Download azaharizaman/nexus-payment-bank 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/ */
azaharizaman / nexus-payment-bank example snippets
use Nexus\PaymentBank\Contracts\BankConnectionManagerInterface;
public function connect(BankConnectionManagerInterface $manager)
{
// 1. Initiate connection flow
$result = $manager->initiateConnection(
providerName: 'plaid',
tenantId: 'tenant-1',
parameters: [
'redirect_url' => 'https://app.example.com/callback',
'scopes' => ['transactions', 'auth']
]
);
// Redirect user to the authorization URL from $result
// 2. Complete connection after callback
$connection = $manager->completeConnection(
providerName: 'plaid',
tenantId: 'tenant-1',
callbackData: [
'public_token' => 'public-token-from-callback',
'institution_id' => 'ins_123'
]
);
}
use Nexus\PaymentBank\Contracts\AccountServiceInterface;
public function showAccounts(AccountServiceInterface $service, string $connectionId)
{
// Get all accounts for a connection
$accounts = $service->getAccounts($connectionId);
foreach ($accounts as $account) {
echo $account->getName() . ': ' . $account->getBalance()->getAmount();
}
// Get transactions
$transactions = $service->getTransactions(
connectionId: $connectionId,
accountId: $accounts[0]->getId(),
startDate: new \DateTimeImmutable('-30 days'),
endDate: new \DateTimeImmutable('now')
);
}