Unicode C++ Stripe: Retrieve a Balance Transaction

Back to Index

Retrieves the balance transaction with the given ID.

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

CURL Command

curl https://api.stripe.com/v1/balance/history/txn_1BnETJGswQrCoh0XxO2tGYr7 \
   -u STRIPE_SECRET_KEY:

Unicode C++ Example

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

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

    //  URL: https://api.stripe.com/v1/balance/history/txn_1BnETJGswQrCoh0XxO2tGYr7
    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"");

    CkStringBuilderW sbResponseBody;
    success = rest.FullRequestNoBodySb(L"GET",L"/v1/balance/history/txn_1BnETJGswQrCoh0XxO2tGYr7",sbResponseBody);
    if (success != true) {
        wprintf(L"%s\n",rest.lastErrorText());
        return;
    }

    CkJsonObjectW jsonResponse;
    jsonResponse.LoadSb(sbResponseBody);

    const wchar_t *id = 0;
    const wchar_t *object = 0;
    int amount;
    int available_on;
    int created;
    const wchar_t *currency = 0;
    bool description;
    bool exchange_rate;
    int fee;
    int net;
    const wchar_t *source = 0;
    const wchar_t *status = 0;
    const wchar_t *type = 0;
    int i;
    int count_i;

    id = jsonResponse.stringOf(L"id");
    object = jsonResponse.stringOf(L"object");
    amount = jsonResponse.IntOf(L"amount");
    available_on = jsonResponse.IntOf(L"available_on");
    created = jsonResponse.IntOf(L"created");
    currency = jsonResponse.stringOf(L"currency");
    description = jsonResponse.IsNullOf(L"description");
    exchange_rate = jsonResponse.IsNullOf(L"exchange_rate");
    fee = jsonResponse.IntOf(L"fee");
    net = jsonResponse.IntOf(L"net");
    source = jsonResponse.stringOf(L"source");
    status = jsonResponse.stringOf(L"status");
    type = jsonResponse.stringOf(L"type");
    i = 0;
    count_i = jsonResponse.SizeOfArray(L"fee_details");
    while (i < count_i) {
        jsonResponse.put_I(i);
        i = i + 1;
    }
    }

Sample JSON Response Body

{
  "id": "txn_1BnETJGswQrCoh0XxO2tGYr7",
  "object": "balance_transaction",
  "amount": 100,
  "available_on": 1516662781,
  "created": 1516662781,
  "currency": "usd",
  "description": null,
  "exchange_rate": null,
  "fee": 0,
  "fee_details": [
  ],
  "net": 100,
  "source": "ch_1BnETJGswQrCoh0XTs0EERBj",
  "status": "pending",
  "type": "charge"
}