Pascal (Lazarus/Delphi)
Pascal (Lazarus/Delphi)
Adyen Verify Payment Result
See more Adyen Examples
Once a payment has completed, this verifies the result from your server with a /payments/result request.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.StringBuilder,
Chilkat.HttpResponse,
Chilkat.JsonObject;
// ---------------------------------------------------------------------------
procedure RunDemo;
var
success: Boolean;
http: THttp;
json: TJsonObject;
resp: THttpResponse;
sbResponseBody: TStringBuilder;
jResp: TJsonObject;
respStatusCode: Integer;
pspReference: string;
resultCode: string;
merchantReference: string;
paymentMethod: string;
shopperLocale: string;
begin
success := False;
http := THttp.Create;
// Use this online tool to generate the code from sample JSON:
// Generate Code to Create JSON
// The following JSON is sent in the request body.
// {
// "payload": "2he28Ddhwj242he28Ddhwj..."
// }
json := TJsonObject.Create;
json.UpdateString('payload','2he28Ddhwj242he28Ddhwj...');
http.SetRequestHeader('X-API-Key','Your_API_key');
resp := THttpResponse.Create;
success := http.HttpJson('POST','https://checkout-test.adyen.com/v41/payments/result',json,'application/json',resp);
if (success = False) then
begin
WriteLn(http.LastErrorText);
Exit;
end;
sbResponseBody := TStringBuilder.Create;
resp.GetBodySb(sbResponseBody);
jResp := TJsonObject.Create;
jResp.LoadSb(sbResponseBody);
jResp.EmitCompact := False;
respStatusCode := resp.StatusCode;
WriteLn('Status Code = ' + respStatusCode);
WriteLn('Response Body:');
WriteLn(jResp.Emit());
if (respStatusCode >= 400) then
begin
WriteLn('Response Header:');
WriteLn(resp.Header);
WriteLn('Failed.');
Exit;
end;
// Sample JSON response:
// {
// "pspReference": "851559480052382F",
// "resultCode": "Authorised",
// "merchantReference": "123",
// "paymentMethod": "ideal",
// "shopperLocale": "nl_NL"
// }
// Sample code for parsing the JSON response...
// Use the following online tool to generate parsing code from sample JSON:
// Generate Parsing Code from JSON
pspReference := jResp.StringOf('pspReference');
resultCode := jResp.StringOf('resultCode');
merchantReference := jResp.StringOf('merchantReference');
paymentMethod := jResp.StringOf('paymentMethod');
shopperLocale := jResp.StringOf('shopperLocale');
http.Free;
json.Free;
resp.Free;
sbResponseBody.Free;
jResp.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.