5 posts / 0 new
Last post
rohitrajagopal3538
Sample code for Events API

Requesting sample code to integrate and use Events API.


rohitrajagopal3538
Re: Sample code for Events API

Here is the example code in PHP:

<?php

$apiKey = "y6pWAJNyJyjGv66IsVuWnklkKUPFbb0a";
$apiSecret = "86fbae7030253af3cd15faef2a1f4b67353e41fb6799f576b5093ae52901e6f7";
$token = "fdoa-a480ce8951daa73262734cf102641994c1e55e7cdf4c02b6";
$nonce = strval(hexdec(bin2hex(openssl_random_pseudo_bytes(4, $cstrong))));
$timestamp = strval(time()*1000); //time stamp in milli seconds

echo "apiKey: ".$apiKey."<br>";
echo "apiSecret: ".$apiSecret."<br>";
echo "token: ".$token."<br>";
echo "nonce: ".$nonce."<br>";
echo "timestamp: ".$timestamp."<br>";

$payload = ""; 

$data = $apiKey . $nonce . $timestamp . $token . $payload;

$hashAlgorithm = "sha256";

### Make sure the HMAC hash is in hex -->
$hmac = hash_hmac ( $hashAlgorithm , $data , $apiSecret, false );

### Authorization : base64 of hmac hash -->
$hmac_enc = base64_encode($hmac);

echo 'Hmac: '.$hmac_enc;

$curl = curl_init('https://api-cert.payeezy.com/v1/events?eventType=TRANSACTION_STATUS&from=2015-04-20&to=2015-09-30&offset=0&limit=10');

$headers = array(
      'Content-Type: application/json',
      'apikey:'.strval($apiKey),
      'token:'.strval($token),
      'Authorization:'.$hmac_enc,
      'nonce:'.$nonce,
      'timestamp:'.$timestamp,
    );

echo 'Headers: '; var_dump($headers);

curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

curl_setopt($curl, CURLOPT_VERBOSE, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);

$json_response = curl_exec($curl);

echo "<br><br> " ;

$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
echo($status);
$response = json_decode($json_response, true);

if ( $status != 200 ) {
die("Error: call to URL $serviceURL failed with status $status, response $json_response, curl_error " . curl_error($curl) . ", curl_errno " . curl_errno($curl));
}

curl_close($curl);

echo "Response is: ".$response."\n";
echo "JSON response is: ".$json_response."\n";

?>


kartyekk14698
Re: Sample code for Events API

Requesting c# sample code to integrate Events API for verification of transaction details.


christopherlord730
Re: Sample code for Events API

Unfortunately we do not have any published C# sample code for the event search API. I apologize for the inconvenience.


christopherlord730
Re: Sample code for Events API

Unfortunately there is no published C# code for the event search API.