Go Requires Chilkat v11.7.0+
Go
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 Go Downloads
success := false
// Requires an unlocked Chilkat bundle. See Global Unlock Sample.
// Supply a restricted sandbox key from merchant-controlled configuration.
apiKey := "YOUR_STRIPE_TEST_KEY"
curl := chilkat.NewHttpCurl()
cmd := chilkat.NewStringBuilder()
json := chilkat.NewJsonObject()
var replaced int
customerId := "cus_FROM_BILLING_ACCOUNT"
pageSuffix := chilkat.NewStringBuilder()
more := true
cursor := ""
for (more == true) {
// 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"
cmd.SetString("curl -X GET \"https://api.stripe.com/v1/subscriptions?customer=@ID@&status=all&limit=100@CURSOR@\"")
cmd.Append(" -u \"@KEY@:\"")
cmd.Append(" -H \"Stripe-Version: 2026-10-28.endive\"")
replaced = cmd.Replace("@CURSOR@",*pageSuffix.GetAsString())
replaced = cmd.Replace("@ID@",customerId)
replaced = cmd.Replace("@KEY@",apiKey)
success = curl.DoYourThing(*cmd.GetAsString())
if success != true {
fmt.Println("No HTTP response. Chilkat failure code: ", curl.FailReason())
curl.DisposeHttpCurl()
cmd.DisposeStringBuilder()
json.DisposeJsonObject()
pageSuffix.DisposeStringBuilder()
return
}
success = curl.GetResponseJson(json)
if (curl.StatusCode() != 200) || (success != true) {
fmt.Println("Stripe HTTP ", curl.StatusCode(), " Request-Id: ", *curl.GetResponseHeaderField("Request-Id"))
if success == true {
fmt.Println(*json.StringOf("error.message"))
}
curl.DisposeHttpCurl()
cmd.DisposeStringBuilder()
json.DisposeJsonObject()
pageSuffix.DisposeStringBuilder()
return
}
i := 0
count := json.SizeOfArray("data")
for (i < count) {
json.SetI(i)
fmt.Println(*json.StringOf("data[i].id"), " | ", *json.StringOf("data[i].status"))
j := 0
for (j < json.SizeOfArray("data[i].items.data")) {
json.SetJ(j)
fmt.Println(" Item ", *json.StringOf("data[i].items.data[j].id"), " price ", *json.StringOf("data[i].items.data[j].price.id"), " quantity ", *json.StringOf("data[i].items.data[j].quantity"))
j = j + 1
}
if json.BoolOf("data[i].items.has_more") == true {
fmt.Println("Additional items are available via /v1/subscription_items for this subscription.")
}
i = i + 1
}
more = json.BoolOf("has_more")
if more == true {
next := json.StringOf("data[i].id")
if (count < 1) || (*next == "") || (*next == cursor) {
fmt.Println("Invalid pagination cursor.")
curl.DisposeHttpCurl()
cmd.DisposeStringBuilder()
json.DisposeJsonObject()
pageSuffix.DisposeStringBuilder()
return
}
cursor = *next
pageSuffix.SetString("&starting_after=")
pageSuffix.Append(cursor)
}
}
curl.DisposeHttpCurl()
cmd.DisposeStringBuilder()
json.DisposeJsonObject()
pageSuffix.DisposeStringBuilder()