Xbase++ Requires Chilkat v11.7.0+
Xbase++
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 Xbase++ Downloads
LOCAL nSuccess
LOCAL cApiKey
LOCAL oCurl
LOCAL oCmd
LOCAL oJson
LOCAL nReplaced
LOCAL cCustomerId
LOCAL oPageSuffix
LOCAL nMore
LOCAL cCursor
LOCAL i
LOCAL nCount
LOCAL cNext
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")
cCustomerId := "cus_FROM_BILLING_ACCOUNT"
// Remove status=open to show all invoice states.
oPageSuffix := CreateObject("Chilkat.StringBuilder")
nMore := 1
cCursor := ""
DO WHILE (nMore == 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"
oCmd:SetString('curl -X GET "https://api.stripe.com/v1/invoices?customer=@CUSTOMER@&status=open&limit=100@CURSOR@"')
oCmd:Append(' -u "@KEY@:"')
oCmd:Append(' -H "Stripe-Version: 2026-10-28.endive"')
nReplaced := oCmd:Replace("@CURSOR@", oPageSuffix:GetAsString())
nReplaced := oCmd:Replace("@CUSTOMER@", cCustomerId)
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()
oPageSuffix: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()
oPageSuffix:destroy()
RETURN
ENDIF
i := 0
nCount := oJson:SizeOfArray("data")
DO WHILE (i < nCount)
oJson:I := i
? oJson:StringOf("data[i].id") + " | " + oJson:StringOf("data[i].number") + " | " + oJson:StringOf("data[i].status") + " | " + oJson:StringOf("data[i].due_date") + " | " + oJson:StringOf("data[i].amount_remaining") + " | " + oJson:StringOf("data[i].currency") + " | " + oJson:StringOf("data[i].hosted_invoice_url") + " | " + oJson:StringOf("data[i].invoice_pdf")
i := i + 1
ENDDO
nMore := oJson:BoolOf("has_more")
IF (nMore == 1)
cNext := oJson:StringOf("data[i].id")
IF ((nCount < 1) .OR. (cNext == "") .OR. (cNext == cCursor))
? "Invalid pagination cursor."
oCurl:destroy()
oCmd:destroy()
oJson:destroy()
oPageSuffix:destroy()
RETURN
ENDIF
cCursor := cNext
oPageSuffix:SetString("&starting_after=")
oPageSuffix:Append(cCursor)
ENDIF
ENDDO
oCurl:destroy()
oCmd:destroy()
oJson:destroy()
oPageSuffix:destroy()