Found duplicate transactions when relogged-in to a specific bank account
ahmad13544 opened this issue · 1 comments
Do not receiving new transactions against a specific bank account, but when I verify transactions from the following endpoint, it shows that there are new transactions available.
When I delete this specific account (do not delete transactions just update account status bit to 1) and relogged-in to the account using bank credentials, it creates new entry in database with different access token of same bank account, also it gives duplicated transactions.
I've looked into a solution that for new account exchange token request (relogged-in), need to compare combination of the accounts’ institution_id, account name, and account mask to determine whether an end user has previously linked an account to your application. Do not exchange a public token for an access token if you detect a duplicate Item.
Need some help in implementing this solution, like after exchange token request, do I need to active same deleted account and do not change account access token instead of adding new account in the database with the new access token (current flow).
$accessTokenObject = (array)$this->plaid->items->exchangeToken($publicTokenObject['public_token']);
if ($accessTokenObject) {
$bank = Banks::updateOrCreate([
'bank_name' => $publicTokenObject['institution']['name'],
'user_id' => Auth::user()->id
], [
'access_token' => $accessTokenObject['access_token']
]);
foreach ($publicTokenObject['accounts'] as $a => $account) {
Accounts::updateOrCreate(
[
'bank_id' => $bank['id'],
'name' => $account['name'],
'mask' => $account['mask']
],
[
'access_token'=>$accessTokenObject['access_token'],
'name' => $account['name'],
'status' => 0,
// 'available'=>$account['balances']['available'],
// 'current'=>$account['balances']['current'],
'subtype' => $account['subtype'],
'type' => $account['type'],
'account_id' => $account['id'],
// 'official_name'=>$account['official_name']
]
);
}
That has nothing to do with the package. It has to do with your implementation.
Each time you run this; you are creating a new session with plaid for the specific account(s). That is why you see a new ID generated and duplicated transactions being stored within your application.