emv-cryptogram
v1.0.5
Published
Generate and create different emv data tags
Readme
EMV Cryptogram
This package helps with EMV data data extraction and processing.
It's able to
- Parse EMV Data into a TLV structure
- Encrypt and Decrypt various EMV fields
Postman Requests
This package can be used to update a transaction's emv data in a postman request.
An example request can be seen below.
Pre-requisites
The following postman variables must be set before using the script below
- scheme: The card scheme used in the transaction (must be "mastercard", "visa" or "amex")
- country: The country in which this transaction was performed
- pan: The PAN number for the transaction's card
- emv_data: The hex encoded string of the card's EMV data
const emvCryptogram = pm.require('npm:emv-cryptogram@latest');
pm.variables.set("scheme", "visa")
pm.variables.set("country", "GB")
pm.variables.set("emv_data", "<emv-data>");
pm.variables.set("pan", "<pan>");
function formatTransactionDate(transactionDate) {
const transactionYear = transactionDate.substring(2, 4);
const transactionMonth = transactionDate.substring(5, 7);
const transactionDay = transactionDate.substring(8, 10);
return transactionYear + transactionMonth + transactionDay;
}
const request = JSON.parse(pm.request.body.raw);
const transaction = new emvCryptogram.Transaction(
request["type"],
new emvCryptogram.Amounts(
request["amounts"]["amount"],
request["amounts"]["currency"],
),
pm.variables.get("emv_data"),
pm.variables.get("pan"),
pm.variables.get("scheme"),
pm.variables.get("country"),
formatTransactionDate(request["transacted_at"])
)
emvCryptogram.updateEmvData(transaction);
pm.variables.set("emv_data", transaction.emvData);
