C 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

C Example

#include <C_CkRest.h>
#include <C_CkStringBuilder.h>
#include <C_CkJsonObject.h>

void ChilkatSample(void)
    {
    HCkRest rest;
    BOOL success;
    BOOL bTls;
    int port;
    BOOL bAutoReconnect;
    HCkStringBuilder sbResponseBody;
    HCkJsonObject jsonResponse;
    const char *object;
    const char *url;
    BOOL has_more;
    int i;
    int count_i;
    const char *id;
    const char *account;
    const char *account_holder_name;
    const char *account_holder_type;
    const char *bank_name;
    const char *country;
    const char *currency;
    BOOL default_for_currency;
    const char *fingerprint;
    const char *last4;
    const char *routing_number;
    const char *status;
    const char *customer;

    rest = CkRest_Create();

    //  URL: https://api.stripe.com/v1/customers/cus_CBbg3iRMzWBjoe/sources?object=bank_account&limit=3
    bTls = TRUE;
    port = 443;
    bAutoReconnect = TRUE;
    success = CkRest_Connect(rest,"api.stripe.com",port,bTls,bAutoReconnect);
    if (success != TRUE) {
        printf("ConnectFailReason: %d\n",CkRest_getConnectFailReason(rest));
        printf("%s\n",CkRest_lastErrorText(rest));
        CkRest_Dispose(rest);
        return;
    }

    CkRest_SetAuthBasic(rest,"STRIPE_SECRET_KEY","");

    sbResponseBody = CkStringBuilder_Create();
    success = CkRest_FullRequestNoBodySb(rest,"GET","/v1/customers/cus_CBbg3iRMzWBjoe/sources?object=bank_account&limit=3",sbResponseBody);
    if (success != TRUE) {
        printf("%s\n",CkRest_lastErrorText(rest));
        CkRest_Dispose(rest);
        CkStringBuilder_Dispose(sbResponseBody);
        return;
    }

    jsonResponse = CkJsonObject_Create();
    CkJsonObject_LoadSb(jsonResponse,sbResponseBody);

    object = CkJsonObject_stringOf(jsonResponse,"object");
    url = CkJsonObject_stringOf(jsonResponse,"url");
    has_more = CkJsonObject_BoolOf(jsonResponse,"has_more");
    i = 0;
    count_i = CkJsonObject_SizeOfArray(jsonResponse,"data");
    while (i < count_i) {
        CkJsonObject_putI(jsonResponse,i);
        id = CkJsonObject_stringOf(jsonResponse,"data[i].id");
        object = CkJsonObject_stringOf(jsonResponse,"data[i].object");
        account = CkJsonObject_stringOf(jsonResponse,"data[i].account");
        account_holder_name = CkJsonObject_stringOf(jsonResponse,"data[i].account_holder_name");
        account_holder_type = CkJsonObject_stringOf(jsonResponse,"data[i].account_holder_type");
        bank_name = CkJsonObject_stringOf(jsonResponse,"data[i].bank_name");
        country = CkJsonObject_stringOf(jsonResponse,"data[i].country");
        currency = CkJsonObject_stringOf(jsonResponse,"data[i].currency");
        default_for_currency = CkJsonObject_BoolOf(jsonResponse,"data[i].default_for_currency");
        fingerprint = CkJsonObject_stringOf(jsonResponse,"data[i].fingerprint");
        last4 = CkJsonObject_stringOf(jsonResponse,"data[i].last4");
        routing_number = CkJsonObject_stringOf(jsonResponse,"data[i].routing_number");
        status = CkJsonObject_stringOf(jsonResponse,"data[i].status");
        customer = CkJsonObject_stringOf(jsonResponse,"data[i].customer");
        i = i + 1;
    }



    CkRest_Dispose(rest);
    CkStringBuilder_Dispose(sbResponseBody);
    CkJsonObject_Dispose(jsonResponse);

    }

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