REST API Client Sample Code using Perl

Created by Richard Moore, Modified on Wed, 12 Apr 2023 at 12:02 PM by Richard Moore

use REST::Client;


my $client = REST::Client->new();

$client->addHeader('Content-Type', 'application/json');
$client->addHeader('charset', 'UTF-8');
$client->addHeader('Accept', 'application/json');

$req = '{
"gateway_id" : "A0001-99",
"password" : "abcdef",
"transaction_type" : "00",
"cc_number" : "4111111111111111",
"cc_expiry":"1019",
"amount":"20.75",
"cardholder_name": "Donald Duck"
}';

#If using a live account
#$url="https://api.e-xact.com/transaction";

#If using a demo account in the E-xact Demo Environment
$url="https://api.demo.e-xact.com/transaction";

$client->POST($url, $req);
print $client->responseContent();

#response headers may be gathered
print $client->responseHeader('ResponseHeader');

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select atleast one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article