Delphi DLL Requires Chilkat v11.7.0+
Delphi DLL
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 Delphi DLL Downloads
var
success: Boolean;
apiKey: PWideChar;
curl: HCkHttpCurl;
cmd: HCkStringBuilder;
json: HCkJsonObject;
replaced: Integer;
availableIndex: Integer;
pendingIndex: Integer;
begin
success := False;
// Requires an unlocked Chilkat bundle. See Global Unlock Sample.
// Supply a restricted sandbox key from merchant-controlled configuration.
apiKey := 'YOUR_STRIPE_TEST_KEY';
curl := CkHttpCurl_Create();
cmd := CkStringBuilder_Create();
json := CkJsonObject_Create();
// curl -X GET "https://api.stripe.com/v1/balance" \
// -u "$STRIPE_API_KEY:" \
// -H "Stripe-Version: 2026-10-28.endive"
CkStringBuilder_SetString(cmd,'curl -X GET "https://api.stripe.com/v1/balance"');
CkStringBuilder_Append(cmd,' -u "@KEY@:"');
CkStringBuilder_Append(cmd,' -H "Stripe-Version: 2026-10-28.endive"');
replaced := CkStringBuilder_Replace(cmd,'@KEY@',apiKey);
success := CkHttpCurl_DoYourThing(curl,CkStringBuilder__getAsString(cmd));
if (success <> True) then
begin
Memo1.Lines.Add('No HTTP response. Chilkat failure code: ' + IntToStr(CkHttpCurl_getFailReason(curl)));
Exit;
end;
success := CkHttpCurl_GetResponseJson(curl,json);
if ((CkHttpCurl_getStatusCode(curl) <> 200) or (success <> True)) then
begin
Memo1.Lines.Add('Stripe HTTP ' + IntToStr(CkHttpCurl_getStatusCode(curl)) + ' Request-Id: ' + CkHttpCurl__getResponseHeaderField(curl,'Request-Id'));
if (success = True) then
begin
Memo1.Lines.Add(CkJsonObject__stringOf(json,'error.message'));
end;
Exit;
end;
// Amounts are integer minor units. Read them as text to preserve large balances.
availableIndex := 0;
while (availableIndex < CkJsonObject_SizeOfArray(json,'available')) do
begin
CkJsonObject_putI(json,availableIndex);
Memo1.Lines.Add('available: ' + CkJsonObject__stringOf(json,'available[i].amount') + ' ' + CkJsonObject__stringOf(json,'available[i].currency'));
availableIndex := availableIndex + 1;
end;
pendingIndex := 0;
while (pendingIndex < CkJsonObject_SizeOfArray(json,'pending')) do
begin
CkJsonObject_putI(json,pendingIndex);
Memo1.Lines.Add('pending: ' + CkJsonObject__stringOf(json,'pending[i].amount') + ' ' + CkJsonObject__stringOf(json,'pending[i].currency'));
pendingIndex := pendingIndex + 1;
end;
CkHttpCurl_Dispose(curl);
CkStringBuilder_Dispose(cmd);
CkJsonObject_Dispose(json);