Delphi ActiveX Stripe: Delete a Card

Back to Index

Deletes a customer credit card.

Documentation: https://stripe.com/docs/api/curl#delete_card

CURL Command

curl https://api.stripe.com/v1/customers/cus_CBbg3iRMzWBjoe/sources/card_1BnETKGswQrCoh0Xhu1A6BfL \
   -u STRIPE_SECRET_KEY: \
   -X DELETE

Delphi ActiveX Example

var
rest: TChilkatRest;
success: Integer;
bTls: Integer;
port: Integer;
bAutoReconnect: Integer;
sbResponseBody: TChilkatStringBuilder;
jsonResponse: TChilkatJsonObject;
deleted: Integer;
id: WideString;

begin
rest := TChilkatRest.Create(Self);

//  URL: https://api.stripe.com/v1/customers/cus_CBbg3iRMzWBjoe/sources/card_1BnETKGswQrCoh0Xhu1A6BfL
bTls := 1;
port := 443;
bAutoReconnect := 1;
success := rest.Connect('api.stripe.com',port,bTls,bAutoReconnect);
if (success <> 1) then
  begin
    Memo1.Lines.Add('ConnectFailReason: ' + IntToStr(rest.ConnectFailReason));
    Memo1.Lines.Add(rest.LastErrorText);
    Exit;
  end;

rest.SetAuthBasic('STRIPE_SECRET_KEY','');

sbResponseBody := TChilkatStringBuilder.Create(Self);
success := rest.FullRequestNoBodySb('DELETE','/v1/customers/cus_CBbg3iRMzWBjoe/sources/card_1BnETKGswQrCoh0Xhu1A6BfL',sbResponseBody.ControlInterface);
if (success <> 1) then
  begin
    Memo1.Lines.Add(rest.LastErrorText);
    Exit;
  end;

jsonResponse := TChilkatJsonObject.Create(Self);
jsonResponse.LoadSb(sbResponseBody.ControlInterface);

deleted := jsonResponse.BoolOf('deleted');
id := jsonResponse.StringOf('id');

Sample JSON Response Body

{
  "deleted": true,
  "id": "card_1BnETKGswQrCoh0Xhu1A6BfL"
}