Unicode C Stripe: Retrieve a Bank Account

Back to Index

Retrieve details about a specific bank account stored on the Stripe account.

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

CURL Command

curl https://api.stripe.com/v1/customers/cus_CBbg3iRMzWBjoe/sources/ba_1BnETKGswQrCoh0XzgjB3t99 \
   -u STRIPE_SECRET_KEY:

Unicode C Example

#include <C_CkRestW.h>
#include <C_CkStringBuilderW.h>
#include <C_CkJsonObjectW.h>

void ChilkatSample(void)
    {
    HCkRestW rest;
    BOOL success;
    BOOL bTls;
    int port;
    BOOL bAutoReconnect;
    HCkStringBuilderW sbResponseBody;
    HCkJsonObjectW jsonResponse;
    const wchar_t *id;
    const wchar_t *object;
    const wchar_t *account;
    const wchar_t *account_holder_name;
    const wchar_t *account_holder_type;
    const wchar_t *bank_name;
    const wchar_t *country;
    const wchar_t *currency;
    BOOL default_for_currency;
    const wchar_t *fingerprint;
    const wchar_t *last4;
    const wchar_t *routing_number;
    const wchar_t *status;
    const wchar_t *customer;

    rest = CkRestW_Create();

    //  URL: https://api.stripe.com/v1/customers/cus_CBbg3iRMzWBjoe/sources/ba_1BnETKGswQrCoh0XzgjB3t99
    bTls = TRUE;
    port = 443;
    bAutoReconnect = TRUE;
    success = CkRestW_Connect(rest,L"api.stripe.com",port,bTls,bAutoReconnect);
    if (success != TRUE) {
        wprintf(L"ConnectFailReason: %d\n",CkRestW_getConnectFailReason(rest));
        wprintf(L"%s\n",CkRestW_lastErrorText(rest));
        CkRestW_Dispose(rest);
        return;
    }

    CkRestW_SetAuthBasic(rest,L"STRIPE_SECRET_KEY",L"");

    sbResponseBody = CkStringBuilderW_Create();
    success = CkRestW_FullRequestNoBodySb(rest,L"GET",L"/v1/customers/cus_CBbg3iRMzWBjoe/sources/ba_1BnETKGswQrCoh0XzgjB3t99",sbResponseBody);
    if (success != TRUE) {
        wprintf(L"%s\n",CkRestW_lastErrorText(rest));
        CkRestW_Dispose(rest);
        CkStringBuilderW_Dispose(sbResponseBody);
        return;
    }

    jsonResponse = CkJsonObjectW_Create();
    CkJsonObjectW_LoadSb(jsonResponse,sbResponseBody);

    id = CkJsonObjectW_stringOf(jsonResponse,L"id");
    object = CkJsonObjectW_stringOf(jsonResponse,L"object");
    account = CkJsonObjectW_stringOf(jsonResponse,L"account");
    account_holder_name = CkJsonObjectW_stringOf(jsonResponse,L"account_holder_name");
    account_holder_type = CkJsonObjectW_stringOf(jsonResponse,L"account_holder_type");
    bank_name = CkJsonObjectW_stringOf(jsonResponse,L"bank_name");
    country = CkJsonObjectW_stringOf(jsonResponse,L"country");
    currency = CkJsonObjectW_stringOf(jsonResponse,L"currency");
    default_for_currency = CkJsonObjectW_BoolOf(jsonResponse,L"default_for_currency");
    fingerprint = CkJsonObjectW_stringOf(jsonResponse,L"fingerprint");
    last4 = CkJsonObjectW_stringOf(jsonResponse,L"last4");
    routing_number = CkJsonObjectW_stringOf(jsonResponse,L"routing_number");
    status = CkJsonObjectW_stringOf(jsonResponse,L"status");
    customer = CkJsonObjectW_stringOf(jsonResponse,L"customer");


    CkRestW_Dispose(rest);
    CkStringBuilderW_Dispose(sbResponseBody);
    CkJsonObjectW_Dispose(jsonResponse);

    }

Sample JSON Response Body

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