I’m working on getting PayEezy working and running into probably what’s a stupid programmer trick on my part.
Using the values given at https://developer.payeezy.com/creditcardpayment/apis/post/transactions to generate an HMAC hash. They generate some test values on their website and the point is that whatever I generate should match theirs. Otherwise, a transaction fails.
[code]//These values are constant
dim apiKey as string = “y6pWAJNyJyjGv66IsVuWnklkKUPFbb0a”
dim token as string = “fdoa-a480ce8951daa73262734cf102641994c1e55e7cdf4c02b6”
//This value changes every 5 minutes
dim APISecret as string = “86fbae7030253af3cd15faef2a1f4b67353e41fb6799f576b5093ae52901e6f7”
//These values change constantly but they list them for testing purposes.
dim nonce as string = “9816090227570385000”
dim timestamp as string = “1446828246216”
dim message as string = apiKey +nonce + timestamp + token + kTestpayload
//Xojo
Dim result As String = Crypto.HMAC(APISecret, message, Crypto.Algorithm.SHA256)
dim sHexResult as string = EncodeHex(result.trim)
dim sReturn as string = EncodeBase64(sHexResult.trim)
//From their test website
dim sReturnAuthorization as string = “Y2YwMDMzNWYyZjZkNThmZmM5NDU3ZTkyMDVhYjFiZDZjZmFjODE2MDJmZWE4OTI3MTgyZGJhYzYxMWEwZjM2Yg==”
if sReturn <> sReturnAuthorization then
break
end[/code]
Yet my sReturn value is “Q0YwMDMzNUYyRjZENThGRkM5NDU3RTkyMDVBQjFCRDZDRkFDODE2MDJGRUE4OTI3MTgyREJBQzYx
MUEwRjM2Qg==” Yes, there’s a line break in there.
Their example php code is:
[code]<?php
$apiKey = “”;
$apiSecret = “”;
$nonce = “”;
$timestamp = “”;
$token = “”;
$payload = “<For POST - Request body / For GET - empty string>”;
$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 -->
$authorization = base64_encode($hmac);
ehco $authorization;
?>[/code]
As far as I can see I have the equivalent code. Any ideas on where I might be going wrong?