PowerBuilder Requires Chilkat v11.7.0+
PowerBuilder
Stripe: Review invoices and outstanding amounts
See more Stripe Examples
List open invoices for a billing account and show outstanding amounts, due dates, and invoice links.
Stripe documentation and cURL example
Chilkat PowerBuilder Downloads
integer li_rc
long li_Success
string ls_ApiKey
oleobject loo_Curl
oleobject loo_Cmd
oleobject loo_Json
long li_Replaced
string ls_CustomerId
oleobject loo_PageSuffix
long li_More
string ls_Cursor
long i
long li_Count
string ls_Next
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")
ls_CustomerId = "cus_FROM_BILLING_ACCOUNT"
// Remove status=open to show all invoice states.
loo_PageSuffix = create oleobject
li_rc = loo_PageSuffix.ConnectToNewObject("Chilkat.StringBuilder")
li_More = 1
ls_Cursor = ""
do while (li_More = 1)
// curl -X GET "https://api.stripe.com/v1/invoices?customer={customerId}&status=open&limit=100" \
// -u "$STRIPE_API_KEY:" \
// -H "Stripe-Version: 2026-10-28.endive"
loo_Cmd.SetString("curl -X GET ~"https://api.stripe.com/v1/invoices?customer=@CUSTOMER@&status=open&limit=100@CURSOR@~"")
loo_Cmd.Append(" -u ~"@KEY@:~"")
loo_Cmd.Append(" -H ~"Stripe-Version: 2026-10-28.endive~"")
li_Replaced = loo_Cmd.Replace("@CURSOR@",loo_PageSuffix.GetAsString())
li_Replaced = loo_Cmd.Replace("@CUSTOMER@",ls_CustomerId)
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
destroy loo_PageSuffix
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
destroy loo_PageSuffix
return
end if
i = 0
li_Count = loo_Json.SizeOfArray("data")
do while (i < li_Count)
loo_Json.I = i
Write-Debug loo_Json.StringOf("data[i].id") + " | " + loo_Json.StringOf("data[i].number") + " | " + loo_Json.StringOf("data[i].status") + " | " + loo_Json.StringOf("data[i].due_date") + " | " + loo_Json.StringOf("data[i].amount_remaining") + " | " + loo_Json.StringOf("data[i].currency") + " | " + loo_Json.StringOf("data[i].hosted_invoice_url") + " | " + loo_Json.StringOf("data[i].invoice_pdf")
i = i + 1
loop
li_More = loo_Json.BoolOf("has_more")
if li_More = 1 then
ls_Next = loo_Json.StringOf("data[i].id")
if (li_Count < 1) OR (ls_Next = "") OR (ls_Next = ls_Cursor) then
Write-Debug "Invalid pagination cursor."
destroy loo_Curl
destroy loo_Cmd
destroy loo_Json
destroy loo_PageSuffix
return
end if
ls_Cursor = ls_Next
loo_PageSuffix.SetString("&starting_after=")
loo_PageSuffix.Append(ls_Cursor)
end if
loop
destroy loo_Curl
destroy loo_Cmd
destroy loo_Json
destroy loo_PageSuffix