Hi Everyone
I am using webhook after finishing the transactions and getting a key "x-anet-signature" in the header from webhook then after trying to create a hash using text "^" + apiLogin + "^" + transId + "^" + amount + "^" as given in his doc.Please look into my below code and give me suggestions what mistake i made ?
function generateSHA512(textToHash, signatureKey) {
var apiLoginId = "xxxxxxxxxxxx";
var transId = "xxxxxxxxx";
var amount = 10;
08-27-2019 10:58 AM
08-28-2019 05:43 AM
Hi Renaissance,
Response came from webhook.
Authorize .net callback body:
{ notificationId: 'xxx',
eventType: 'xxx',
eventDate: 'xxx',
webhookId: 'xxx',
payload:
{ responseCode: 1,
authCode: 'T05SXH',
avsResponse: 'Y',
authAmount: 80,
entityName: 'transaction',
id: '60125874223' } }
Authorize .net callback header: EECDA210427E8FF17FFE8FF45E58DFCC542DEEF92D1156F3943C42FF7AFFFB5DA310E7476474490B6833B0271438BA20C699FFC105FBA7422D732B797A38C734
So according to you, this text has to be hashed:
'^1^T05SXH^Y^80^transaction^60125874223^'
I tried hashing with same function shown in original post but it did not work - it got a different hash value.
I then tried converting responseCode and amount to string, since they are not strings in the payload - both got the same hashcode as before (so javascript is implicitly converting to string).
Let me know if you see anything wrong with the text to hash or the method to generate the hash..
08-28-2019 11:45 AM
08-28-2019 07:00 PM
Thanks for clarifying. But I still don't know how to continue.
You said the same as the docs for Authorize.net - Just use the body as-is and hash it. But what method should we use to hash it as-is, as an object? Our method(s) only work on text strings, as in the authorize.net sample code for SHA512 (in sample-code-node/Sha512/compute_trans_hashSHA2.js ). When I tried using body as-is, it failed with error (input is invalid type).
Since that sample code doesn't apply to webhooks, and we have to do exactly the same hashing as authorize.net does, I need to see some sample code for hashing, in webhooks, in node.js...
Thanks for your patience.
08-29-2019 11:51 AM
08-29-2019 03:32 PM
Hi
Here is my webhook endpoint in nodejs
08-30-2019 10:21 AM
08-31-2019 04:39 AM
AUthorize .net callback body
{
notificationId: '4919527c-fdcc-4b22-9ca9-022e4800f4c8',
eventType: 'net.authorize.payment.authcapture.created',
eventDate: '2019-09-04T16:46:28.7407067Z',
webhookId: 'a92b9535-f456-4cc6-8b13-30d2a15296ba',
payload:
{
responseCode: 1,
authCode: 'W4DC4O',
avsResponse: 'Y',
authAmount: 30,
entityName: 'transaction',
id: '60126807698'
}
}
AUthorize .net callback headers
{
'content-type': 'application/json',
'x-anet-signature': 'sha512=8547F08392F112D5FAA9025FC51C3C5C1294AF1C6264CAABCC924B23E62F6F8D57BEF05F755745058A8649DAAA402164DE5C3816E397AC5426015C5E4681C0F2',
host: 'bitlume.com:4443',
connection: 'close',
'transfer-encoding': 'chunked'
}
Singnature kEY:
09-04-2019 09:51 AM
That body looks like it has been formatted. Run another request and capture the complete body in a log file and post what is on the log file here. The headers can be formatted any way you wish, but the body having those extra spaces and line breaks will throw off your hash.
09-07-2019 07:01 AM