Sample code for 30+ languages & platforms
Lazarus Pascal Requires Chilkat v11.7.0+

Stripe: Find a catalog price by its lookup key

See more Stripe Examples

Retrieve an active price by its catalog lookup key and read its price ID, currency, amount, and billing type.

Stripe documentation and cURL example

Chilkat Lazarus Pascal Downloads

Lazarus Pascal
program ChilkatDemo;

// Demonstrates using the Chilkat Pascal wrapper via the C bridge DLL.
// Builds as a console application under Lazarus (FPC) or Delphi.

{$IFDEF FPC}
  {$MODE DELPHI}
{$ENDIF}
{$APPTYPE CONSOLE}

uses
  {$IFDEF UNIX}
  cthreads,
  {$ENDIF}
  SysUtils,
  CkDllLoader,
  Chilkat.HttpCurl,
  Chilkat.StringBuilder,
  Chilkat.JsonObject;

// ---------------------------------------------------------------------------

procedure RunDemo;
var
  success: Boolean;
  apiKey: string;
  curl: THttpCurl;
  cmd: TStringBuilder;
  json: TJsonObject;
  replaced: Integer;
  lookupKey: TStringBuilder;

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 := THttpCurl.Create;
  cmd := TStringBuilder.Create;
  json := TJsonObject.Create;

  lookupKey := TStringBuilder.Create;
  lookupKey.SetString('support_monthly_usd');

  //  curl -X GET "https://api.stripe.com/v1/prices?active=true&lookup_keys%5B%5D={lookupKey}&limit=2" \
  //    -u "$STRIPE_API_KEY:" \
  //    -H "Stripe-Version: 2026-10-28.endive"
  cmd.SetString('curl -X GET "https://api.stripe.com/v1/prices?active=true&lookup_keys%5B%5D=@LOOKUP@&limit=2"');
  cmd.Append(' -u "@KEY@:"');
  cmd.Append(' -H "Stripe-Version: 2026-10-28.endive"');
  replaced := cmd.Replace('@LOOKUP@',lookupKey.GetEncoded('url_rfc3986','utf-8'));
  replaced := cmd.Replace('@KEY@',apiKey);
  success := curl.DoYourThing(cmd.GetAsString());
  if (success <> True) then
    begin
      WriteLn('No HTTP response. Chilkat failure code: ' + curl.FailReason);
      Exit;
    end;
  success := curl.GetResponseJson(json);
  if ((curl.StatusCode <> 200) or (success <> True)) then
    begin
      WriteLn('Stripe HTTP ' + curl.StatusCode + '  Request-Id: ' + curl.GetResponseHeaderField('Request-Id'));
      if (success = True) then
        begin
          WriteLn(json.StringOf('error.message'));
        end;
      Exit;
    end;

  if ((json.SizeOfArray('data') <> 1) or (json.BoolOf('has_more') = True)) then
    begin
      WriteLn('Expected one active price for this lookup key.');
      Exit;
    end;

  WriteLn('id = ' + json.StringOf('data[0].id'));
  WriteLn('lookup_key = ' + json.StringOf('data[0].lookup_key'));
  WriteLn('currency = ' + json.StringOf('data[0].currency'));
  WriteLn('unit_amount_decimal = ' + json.StringOf('data[0].unit_amount_decimal'));
  WriteLn('type = ' + json.StringOf('data[0].type'));


  curl.Free;
  cmd.Free;
  json.Free;
  lookupKey.Free;

end;

// ---------------------------------------------------------------------------

begin

  try
    RunDemo;
  except
    on E: Exception do
      WriteLn('Unhandled exception: ', E.ClassName, ': ', E.Message);
  end;

  WriteLn;
  {$IFDEF MSWINDOWS}
  WriteLn('Press Enter to exit...');
  ReadLn;
  {$ENDIF}
end.