So I have spent the last two days looking around on stackoverflow and also the stripe API and I can't seem to find out how to get the banking ID when I add a new bank account for a worker. The account gets added to stripe, but it never seems to return me a bank id token, the ba_****.
Here is my code to add the bank account:
First method I tried:
$bank_account_token = mysqli_real_escape_string($link, $_POST['token']);
$account = \Stripe\Account::retrieve($worker_token);
$account->external_accounts->create(["external_account" =>
$bank_account_token]);
$bank_id = $account->external_account->id;
This is the second method I tried:
$account = \Stripe\Account::retrieve($worker_token);
$account->external_accounts->create(array(
"external_account" => array(
"object" => "bank_account",
"account_number" => $account_number,
"routing_number" => $routing_number,
"country" => "US",
"currency" => "USD",)
));
$bank_id = $account->external_account->id;
I have also tried these various other methods to try and capture the bank id after it has been input into stripe and none of them return an id.
$bank_id = $account->bank_account->id;
$bank_id = $account->bank_account->external_account->id;
$bank_id = $account->external_accounts->bank_account->id;
This is the response that stripe says I should get when I add a new bank account:
com.stripe.model.BankAccount JSON: {
"id": "ba_1DVFGuC7941OKJKEoBwDlmHc",
"object": "bank_account",
"account_holder_name": null,
"account_holder_type": null,
"bank_name": "STRIPE TEST BANK",
"country": "US",
"currency": "usd",
"fingerprint": "bGA06pJMr6Vwreh6",
"last4": "6789",
"metadata": {
},
"routing_number": "110000000",
"status": "new",
"account": "acct_1BS4bBC7941OKJKE"
}