分行银行帐号

时间:2018-11-11 10:29:23

标签: php stripe-payments

因此,过去两天我一直在研究stackoverflow和条纹API,当为工人添加新的银行帐户时,我似乎找不到如何获取银行ID的方法。该帐户被添加到条带中,但它似乎从未向我返回银行ID令牌ba _ ****。

这是我添加银行帐户的代码:

我尝试过的第一种方法:

 $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;

这是我尝试的第二种方法:

$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;

我还尝试了其他各种方法来尝试将银行ID输入到条带中之后,并没有一个返回ID。

$bank_id = $account->bank_account->id;
$bank_id = $account->bank_account->external_account->id;
$bank_id = $account->external_accounts->bank_account->id;

这是Stripe说的在我添加新的银行帐户时应该得到的响应:

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"
}

1 个答案:

答案 0 :(得分:0)

好的,所以在进一步挖掘并扩展到条带化(等待他们的电子邮件回复)之后,我发现他们的文档在某些部分中已过时。正确的响应是:

 "external_accounts": {
"object": "list",
"data": [
  {
    "id": "ba_1DVFGuC7941OKJKEoBwDlmHc",
    "object": "bank_account",
    "account": "acct_2BS4cCb7841ONDLK",
    "account_holder_name": null,
    "account_holder_type": null,
    "bank_name": "STRIPE TEST BANK",
    "country": "US",
    "currency": "usd",
    "default_for_currency": true,
    "fingerprint": "bGA06pJMr6Vwreh6",
    "last4": "6789",
    "metadata": {
    },
    "routing_number": "110000000",
    "status": "new"
  }
],

因此要提取第一个元素(即id),我需要将其提取为数组:

  $account = \Stripe\Account::retrieve($worker_token);
  $account->external_accounts->create(["external_account" => $bank_account_token]);
  $bank_id = $account->external_accounts->data[0]->id;