Delphi DLL Requires Chilkat v11.7.0+
Delphi DLL
Stripe: Review invoices and outstanding amounts
See more Stripe Examples
List open invoices for a billing account and show outstanding amounts, due dates, and invoice links.
Stripe documentation and cURL example
Chilkat Delphi DLL Downloads
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;
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';
// Remove status=open to show all invoice states.
pageSuffix := CkStringBuilder_Create();
more := True;
cursor := '';
while (more = True) do
begin
// curl -X GET "https://api.stripe.com/v1/invoices?customer={customerId}&status=open&limit=100" \
// -u "$STRIPE_API_KEY:" \
// -H "Stripe-Version: 2026-10-28.endive"
CkStringBuilder_SetString(cmd,'curl -X GET "https://api.stripe.com/v1/invoices?customer=@CUSTOMER@&status=open&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,'@CUSTOMER@',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].number') + ' | ' + CkJsonObject__stringOf(json,'data[i].status')
+ ' | ' + CkJsonObject__stringOf(json,'data[i].due_date') + ' | ' + CkJsonObject__stringOf(json,'data[i].amount_remaining') + ' | ' + CkJsonObject__stringOf(json,'data[i].currency')
+ ' | ' + CkJsonObject__stringOf(json,'data[i].hosted_invoice_url') + ' | ' + CkJsonObject__stringOf(json,'data[i].invoice_pdf'));
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);