Pascal (Lazarus/Delphi)
Pascal (Lazarus/Delphi)
PayPal PayFlowPro - Send Transaction to Server
See more HTTP Misc Examples
Sends a simple transaction to the Gateway server.Chilkat Pascal (Lazarus/Delphi) Downloads
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.Http,
Chilkat.HttpRequest,
Chilkat.HttpResponse;
// ---------------------------------------------------------------------------
procedure RunDemo;
var
success: Boolean;
http: THttp;
req: THttpRequest;
resp: THttpResponse;
begin
success := False;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http := THttp.Create;
// Implements the following CURL command:
// curl https://pilot-payflowpro.paypal.com -d PARTNER=PayPal -d VENDOR=zzz -d USER=zzz -d PWD=zzzzz -d TRXTYPE=S -d AMT=40 -d CREATESECURETOKEN=Y -d SECURETOKENID=XXXEFF0A-XXXX-4585-XXXX-B763B1F1XXXX
// Use the following online tool to generate HTTP code from a CURL command
// Convert a cURL Command to HTTP Source Code
req := THttpRequest.Create;
req.HttpVerb := 'POST';
req.Path := '/';
req.ContentType := 'application/x-www-form-urlencoded';
req.AddParam('PARTNER','PayPal');
req.AddParam('VENDOR','zzz');
req.AddParam('USER','zzz');
req.AddParam('PWD','zzzzz');
req.AddParam('TRXTYPE','S');
req.AddParam('AMT','40');
req.AddParam('CREATESECURETOKEN','Y');
req.AddParam('SECURETOKENID','XXXEFF0A-XXXX-4585-XXXX-B763B1F1XXXX');
resp := THttpResponse.Create;
success := http.HttpReq('https://pilot-payflowpro.paypal.com',req,resp);
if (success = False) then
begin
WriteLn(http.LastErrorText);
Exit;
end;
WriteLn('Status code: ' + resp.StatusCode);
WriteLn('Response body:');
WriteLn(resp.BodyStr);
http.Free;
req.Free;
resp.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.