Sample code for 30+ languages & platforms
Delphi DLL 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 Delphi DLL Downloads

Delphi DLL
var
success: Boolean;
apiKey: PWideChar;
curl: HCkHttpCurl;
cmd: HCkStringBuilder;
json: HCkJsonObject;
replaced: Integer;
customerId: PWideChar;
pageSuffix: HCkStringBuilder;
more: Boolean;
cursor: PWideChar;
i: Integer;
count: Integer;
j: Integer;
next: PWideChar;

begin
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 := CkHttpCurl_Create();
cmd := CkStringBuilder_Create();
json := CkJsonObject_Create();

customerId := 'cus_FROM_BILLING_ACCOUNT';

pageSuffix := CkStringBuilder_Create();
more := True;
cursor := '';
while (more = True) do
  begin
    //  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"
    CkStringBuilder_SetString(cmd,'curl -X GET "https://api.stripe.com/v1/subscriptions?customer=@ID@&status=all&limit=100@CURSOR@"');
    CkStringBuilder_Append(cmd,' -u "@KEY@:"');
    CkStringBuilder_Append(cmd,' -H "Stripe-Version: 2026-10-28.endive"');
    replaced := CkStringBuilder_Replace(cmd,'@CURSOR@',CkStringBuilder__getAsString(pageSuffix));
    replaced := CkStringBuilder_Replace(cmd,'@ID@',customerId);
    replaced := CkStringBuilder_Replace(cmd,'@KEY@',apiKey);
    success := CkHttpCurl_DoYourThing(curl,CkStringBuilder__getAsString(cmd));
    if (success <> True) then
      begin
        Memo1.Lines.Add('No HTTP response. Chilkat failure code: ' + IntToStr(CkHttpCurl_getFailReason(curl)));
        Exit;
      end;
    success := CkHttpCurl_GetResponseJson(curl,json);
    if ((CkHttpCurl_getStatusCode(curl) <> 200) or (success <> True)) then
      begin
        Memo1.Lines.Add('Stripe HTTP ' + IntToStr(CkHttpCurl_getStatusCode(curl)) + '  Request-Id: ' + CkHttpCurl__getResponseHeaderField(curl,'Request-Id'));
        if (success = True) then
          begin
            Memo1.Lines.Add(CkJsonObject__stringOf(json,'error.message'));
          end;
        Exit;
      end;

    i := 0;
    count := CkJsonObject_SizeOfArray(json,'data');
    while (i < count) do
      begin
        CkJsonObject_putI(json,i);
        Memo1.Lines.Add(CkJsonObject__stringOf(json,'data[i].id') + ' | ' + CkJsonObject__stringOf(json,'data[i].status'));
        j := 0;
        while (j < CkJsonObject_SizeOfArray(json,'data[i].items.data')) do
          begin
            CkJsonObject_putJ(json,j);
            Memo1.Lines.Add('  Item ' + CkJsonObject__stringOf(json,'data[i].items.data[j].id') + '  price ' + CkJsonObject__stringOf(json,'data[i].items.data[j].price.id')
                 + '  quantity ' + CkJsonObject__stringOf(json,'data[i].items.data[j].quantity'));
            j := j + 1;
          end;

        if (CkJsonObject_BoolOf(json,'data[i].items.has_more') = True) then
          begin
            Memo1.Lines.Add('Additional items are available via /v1/subscription_items for this subscription.');
          end;
        i := i + 1;
      end;

    more := CkJsonObject_BoolOf(json,'has_more');
    if (more = True) then
      begin
        next := CkJsonObject__stringOf(json,'data[i].id');
        if ((count < 1) or (next = '') or (next = cursor)) then
          begin
            Memo1.Lines.Add('Invalid pagination cursor.');
            Exit;
          end;
        cursor := next;
        CkStringBuilder_SetString(pageSuffix,'&starting_after=');
        CkStringBuilder_Append(pageSuffix,cursor);
      end;
  end;

CkHttpCurl_Dispose(curl);
CkStringBuilder_Dispose(cmd);
CkJsonObject_Dispose(json);
CkStringBuilder_Dispose(pageSuffix);