Sample code for 30+ languages & platforms
Delphi DLL Requires Chilkat v11.7.0+

Stripe: Check where a refund stands

See more Stripe Examples

Read the current status of a saved refund, including the reason for a pending or failed refund when available.

Stripe documentation and cURL example

Chilkat Delphi DLL Downloads

Delphi DLL
var
success: Boolean;
apiKey: PWideChar;
curl: HCkHttpCurl;
cmd: HCkStringBuilder;
json: HCkJsonObject;
replaced: Integer;
refundId: 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();

refundId := 're_FROM_REFUND_RECORD';

//  curl -X GET "https://api.stripe.com/v1/refunds/{refundId}" \
//    -u "$STRIPE_API_KEY:" \
//    -H "Stripe-Version: 2026-10-28.endive"
CkStringBuilder_SetString(cmd,'curl -X GET "https://api.stripe.com/v1/refunds/@ID@"');
CkStringBuilder_Append(cmd,' -u "@KEY@:"');
CkStringBuilder_Append(cmd,' -H "Stripe-Version: 2026-10-28.endive"');
replaced := CkStringBuilder_Replace(cmd,'@ID@',refundId);
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;

Memo1.Lines.Add('id = ' + CkJsonObject__stringOf(json,'id'));
Memo1.Lines.Add('status = ' + CkJsonObject__stringOf(json,'status'));
Memo1.Lines.Add('amount = ' + CkJsonObject__stringOf(json,'amount'));
Memo1.Lines.Add('currency = ' + CkJsonObject__stringOf(json,'currency'));

if (CkJsonObject__stringOf(json,'status') = 'failed') then
  begin
    Memo1.Lines.Add('Failure reason: ' + CkJsonObject__stringOf(json,'failure_reason'));
  end;
if (CkJsonObject__stringOf(json,'status') = 'pending') then
  begin
    Memo1.Lines.Add('Pending reason: ' + CkJsonObject__stringOf(json,'pending_reason'));
  end;

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