Sample code for 30+ languages & platforms
Visual FoxPro Requires Chilkat v11.7.0+

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 Visual FoxPro Downloads

Visual FoxPro
LOCAL lnSuccess
LOCAL lcApiKey
LOCAL loCurl
LOCAL loCmd
LOCAL loJson
LOCAL lnReplaced
LOCAL lcFromTime
LOCAL lcUntilTime
LOCAL loLedger
LOCAL lnOutputRow
LOCAL loPageSuffix
LOCAL lnMore
LOCAL lcCursor
LOCAL i
LOCAL lnCount
LOCAL lcNext

lnSuccess = 0

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

loCurl = CreateObject('Chilkat.HttpCurl')
loCmd = CreateObject('Chilkat.StringBuilder')
loJson = CreateObject('Chilkat.JsonObject')

*  Example UTC interval: 1 October 2026 inclusive through 1 November exclusive.
lcFromTime = "1790812800"
lcUntilTime = "1793491200"

loLedger = CreateObject('Chilkat.Csv')
loLedger.HasColumnNames = 1
lnOutputRow = 0
loLedger.SetColumnName(0,"id")
loLedger.SetColumnName(1,"created")
loLedger.SetColumnName(2,"source")
loLedger.SetColumnName(3,"reporting_category")
loLedger.SetColumnName(4,"amount")
loLedger.SetColumnName(5,"fee")
loLedger.SetColumnName(6,"net")
loLedger.SetColumnName(7,"currency")

loPageSuffix = CreateObject('Chilkat.StringBuilder')
lnMore = 1
lcCursor = ""
DO WHILE (lnMore = 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"
    loCmd.SetString('curl -X GET "https://api.stripe.com/v1/balance_transactions?created%5Bgte%5D=@FROM@&created%5Blt%5D=@UNTIL@&limit=100@CURSOR@"')
    loCmd.Append(' -u "@KEY@:"')
    loCmd.Append(' -H "Stripe-Version: 2026-10-28.endive"')
    lnReplaced = loCmd.Replace("@CURSOR@",loPageSuffix.GetAsString())
    lnReplaced = loCmd.Replace("@FROM@",lcFromTime)
    lnReplaced = loCmd.Replace("@UNTIL@",lcUntilTime)
    lnReplaced = loCmd.Replace("@KEY@",lcApiKey)
    lnSuccess = loCurl.DoYourThing(loCmd.GetAsString())
    IF (lnSuccess <> 1) THEN
        ? "No HTTP response. Chilkat failure code: " + STR(loCurl.FailReason)
        RELEASE loCurl
        RELEASE loCmd
        RELEASE loJson
        RELEASE loLedger
        RELEASE loPageSuffix
        CANCEL
    ENDIF

    lnSuccess = loCurl.GetResponseJson(loJson)
    IF ((loCurl.StatusCode <> 200) OR (lnSuccess <> 1)) THEN
        ? "Stripe HTTP " + STR(loCurl.StatusCode) + "  Request-Id: " + loCurl.GetResponseHeaderField("Request-Id")
        IF (lnSuccess = 1) THEN
            ? loJson.StringOf("error.message")
        ENDIF

        RELEASE loCurl
        RELEASE loCmd
        RELEASE loJson
        RELEASE loLedger
        RELEASE loPageSuffix
        CANCEL
    ENDIF

    i = 0
    lnCount = loJson.SizeOfArray("data")
    DO WHILE (i < lnCount)
        loJson.I = i
        loLedger.SetCell(lnOutputRow,0,loJson.StringOf("data[i].id"))
        loLedger.SetCell(lnOutputRow,1,loJson.StringOf("data[i].created"))
        loLedger.SetCell(lnOutputRow,2,loJson.StringOf("data[i].source"))
        loLedger.SetCell(lnOutputRow,3,loJson.StringOf("data[i].reporting_category"))
        loLedger.SetCell(lnOutputRow,4,loJson.StringOf("data[i].amount"))
        loLedger.SetCell(lnOutputRow,5,loJson.StringOf("data[i].fee"))
        loLedger.SetCell(lnOutputRow,6,loJson.StringOf("data[i].net"))
        loLedger.SetCell(lnOutputRow,7,loJson.StringOf("data[i].currency"))
        lnOutputRow = lnOutputRow + 1
        i = i + 1
    ENDDO
    lnMore = loJson.BoolOf("has_more")
    IF (lnMore = 1) THEN
        lcNext = loJson.StringOf("data[i].id")
        IF ((lnCount < 1) OR (lcNext = "") OR (lcNext = lcCursor)) THEN
            ? "Invalid pagination cursor."
            RELEASE loCurl
            RELEASE loCmd
            RELEASE loJson
            RELEASE loLedger
            RELEASE loPageSuffix
            CANCEL
        ENDIF

        lcCursor = lcNext
        loPageSuffix.SetString("&starting_after=")
        loPageSuffix.Append(lcCursor)
    ENDIF

ENDDO

lnSuccess = loLedger.SaveFile("stripe-balance-transactions.csv")
IF (lnSuccess = 0) THEN
    ? loLedger.LastErrorText
    RELEASE loCurl
    RELEASE loCmd
    RELEASE loJson
    RELEASE loLedger
    RELEASE loPageSuffix
    CANCEL
ENDIF

? "Exported rows: " + STR(lnOutputRow)

RELEASE loCurl
RELEASE loCmd
RELEASE loJson
RELEASE loLedger
RELEASE loPageSuffix