Sample code for 30+ languages & platforms
Xbase++ Requires Chilkat v11.7.0+

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 Xbase++ Downloads

Xbase++
LOCAL nSuccess
LOCAL cApiKey
LOCAL oCurl
LOCAL oCmd
LOCAL oJson
LOCAL nReplaced
LOCAL nAvailableIndex
LOCAL nPendingIndex

nSuccess := 0

//  Requires an unlocked Chilkat bundle. See Global Unlock Sample.
//  Supply a restricted sandbox key from merchant-controlled configuration.
cApiKey := "YOUR_STRIPE_TEST_KEY"

oCurl := CreateObject("Chilkat.HttpCurl")
oCmd := CreateObject("Chilkat.StringBuilder")
oJson := CreateObject("Chilkat.JsonObject")

//  curl -X GET "https://api.stripe.com/v1/balance" \
//    -u "$STRIPE_API_KEY:" \
//    -H "Stripe-Version: 2026-10-28.endive"
oCmd:SetString('curl -X GET "https://api.stripe.com/v1/balance"')
oCmd:Append(' -u "@KEY@:"')
oCmd:Append(' -H "Stripe-Version: 2026-10-28.endive"')
nReplaced := oCmd:Replace("@KEY@", cApiKey)
nSuccess := oCurl:DoYourThing(oCmd:GetAsString())
IF (nSuccess != 1)
    ? "No HTTP response. Chilkat failure code: " + Str(oCurl:FailReason)
    oCurl:destroy()
    oCmd:destroy()
    oJson:destroy()
    RETURN
ENDIF

nSuccess := oCurl:GetResponseJson(oJson)
IF ((oCurl:StatusCode != 200) .OR. (nSuccess != 1))
    ? "Stripe HTTP " + Str(oCurl:StatusCode) + "  Request-Id: " + oCurl:GetResponseHeaderField("Request-Id")
    IF (nSuccess == 1)
        ? oJson:StringOf("error.message")
    ENDIF

    oCurl:destroy()
    oCmd:destroy()
    oJson:destroy()
    RETURN
ENDIF

//  Amounts are integer minor units. Read them as text to preserve large balances.

nAvailableIndex := 0
DO WHILE (nAvailableIndex < oJson:SizeOfArray("available"))
    oJson:I := nAvailableIndex
    ? "available: " + oJson:StringOf("available[i].amount") + " " + oJson:StringOf("available[i].currency")
    nAvailableIndex := nAvailableIndex + 1
ENDDO

nPendingIndex := 0
DO WHILE (nPendingIndex < oJson:SizeOfArray("pending"))
    oJson:I := nPendingIndex
    ? "pending: " + oJson:StringOf("pending[i].amount") + " " + oJson:StringOf("pending[i].currency")
    nPendingIndex := nPendingIndex + 1
ENDDO

oCurl:destroy()
oCmd:destroy()
oJson:destroy()