Receiving Invalid HMAC error response when trying to send a POST Request from Salesforce

You are here

1 post / 0 new
Shreerath Nair
Receiving Invalid HMAC error response when trying to send a POST Request from Salesforce
Hi,  I am gettting the ''100003 error : Invalid HMAC" response when i am trying to send a post request from Salesforce to the API Sandbox.  Can you please help what's wrong in the below code:  Note: 'Body' variable is set as same provided on the API Sandbox          String MACENCRIPTION = 'HMACSHA512';         String SAGE_MERCHANT_ID = '173859436515';         String SAGE_MERCHANT_KEY = 'P1J2V8P2Q3D8';         String SAGE_CLIENT_ID = 'W8yvKQ5XbvAn7dUDJeAnaWCEwA4yXEgd';         String SAGE_CLIENT_SECRET = 'iLzODV5AUsCGWGkr';         String url='https://api-cert.sagepayments.com/bankcard/v1/charges?type=Sale';         verb='POST';         requestbody=JSON.serialize(body);         merchantId= SAGE_MERCHANT_ID;         nonce=String.valueOf(System.now().getTime());         DateTime current = System.now();         Long timeInMili = current.getTime()/1000;         timestamp=String.valueOf(integer.valueof(timeInMili));         messagePayload=verb+url+requestbody+merchantId+nonce+timestamp;         Blob data  = crypto.generateMac(MACENCRIPTION, Blob.valueof(messagePayload), Blob.valueOf(SAGE_CLIENT_SECRET));         String signature = EncodingUtil.base64Encode(data);     This signature is what we are using in the authorization header. Thanks