Unicode C++ Requires Chilkat v11.7.0+
Unicode C++
Stripe: Show available and pending balances by currency
See more Stripe Examples
Read the available and pending account balances for every currency returned by Stripe.
Stripe documentation and cURL example
Chilkat Unicode C++ Downloads
#include <CkHttpCurlW.h>
#include <CkStringBuilderW.h>
#include <CkJsonObjectW.h>
void ChilkatSample(void)
{
bool success = false;
// Requires an unlocked Chilkat bundle. See Global Unlock Sample.
// Supply a restricted sandbox key from merchant-controlled configuration.
const wchar_t *apiKey = L"YOUR_STRIPE_TEST_KEY";
CkHttpCurlW curl;
CkStringBuilderW cmd;
CkJsonObjectW json;
int replaced;
// curl -X GET "https://api.stripe.com/v1/balance" \
// -u "$STRIPE_API_KEY:" \
// -H "Stripe-Version: 2026-10-28.endive"
cmd.SetString(L"curl -X GET \"https://api.stripe.com/v1/balance\"");
cmd.Append(L" -u \"@KEY@:\"");
cmd.Append(L" -H \"Stripe-Version: 2026-10-28.endive\"");
replaced = cmd.Replace(L"@KEY@",apiKey);
success = curl.DoYourThing(cmd.getAsString());
if (success != true) {
wprintf(L"No HTTP response. Chilkat failure code: %d\n",curl.get_FailReason());
return;
}
success = curl.GetResponseJson(json);
if ((curl.get_StatusCode() != 200) || (success != true)) {
wprintf(L"Stripe HTTP %d Request-Id: %s\n",curl.get_StatusCode(),curl.getResponseHeaderField(L"Request-Id"));
if (success == true) {
wprintf(L"%s\n",json.stringOf(L"error.message"));
}
return;
}
// Amounts are integer minor units. Read them as text to preserve large balances.
int availableIndex = 0;
while ((availableIndex < json.SizeOfArray(L"available"))) {
json.put_I(availableIndex);
wprintf(L"available: %s %s\n",json.stringOf(L"available[i].amount"),json.stringOf(L"available[i].currency"));
availableIndex = availableIndex + 1;
}
int pendingIndex = 0;
while ((pendingIndex < json.SizeOfArray(L"pending"))) {
json.put_I(pendingIndex);
wprintf(L"pending: %s %s\n",json.stringOf(L"pending[i].amount"),json.stringOf(L"pending[i].currency"));
pendingIndex = pendingIndex + 1;
}
}