Unicode C++ Stripe: Update a Bank Account

Back to Index

Updates the metadata, account_holder_name, and account_holder_type of a bank account belonging to a Customer. Other bank account details are not editable by design.

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

CURL Command

curl https://api.stripe.com/v1/customers/cus_CBbg3iRMzWBjoe/sources/ba_1BnETKGswQrCoh0XzgjB3t99 \
   -u STRIPE_SECRET_KEY: \
   -d metadata[key]=value \
   -X POST

Unicode C++ Example

#include <CkRestW.h>
#include <CkJsonObjectW.h>

void ChilkatSample(void)
    {
    CkRestW rest;
    bool success;

    //  URL: https://api.stripe.com/v1/customers/cus_CBbg3iRMzWBjoe/sources/ba_1BnETKGswQrCoh0XzgjB3t99
    bool bTls = true;
    int port = 443;
    bool bAutoReconnect = true;
    success = rest.Connect(L"api.stripe.com",port,bTls,bAutoReconnect);
    if (success != true) {
        wprintf(L"ConnectFailReason: %d\n",rest.get_ConnectFailReason());
        wprintf(L"%s\n",rest.lastErrorText());
        return;
    }

    rest.SetAuthBasic(L"STRIPE_SECRET_KEY",L"");

    rest.AddQueryParam(L"metadata[key]",L"value");

    const wchar_t *strResponseBody = rest.fullRequestFormUrlEncoded(L"POST",L"/v1/customers/cus_CBbg3iRMzWBjoe/sources/ba_1BnETKGswQrCoh0XzgjB3t99");
    if (rest.get_LastMethodSuccess() != true) {
        wprintf(L"%s\n",rest.lastErrorText());
        return;
    }

    CkJsonObjectW jsonResponse;
    jsonResponse.Load(strResponseBody);

    const wchar_t *id = 0;
    const wchar_t *object = 0;
    const wchar_t *account = 0;
    const wchar_t *account_holder_name = 0;
    const wchar_t *account_holder_type = 0;
    const wchar_t *bank_name = 0;
    const wchar_t *country = 0;
    const wchar_t *currency = 0;
    bool default_for_currency;
    const wchar_t *fingerprint = 0;
    const wchar_t *last4 = 0;
    const wchar_t *routing_number = 0;
    const wchar_t *status = 0;
    const wchar_t *customer = 0;
    const wchar_t *name = 0;

    id = jsonResponse.stringOf(L"id");
    object = jsonResponse.stringOf(L"object");
    account = jsonResponse.stringOf(L"account");
    account_holder_name = jsonResponse.stringOf(L"account_holder_name");
    account_holder_type = jsonResponse.stringOf(L"account_holder_type");
    bank_name = jsonResponse.stringOf(L"bank_name");
    country = jsonResponse.stringOf(L"country");
    currency = jsonResponse.stringOf(L"currency");
    default_for_currency = jsonResponse.BoolOf(L"default_for_currency");
    fingerprint = jsonResponse.stringOf(L"fingerprint");
    last4 = jsonResponse.stringOf(L"last4");
    routing_number = jsonResponse.stringOf(L"routing_number");
    status = jsonResponse.stringOf(L"status");
    customer = jsonResponse.stringOf(L"customer");
    name = jsonResponse.stringOf(L"name");
    }

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",
  "name": "Liam Thomas"
}