Unicode C++ Requires Chilkat v11.7.0+
Unicode C++
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 Unicode C++ Downloads
#include <CkHttpCurlW.h>
#include <CkStringBuilderW.h>
#include <CkJsonObjectW.h>
void ChilkatSample(void)
{
bool success = false;
// Requires an unlocked Chilkat bundle. See Global Unlock Sample.
// Supply a restricted sandbox key from merchant-controlled configuration.
const wchar_t *apiKey = L"YOUR_STRIPE_TEST_KEY";
CkHttpCurlW curl;
CkStringBuilderW cmd;
CkJsonObjectW json;
int replaced;
const wchar_t *customerId = L"cus_FROM_BILLING_ACCOUNT";
CkStringBuilderW pageSuffix;
bool more = true;
const wchar_t *cursor = L"";
while ((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(L"curl -X GET \"https://api.stripe.com/v1/subscriptions?customer=@ID@&status=all&limit=100@CURSOR@\"");
cmd.Append(L" -u \"@KEY@:\"");
cmd.Append(L" -H \"Stripe-Version: 2026-10-28.endive\"");
replaced = cmd.Replace(L"@CURSOR@",pageSuffix.getAsString());
replaced = cmd.Replace(L"@ID@",customerId);
replaced = cmd.Replace(L"@KEY@",apiKey);
success = curl.DoYourThing(cmd.getAsString());
if (success != true) {
wprintf(L"No HTTP response. Chilkat failure code: %d\n",curl.get_FailReason());
return;
}
success = curl.GetResponseJson(json);
if ((curl.get_StatusCode() != 200) || (success != true)) {
wprintf(L"Stripe HTTP %d Request-Id: %s\n",curl.get_StatusCode(),curl.getResponseHeaderField(L"Request-Id"));
if (success == true) {
wprintf(L"%s\n",json.stringOf(L"error.message"));
}
return;
}
int i = 0;
int count = json.SizeOfArray(L"data");
while ((i < count)) {
json.put_I(i);
wprintf(L"%s | %s\n",json.stringOf(L"data[i].id"),json.stringOf(L"data[i].status"));
int j = 0;
while ((j < json.SizeOfArray(L"data[i].items.data"))) {
json.put_J(j);
wprintf(L" Item %s price %s quantity %s\n",json.stringOf(L"data[i].items.data[j].id"),json.stringOf(L"data[i].items.data[j].price.id"),json.stringOf(L"data[i].items.data[j].quantity"));
j = j + 1;
}
if (json.BoolOf(L"data[i].items.has_more") == true) {
wprintf(L"Additional items are available via /v1/subscription_items for this subscription.\n");
}
i = i + 1;
}
more = json.BoolOf(L"has_more");
if (more == true) {
const wchar_t *next = json.stringOf(L"data[i].id");
if ((count < 1) || (next == L"") || (next == cursor)) {
wprintf(L"Invalid pagination cursor.\n");
return;
}
cursor = next;
pageSuffix.SetString(L"&starting_after=");
pageSuffix.Append(cursor);
}
}
}