DataFlex Requires Chilkat v11.7.0+
DataFlex
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 DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
String sApiKey
Handle hoCurl
Handle hoCmd
Variant vJson
Handle hoJson
Integer iReplaced
String sFromTime
String sUntilTime
Handle hoLedger
Integer iOutputRow
Handle hoPageSuffix
Boolean iMore
String sCursor
Integer i
Integer iCount
String sNext
String sTemp1
Integer iTemp1
Move False To iSuccess
// Requires an unlocked Chilkat bundle. See Global Unlock Sample.
// Supply a restricted sandbox key from merchant-controlled configuration.
Move "YOUR_STRIPE_TEST_KEY" To sApiKey
Get Create (RefClass(cComChilkatHttpCurl)) To hoCurl
If (Not(IsComObjectCreated(hoCurl))) Begin
Send CreateComObject of hoCurl
End
Get Create (RefClass(cComChilkatStringBuilder)) To hoCmd
If (Not(IsComObjectCreated(hoCmd))) Begin
Send CreateComObject of hoCmd
End
Get Create (RefClass(cComChilkatJsonObject)) To hoJson
If (Not(IsComObjectCreated(hoJson))) Begin
Send CreateComObject of hoJson
End
// Example UTC interval: 1 October 2026 inclusive through 1 November exclusive.
Move "1790812800" To sFromTime
Move "1793491200" To sUntilTime
Get Create (RefClass(cComChilkatCsv)) To hoLedger
If (Not(IsComObjectCreated(hoLedger))) Begin
Send CreateComObject of hoLedger
End
Set ComHasColumnNames Of hoLedger To True
Move 0 To iOutputRow
Get ComSetColumnName Of hoLedger 0 "id" To iSuccess
Get ComSetColumnName Of hoLedger 1 "created" To iSuccess
Get ComSetColumnName Of hoLedger 2 "source" To iSuccess
Get ComSetColumnName Of hoLedger 3 "reporting_category" To iSuccess
Get ComSetColumnName Of hoLedger 4 "amount" To iSuccess
Get ComSetColumnName Of hoLedger 5 "fee" To iSuccess
Get ComSetColumnName Of hoLedger 6 "net" To iSuccess
Get ComSetColumnName Of hoLedger 7 "currency" To iSuccess
Get Create (RefClass(cComChilkatStringBuilder)) To hoPageSuffix
If (Not(IsComObjectCreated(hoPageSuffix))) Begin
Send CreateComObject of hoPageSuffix
End
Move True To iMore
Move "" To sCursor
While (iMore = True)
// 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"
Get ComSetString Of hoCmd 'curl -X GET "https://api.stripe.com/v1/balance_transactions?created%5Bgte%5D=@FROM@&created%5Blt%5D=@UNTIL@&limit=100@CURSOR@"' To iSuccess
Get ComAppend Of hoCmd ' -u "@KEY@:"' To iSuccess
Get ComAppend Of hoCmd ' -H "Stripe-Version: 2026-10-28.endive"' To iSuccess
Get ComGetAsString Of hoPageSuffix To sTemp1
Get ComReplace Of hoCmd "@CURSOR@" sTemp1 To iReplaced
Get ComReplace Of hoCmd "@FROM@" sFromTime To iReplaced
Get ComReplace Of hoCmd "@UNTIL@" sUntilTime To iReplaced
Get ComReplace Of hoCmd "@KEY@" sApiKey To iReplaced
Get ComGetAsString Of hoCmd To sTemp1
Get ComDoYourThing Of hoCurl sTemp1 To iSuccess
If (iSuccess <> True) Begin
Get ComFailReason Of hoCurl To iTemp1
Showln "No HTTP response. Chilkat failure code: " iTemp1
Procedure_Return
End
Get pvComObject of hoJson to vJson
Get ComGetResponseJson Of hoCurl vJson To iSuccess
Get ComStatusCode Of hoCurl To iTemp1
If ((iTemp1 <> 200) Or (iSuccess <> True)) Begin
Get ComStatusCode Of hoCurl To iTemp1
Get ComGetResponseHeaderField Of hoCurl "Request-Id" To sTemp1
Showln "Stripe HTTP " iTemp1 " Request-Id: " sTemp1
If (iSuccess = True) Begin
Get ComStringOf Of hoJson "error.message" To sTemp1
Showln sTemp1
End
Procedure_Return
End
Move 0 To i
Get ComSizeOfArray Of hoJson "data" To iCount
While (i < iCount)
Set ComI Of hoJson To i
Get ComStringOf Of hoJson "data[i].id" To sTemp1
Get ComSetCell Of hoLedger iOutputRow 0 sTemp1 To iSuccess
Get ComStringOf Of hoJson "data[i].created" To sTemp1
Get ComSetCell Of hoLedger iOutputRow 1 sTemp1 To iSuccess
Get ComStringOf Of hoJson "data[i].source" To sTemp1
Get ComSetCell Of hoLedger iOutputRow 2 sTemp1 To iSuccess
Get ComStringOf Of hoJson "data[i].reporting_category" To sTemp1
Get ComSetCell Of hoLedger iOutputRow 3 sTemp1 To iSuccess
Get ComStringOf Of hoJson "data[i].amount" To sTemp1
Get ComSetCell Of hoLedger iOutputRow 4 sTemp1 To iSuccess
Get ComStringOf Of hoJson "data[i].fee" To sTemp1
Get ComSetCell Of hoLedger iOutputRow 5 sTemp1 To iSuccess
Get ComStringOf Of hoJson "data[i].net" To sTemp1
Get ComSetCell Of hoLedger iOutputRow 6 sTemp1 To iSuccess
Get ComStringOf Of hoJson "data[i].currency" To sTemp1
Get ComSetCell Of hoLedger iOutputRow 7 sTemp1 To iSuccess
Move (iOutputRow + 1) To iOutputRow
Move (i + 1) To i
Loop
Get ComBoolOf Of hoJson "has_more" To iMore
If (iMore = True) Begin
Get ComStringOf Of hoJson "data[i].id" To sNext
If ((iCount < 1) Or (sNext = "") Or (sNext = sCursor)) Begin
Showln "Invalid pagination cursor."
Procedure_Return
End
Move sNext To sCursor
Get ComSetString Of hoPageSuffix "&starting_after=" To iSuccess
Get ComAppend Of hoPageSuffix sCursor To iSuccess
End
Loop
Get ComSaveFile Of hoLedger "stripe-balance-transactions.csv" To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoLedger To sTemp1
Showln sTemp1
Procedure_Return
End
Showln "Exported rows: " iOutputRow
End_Procedure