Delphi DLL Requires Chilkat v11.7.0+
Delphi DLL
Stripe: Find customer records by billing email
See more Stripe Examples
Find all customers with a given billing email, including addresses with a plus sign. Display the internal account reference so the operator can select the right record.
Stripe documentation and cURL example
Chilkat Delphi DLL Downloads
var
success: Boolean;
apiKey: PWideChar;
curl: HCkHttpCurl;
cmd: HCkStringBuilder;
json: HCkJsonObject;
replaced: Integer;
email: HCkStringBuilder;
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();
email := CkStringBuilder_Create();
CkStringBuilder_SetString(email,'billing+east@example.com');
// Show every match so the operator can check the internal account reference.
pageSuffix := CkStringBuilder_Create();
more := True;
cursor := '';
while (more = True) do
begin
// curl -X GET "https://api.stripe.com/v1/customers?email={email}&limit=100" \
// -u "$STRIPE_API_KEY:" \
// -H "Stripe-Version: 2026-10-28.endive"
CkStringBuilder_SetString(cmd,'curl -X GET "https://api.stripe.com/v1/customers?email=@EMAIL@&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,'@EMAIL@',CkStringBuilder__getEncoded(email,'url_rfc3986','utf-8'));
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].name') + ' | ' + CkJsonObject__stringOf(json,'data[i].email')
+ ' | ' + CkJsonObject__stringOf(json,'data[i].metadata.account_ref'));
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(email);
CkStringBuilder_Dispose(pageSuffix);