Perl Requires Chilkat v11.0.0+
Perl
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 Perl Downloads
use strict;
use warnings;
use Chilkat2;
my $http = Chilkat2::Http->new;
# 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..."
# }
my $json = Chilkat2::JsonObject->new;
$json->UpdateString('payload', '2he28Ddhwj242he28Ddhwj...');
$http->SetRequestHeader('X-API-Key', 'Your_API_key');
my $resp = Chilkat2::HttpResponse->new;
my $success = $http->HttpJson('POST', 'https://checkout-test.adyen.com/v41/payments/result', $json, 'application/json', $resp);
if (!$success) {
print $http->LastErrorText, "\n";
exit;
}
my $sbResponseBody = Chilkat2::StringBuilder->new;
$resp->GetBodySb($sbResponseBody);
my $jResp = Chilkat2::JsonObject->new;
$jResp->LoadSb($sbResponseBody);
$jResp->EmitCompact(0);
my $respStatusCode = $resp->StatusCode;
print 'Status Code = ', $respStatusCode, "\n";
print "Response Body:\n";
print $jResp->Emit(), "\n";
if ($respStatusCode >= 400) {
print "Response Header:\n";
print $resp->Header, "\n";
print "Failed.\n";
exit;
}
# 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
my $pspReference = $jResp->StringOf('pspReference');
my $resultCode = $jResp->StringOf('resultCode');
my $merchantReference = $jResp->StringOf('merchantReference');
my $paymentMethod = $jResp->StringOf('paymentMethod');
my $shopperLocale = $jResp->StringOf('shopperLocale');