Hello,
I'm trying to figure out how to decrypt the consumer data after getting V.on("payment.success"....)
I'm using Node.js and I used the decryption algorithm provided in the docs.
Hey @julialiebs,
Can you please confirm the API product that your query relates to so that we can provide you with further assistance? Please take a look at our website for APIs relevant to your business case. We are happy to help.
https://developer.visa.com/
https://developer.visa.com/apibrowser
This is using the Get Payment Info API when decrypting consumer information by using the following sample code:
The following Node.js JavaScript code provides an example of decrypting the payload:
const crypto = require('crypto');
module.exports = { decryptPayload: function(key,wrappedKey,payload){
let decryptedKey = decrypt(wrappedKey,key); let decryptedMsg = decrypt(payload,decryptedKey); return decryptedMsg.toString('utf8'); }}
function decrypt(encrypted,key){ let encryptedBuffer = new Buffer(encrypted,'base64'); // TODO: Check that data(encryptedBuffer) is at least bigger // than HMAC + IV length , i.e. 48 bytes let hmac = new Buffer(32); let iv = new Buffer(16); encryptedBuffer.copy(hmac,0,0,32); encryptedBuffer.copy(iv,0,32,48); let data = Buffer.from(encryptedBuffer).slice(48);
var hash = crypto.createHmac('SHA256', key).update (Buffer.concat([iv,data])).digest(); if(!hmac.equals(hash)){
// TODO: Handle HMAC validation failure
return ''; }
let decipher = crypto.createDecipheriv('aes-256-cbc', crypto.createHash('sha256').update(key).digest(), iv); let decryptedData = Buffer.concat([decipher.update(data), decipher.final()]); return decryptedData;
}
Hey @julialiebs,
I'm happy to help you get in touch with a Visa Checkout Partner. Currently, you'll have to work with a partner to integrate Visa Checkout into your project.
Please find a list of Partners to integrate with Visa Checkout using this link here: https://globalcheckout.visa.com/visacheckoutPartners
Hey @julialiebs,
Please reach out to a Visa Checkout Partner using this link here if you have any questions about Visa Checkout: https://globalcheckout.visa.com/visacheckoutPartners