PowerBuilder Requires Chilkat v11.7.0+
PowerBuilder
Stripe: Export a period of account activity
See more Stripe Examples
Export account activity for a UTC date range to CSV, including transaction references, fees, net amounts, and currencies.
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_FromTime
string ls_UntilTime
oleobject loo_Ledger
long li_OutputRow
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")
// Example UTC interval: 1 October 2026 inclusive through 1 November exclusive.
ls_FromTime = "1790812800"
ls_UntilTime = "1793491200"
loo_Ledger = create oleobject
li_rc = loo_Ledger.ConnectToNewObject("Chilkat.Csv")
loo_Ledger.HasColumnNames = 1
li_OutputRow = 0
loo_Ledger.SetColumnName(0,"id")
loo_Ledger.SetColumnName(1,"created")
loo_Ledger.SetColumnName(2,"source")
loo_Ledger.SetColumnName(3,"reporting_category")
loo_Ledger.SetColumnName(4,"amount")
loo_Ledger.SetColumnName(5,"fee")
loo_Ledger.SetColumnName(6,"net")
loo_Ledger.SetColumnName(7,"currency")
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/balance_transactions?created%5Bgte%5D={fromTime}&created%5Blt%5D={untilTime}&limit=100" \
// -u "$STRIPE_API_KEY:" \
// -H "Stripe-Version: 2026-10-28.endive"
loo_Cmd.SetString("curl -X GET ~"https://api.stripe.com/v1/balance_transactions?created%5Bgte%5D=@FROM@&created%5Blt%5D=@UNTIL@&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("@FROM@",ls_FromTime)
li_Replaced = loo_Cmd.Replace("@UNTIL@",ls_UntilTime)
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_Ledger
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_Ledger
destroy loo_PageSuffix
return
end if
i = 0
li_Count = loo_Json.SizeOfArray("data")
do while (i < li_Count)
loo_Json.I = i
loo_Ledger.SetCell(li_OutputRow,0,loo_Json.StringOf("data[i].id"))
loo_Ledger.SetCell(li_OutputRow,1,loo_Json.StringOf("data[i].created"))
loo_Ledger.SetCell(li_OutputRow,2,loo_Json.StringOf("data[i].source"))
loo_Ledger.SetCell(li_OutputRow,3,loo_Json.StringOf("data[i].reporting_category"))
loo_Ledger.SetCell(li_OutputRow,4,loo_Json.StringOf("data[i].amount"))
loo_Ledger.SetCell(li_OutputRow,5,loo_Json.StringOf("data[i].fee"))
loo_Ledger.SetCell(li_OutputRow,6,loo_Json.StringOf("data[i].net"))
loo_Ledger.SetCell(li_OutputRow,7,loo_Json.StringOf("data[i].currency"))
li_OutputRow = li_OutputRow + 1
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_Ledger
destroy loo_PageSuffix
return
end if
ls_Cursor = ls_Next
loo_PageSuffix.SetString("&starting_after=")
loo_PageSuffix.Append(ls_Cursor)
end if
loop
li_Success = loo_Ledger.SaveFile("stripe-balance-transactions.csv")
if li_Success = 0 then
Write-Debug loo_Ledger.LastErrorText
destroy loo_Curl
destroy loo_Cmd
destroy loo_Json
destroy loo_Ledger
destroy loo_PageSuffix
return
end if
Write-Debug "Exported rows: " + string(li_OutputRow)
destroy loo_Curl
destroy loo_Cmd
destroy loo_Json
destroy loo_Ledger
destroy loo_PageSuffix