Sample code for 30+ languages & platforms
Pascal (Lazarus/Delphi)

CardConnect Delete Profile

See more CardConnect Examples

Demonstrates how to delete a profile.
A DELETE request to the profile endpoint deletes the stored data for the specified profile ID. ...

See https://developer.cardconnect.com/cardconnect-api?lang=json#delete-profile-request

Chilkat Pascal (Lazarus/Delphi) Downloads

Pascal (Lazarus/Delphi)
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.JsonObject,
  Chilkat.Http;

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

procedure RunDemo;
var
  success: Boolean;
  http: THttp;
  url: string;
  responseStr: string;
  jsonResp: TJsonObject;

begin
  success := False;

  //  This example assumes the Chilkat API to have been previously unlocked.
  //  See Global Unlock Sample for sample code.

  http := THttp.Create;

  http.BasicAuth := True;
  http.Login := 'API_USERNAME';
  http.Password := 'API_PASSWORD';

  url := 'https://<site>.cardconnect.com:<port>/cardconnect/rest/profile/<profile ID>/<account ID>/<merchid>';
  responseStr := http.QuickDeleteStr(url);
  if (http.LastMethodSuccess = False) then
    begin
      WriteLn(http.LastErrorText);
      Exit;
    end;

  //  A response status of 200 indicates potential success.  The JSON response body
  //  must be examined to determine if it was truly successful or an error.
  WriteLn('response status code = ' + http.LastStatus);

  jsonResp := TJsonObject.Create;
  jsonResp.Load(responseStr);
  jsonResp.EmitCompact := False;

  WriteLn('response JSON:');
  WriteLn(jsonResp.Emit());

  //  A successful response looks like this:

  //  {
  //    "respproc": "PPS",
  //    "resptext": "Profile Deleted",
  //    "respstat": "A",
  //    "respcode": "08"
  //  }
  //  
  //  


  http.Free;
  jsonResp.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.