Code for decrypting
exports.fetchDecryptedPayload = async (keyId, keyPath, encryptedPayloadString) => {
let encryptedPayload = typeof encryptedPayloadString == 'string' ? JSON.parse(encryptedPayloadString) : encryptedPayloadString;
let keystore = nodeJose.JWK.createKeyStore();
let decProps = {
kid: keyId,
alg: 'RSA-OAEP-256',
enc: 'A128GCM'
};
let decryptionKey = fs.readFileSync(keyPath);
return keystore.add(decryptionKey, 'pem', decProps)
.then((key) => {
return nodeJose.JWE.createDecrypt(key)
.decrypt(encryptedPayload.encData)
.then((result) => {
return result;
});
});
}
Code decrypted data
log.debug("Расшифровываем данные от visa-subscription", refId);
decryptedData = await fetchDecryptedPayload(
subsConfig.mle.keyId,
subsConfig.mle.keyPath,
responseBody
);
decryptedData = decryptedData.payload.toString("utf8");
log.debug(`Расшифрованные данные: ${decryptedData}`, refId);
decryptedData = JSON.parse(decryptedData);
Why in the response
"cardAcceptorId": "1.60E+14"
becoming like this, it has to be string and "235251000762203" (from docs).
I thought it might be because of JSON.parse, but it turned out that this field was changed before parsing.
Code for decrypting I took from docs.
How to solve it please help.
node - 18 version
node - jose - 2.2.0
Hi @elnura, Thank you for reaching out. An agent will get back to you soon. Until then, if any community member knows a solution, feel free to reply in this thread.
Hello, thank you for response, waiting for your answer.
As I noticed when I use this pan 4395842407255900 (from example in API reference of this https://sandbox.api.visa.com/vsps/search), parameter is like this
"cardAcceptorId": "1.60E+14",
but when I use 4072208010000000 (from example in API reference of this API) , parameter is as should be
"cardAcceptorId": "337186000108778",
I hope it will help you to resolve issue quicker.
Also I have noticed that pan examples from APIS are not compatible within Subscription service.
F.e: When I am trying to use 4072202010000000 from raw merchant data API in
Расшифрованные данные: {"httpStatus":"Bad Request","guid":"b566f937-9b90-4499-ad80-e61db8aee9b8","errors":[{"field":"Bad Request","description":"Pan is not valid"}]}
So could you please provide me with pans which I can use for testing.