Xbase++ Requires Chilkat v11.7.0+
Xbase++
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 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 j
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"
oPageSuffix := CreateObject("Chilkat.StringBuilder")
nMore := 1
cCursor := ""
DO WHILE (nMore == 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"
oCmd:SetString('curl -X GET "https://api.stripe.com/v1/subscriptions?customer=@ID@&status=all&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("@ID@", 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].status")
j := 0
DO WHILE (j < oJson:SizeOfArray("data[i].items.data"))
oJson:J := j
? " Item " + oJson:StringOf("data[i].items.data[j].id") + " price " + oJson:StringOf("data[i].items.data[j].price.id") + " quantity " + oJson:StringOf("data[i].items.data[j].quantity")
j := j + 1
ENDDO
IF (oJson:BoolOf("data[i].items.has_more") == 1)
? "Additional items are available via /v1/subscription_items for this subscription."
ENDIF
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()