Perl Stripe: List all Bank Accounts

Back to Index

List bank accounts belonging to a customer.

Documentation: https://stripe.com/docs/api/curl#customer_list_bank_accounts

CURL Command

curl "https://api.stripe.com/v1/customers/cus_CBbg3iRMzWBjoe/sources?object=bank_account&limit=3" \
   -u STRIPE_SECRET_KEY: \
   -G

Perl Example

use chilkat();

$rest = chilkat::CkRest->new();

#  URL: https://api.stripe.com/v1/customers/cus_CBbg3iRMzWBjoe/sources?object=bank_account&limit=3
$bTls = 1;
$port = 443;
$bAutoReconnect = 1;
$success = $rest->Connect("api.stripe.com",$port,$bTls,$bAutoReconnect);
if ($success != 1) {
    print "ConnectFailReason: " . $rest->get_ConnectFailReason() . "\r\n";
    print $rest->lastErrorText() . "\r\n";
    exit;
}

$rest->SetAuthBasic("STRIPE_SECRET_KEY","");

$sbResponseBody = chilkat::CkStringBuilder->new();
$success = $rest->FullRequestNoBodySb("GET","/v1/customers/cus_CBbg3iRMzWBjoe/sources?object=bank_account&limit=3",$sbResponseBody);
if ($success != 1) {
    print $rest->lastErrorText() . "\r\n";
    exit;
}

$jsonResponse = chilkat::CkJsonObject->new();
$jsonResponse->LoadSb($sbResponseBody);

$object = $jsonResponse->stringOf("object");
$url = $jsonResponse->stringOf("url");
$has_more = $jsonResponse->BoolOf("has_more");
$i = 0;
$count_i = $jsonResponse->SizeOfArray("data");
while ($i < $count_i) {
    $jsonResponse->put_I($i);
    $id = $jsonResponse->stringOf("data[i].id");
    $object = $jsonResponse->stringOf("data[i].object");
    $account = $jsonResponse->stringOf("data[i].account");
    $account_holder_name = $jsonResponse->stringOf("data[i].account_holder_name");
    $account_holder_type = $jsonResponse->stringOf("data[i].account_holder_type");
    $bank_name = $jsonResponse->stringOf("data[i].bank_name");
    $country = $jsonResponse->stringOf("data[i].country");
    $currency = $jsonResponse->stringOf("data[i].currency");
    $default_for_currency = $jsonResponse->BoolOf("data[i].default_for_currency");
    $fingerprint = $jsonResponse->stringOf("data[i].fingerprint");
    $last4 = $jsonResponse->stringOf("data[i].last4");
    $routing_number = $jsonResponse->stringOf("data[i].routing_number");
    $status = $jsonResponse->stringOf("data[i].status");
    $customer = $jsonResponse->stringOf("data[i].customer");
    $i = $i + 1;
}

Sample JSON Response Body

{
  "object": "list",
  "url": "/v1/customers/cus_CBbg3iRMzWBjoe/sources",
  "has_more": false,
  "data": [
    {
      "id": "ba_1BnETKGswQrCoh0XzgjB3t99",
      "object": "bank_account",
      "account": "acct_18qpKxGswQrCoh0X",
      "account_holder_name": "Jane Austen",
      "account_holder_type": "individual",
      "bank_name": "STRIPE TEST BANK",
      "country": "US",
      "currency": "usd",
      "default_for_currency": false,
      "fingerprint": "L2j4aSuWk1MZMDZ5",
      "last4": "6789",
      "metadata": {},
      "routing_number": "110000000",
      "status": "new",
      "customer": "cus_CBbg3iRMzWBjoe"
    }
  ]
}