Sample code for 30+ languages & platforms
Visual FoxPro 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 Visual FoxPro Downloads

Visual FoxPro
LOCAL lnSuccess
LOCAL lcApiKey
LOCAL loCurl
LOCAL loCmd
LOCAL loJson
LOCAL lnReplaced
LOCAL lnAvailableIndex
LOCAL lnPendingIndex

lnSuccess = 0

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

loCurl = CreateObject('Chilkat.HttpCurl')
loCmd = CreateObject('Chilkat.StringBuilder')
loJson = CreateObject('Chilkat.JsonObject')

*  curl -X GET "https://api.stripe.com/v1/balance" \
*    -u "$STRIPE_API_KEY:" \
*    -H "Stripe-Version: 2026-10-28.endive"
loCmd.SetString('curl -X GET "https://api.stripe.com/v1/balance"')
loCmd.Append(' -u "@KEY@:"')
loCmd.Append(' -H "Stripe-Version: 2026-10-28.endive"')
lnReplaced = loCmd.Replace("@KEY@",lcApiKey)
lnSuccess = loCurl.DoYourThing(loCmd.GetAsString())
IF (lnSuccess <> 1) THEN
    ? "No HTTP response. Chilkat failure code: " + STR(loCurl.FailReason)
    RELEASE loCurl
    RELEASE loCmd
    RELEASE loJson
    CANCEL
ENDIF

lnSuccess = loCurl.GetResponseJson(loJson)
IF ((loCurl.StatusCode <> 200) OR (lnSuccess <> 1)) THEN
    ? "Stripe HTTP " + STR(loCurl.StatusCode) + "  Request-Id: " + loCurl.GetResponseHeaderField("Request-Id")
    IF (lnSuccess = 1) THEN
        ? loJson.StringOf("error.message")
    ENDIF

    RELEASE loCurl
    RELEASE loCmd
    RELEASE loJson
    CANCEL
ENDIF

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

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

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

RELEASE loCurl
RELEASE loCmd
RELEASE loJson