2 posts / 0 new
Last post
500 internal server error on refund call

I am trying to call refund API but getting 500 internal server error. however my create payment call is working fine. I am using asp.net with c# for integration. I have try with XML request using their web interface but getting same problem on it as well. Moreover, It mentioned that it returns 500 internal server error while problem at Payeezy end through want to see if anyone have any idea or Please find my code below if anyone can help.

protected void btnRefund_Click(object sender, EventArgs e)

public void Refund()
var builder = new StringBuilder("{ " +
"\"merchant_ref\": \"Acme Sock\", " +
"\"transaction_tag\": \"56289413\", " +
"\"transaction_type\": \"refund\", " +
"\"method\": \"credit_card\", " +
"\"amount\": \"1299\", " +
"\"currency_code\": \"USD\"" +
var payload = builder.ToString();
byte[] byteArray = Encoding.UTF8.GetBytes(payload);
var apiKey = "EgZd4ypWLNwFDmDzkLxmuLpgMXXuqQJd";
var timeStamp = ((long)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalMilliseconds).ToString(CultureInfo.InvariantCulture);
var nonce = (10000000000000000000 * new Random(DateTime.Now.Millisecond).NextDouble()).ToString("0000000000000000000");
var merchantToken = "fdoa-a480ce8951daa73262734cf102641994c1e55e7cdf4c02b6";
var secretKey = "2f5ccd1357d656d50c33ac60afc1fb5b0299783b69931f0602881621aeb3f0ba";

var post = (HttpWebRequest)HttpWebRequest.Create("https://api-cert.payeezy.com/v1/transactions/ET124595");
post.Method = "POST";
post.KeepAlive = true;
post.Accept = "*/*";
post.Headers.Add("Accept-Encoding", "gzip");
post.Headers.Add("Accept-Language", "en-US");
post.Headers.Add("apikey", apiKey);
post.Headers.Add("nonce", nonce);
post.Headers.Add("timestamp", timeStamp);
var authorize = CreateHMAC(apiKey, secretKey, merchantToken, payload, nonce, timeStamp);
post.Headers.Add("Authorization", authorize);
post.ContentType = "application/json";
post.Headers.Add("token", merchantToken);
post.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv: Gecko/20091221 Firefox/3.5.7";
post.GetRequestStream().Write(byteArray, 0, byteArray.Length);
var response = post.GetResponse();
var reader = new StreamReader(response.GetResponseStream());
var responseFromServer = reader.ReadToEnd();
response_label.Text = responseFromServer.ToString();

public static string CreateHMAC(string apiKey, string apiSecret, string token,
string payload, string nonce, string timeStamp)
var hmacData = apiKey + nonce + timeStamp + token + payload;
var hmac = new HMACSHA256(Encoding.UTF8.GetBytes(apiSecret));
var encBytes = hmac.ComputeHash(Encoding.UTF8.GetBytes(hmacData));
var encStr = ByteArrayToHexString(encBytes);
return Convert.ToBase64String(Encoding.UTF8.GetBytes((encStr)));

public static string ByteArrayToHexString(byte[] ba)
StringBuilder hex = new StringBuilder(ba.Length * 2);
foreach (byte b in ba)
hex.AppendFormat("{0:x2}", b);
return hex.ToString();

Re: 500 internal server error on refund call

Hi Keyur,

You may be using the payload for Capture which is different than the payload for Refund. This page has more details:



Payeezy Team