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

Stripe: Review a customer's subscriptions

See more Stripe Examples

List a customer's subscriptions and inspect their items, prices, and seat counts.

Stripe documentation and cURL example

Chilkat Visual FoxPro Downloads

Visual FoxPro
LOCAL lnSuccess
LOCAL lcApiKey
LOCAL loCurl
LOCAL loCmd
LOCAL loJson
LOCAL lnReplaced
LOCAL lcCustomerId
LOCAL loPageSuffix
LOCAL lnMore
LOCAL lcCursor
LOCAL i
LOCAL lnCount
LOCAL j
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')

lcCustomerId = "cus_FROM_BILLING_ACCOUNT"

loPageSuffix = CreateObject('Chilkat.StringBuilder')
lnMore = 1
lcCursor = ""
DO WHILE (lnMore = 1)
    *  curl -X GET "https://api.stripe.com/v1/subscriptions?customer={customerId}&status=all&limit=100" \
    *    -u "$STRIPE_API_KEY:" \
    *    -H "Stripe-Version: 2026-10-28.endive"
    loCmd.SetString('curl -X GET "https://api.stripe.com/v1/subscriptions?customer=@ID@&status=all&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("@ID@",lcCustomerId)
    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 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 loPageSuffix
        CANCEL
    ENDIF

    i = 0
    lnCount = loJson.SizeOfArray("data")
    DO WHILE (i < lnCount)
        loJson.I = i
        ? loJson.StringOf("data[i].id") + " | " + loJson.StringOf("data[i].status")
        j = 0
        DO WHILE (j < loJson.SizeOfArray("data[i].items.data"))
            loJson.J = j
            ? "  Item " + loJson.StringOf("data[i].items.data[j].id") + "  price " + loJson.StringOf("data[i].items.data[j].price.id") + "  quantity " + loJson.StringOf("data[i].items.data[j].quantity")
            j = j + 1
        ENDDO
        IF (loJson.BoolOf("data[i].items.has_more") = 1) THEN
            ? "Additional items are available via /v1/subscription_items for this subscription."
        ENDIF

        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 loPageSuffix
            CANCEL
        ENDIF

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

ENDDO

RELEASE loCurl
RELEASE loCmd
RELEASE loJson
RELEASE loPageSuffix