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

PowerBuilder
integer li_rc
long li_Success
string ls_ApiKey
oleobject loo_Curl
oleobject loo_Cmd
oleobject loo_Json
long li_Replaced
long li_AvailableIndex
long li_PendingIndex

li_Success = 0

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

loo_Curl = create oleobject
li_rc = loo_Curl.ConnectToNewObject("Chilkat.HttpCurl")
if li_rc < 0 then
    destroy loo_Curl
    MessageBox("Error","Connecting to COM object failed")
    return
end if
loo_Cmd = create oleobject
li_rc = loo_Cmd.ConnectToNewObject("Chilkat.StringBuilder")

loo_Json = create oleobject
li_rc = loo_Json.ConnectToNewObject("Chilkat.JsonObject")

//  curl -X GET "https://api.stripe.com/v1/balance" \
//    -u "$STRIPE_API_KEY:" \
//    -H "Stripe-Version: 2026-10-28.endive"
loo_Cmd.SetString("curl -X GET ~"https://api.stripe.com/v1/balance~"")
loo_Cmd.Append(" -u ~"@KEY@:~"")
loo_Cmd.Append(" -H ~"Stripe-Version: 2026-10-28.endive~"")
li_Replaced = loo_Cmd.Replace("@KEY@",ls_ApiKey)
li_Success = loo_Curl.DoYourThing(loo_Cmd.GetAsString())
if li_Success <> 1 then
    Write-Debug "No HTTP response. Chilkat failure code: " + string(loo_Curl.FailReason)
    destroy loo_Curl
    destroy loo_Cmd
    destroy loo_Json
    return
end if

li_Success = loo_Curl.GetResponseJson(loo_Json)
if (loo_Curl.StatusCode <> 200) OR (li_Success <> 1) then
    Write-Debug "Stripe HTTP " + string(loo_Curl.StatusCode) + "  Request-Id: " + loo_Curl.GetResponseHeaderField("Request-Id")
    if li_Success = 1 then
        Write-Debug loo_Json.StringOf("error.message")
    end if

    destroy loo_Curl
    destroy loo_Cmd
    destroy loo_Json
    return
end if

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

li_AvailableIndex = 0
do while (li_AvailableIndex < loo_Json.SizeOfArray("available"))
    loo_Json.I = li_AvailableIndex
    Write-Debug "available: " + loo_Json.StringOf("available[i].amount") + " " + loo_Json.StringOf("available[i].currency")
    li_AvailableIndex = li_AvailableIndex + 1
loop

li_PendingIndex = 0
do while (li_PendingIndex < loo_Json.SizeOfArray("pending"))
    loo_Json.I = li_PendingIndex
    Write-Debug "pending: " + loo_Json.StringOf("pending[i].amount") + " " + loo_Json.StringOf("pending[i].currency")
    li_PendingIndex = li_PendingIndex + 1
loop


destroy loo_Curl
destroy loo_Cmd
destroy loo_Json