Delphi ActiveX Stripe: Delete a Customer Discount

Back to Index

Removes the currently applied discount on a customer.

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

CURL Command

curl https://api.stripe.com/v1/customers/cus_CBbg9PmQ9sLbmo/discount \
   -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_CBbg9PmQ9sLbmo/discount
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_CBbg9PmQ9sLbmo/discount',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": "di_1BnETLGswQrCoh0Xe991uMc7"
}