0.0.8 • Published 4 years ago

steplix-emv-qrcps v0.0.8

Weekly downloads
279
License
ISC
Repository
github
Last release
4 years ago

This library was made to help people that are using NodeJS to generate and parse EMV QRcode according with the specifications:

It is a fork of Emmanuel Kiametis library.

This version fixes the CRC generated in cases where the resulting code is less than 4 digits long.

Installing

npm install steplix-emv-qrcps

Modules

There are 2 modules in this library.

  • Merchant - To work with QRCode according with the Merchant Specification.
  • Consumer - To work with QRCode according with the Consumer Specification.

Merchant Module

You can use this Module by importing:

const { Merchant } = require('steplix-emv-qrcps');

Methods

buildTLV

const TLV = Merchant.buildTLV(tag, length, value);
ParameterDescriptionType
tagPayload Format Indicatorstring
lengthPoint of Initiation Methodnumber
valueMerchant Account Informationstring
Return TypeDescription
TLVIt means an object that stores a Tag + Lenght + Value.

buildEMVQR

const EMVQR = Merchant.buildEMVQR();

// ... OR

const EMVQR = Merchant.buildEMVQR(
    payloadFormatIndicator,
    pointOfInitiationMethod,
    merchantAccountInformation,
    merchantCategoryCode,
    transactionCurrency,
    transactionAmount,
    tipOrConvenienceIndicator,
    valueOfConvenienceFeeFixed,
    valueOfConvenienceFeePercentage,
    countryCode,
    merchantName,
    merchantCity,
    postalCode,
    additionalDataFieldTemplate,
    crc,
    merchantInformationLanguageTemplate,
    rfuForEMVCo,
    unreservedTemplates,
);
ParameterDescriptionType
payloadFormatIndicatorPayload Format IndicatorTLV
pointOfInitiationMethodPoint of Initiation MethodTLV
merchantAccountInformationMerchant Account Informationmap id(string) : MerchantAccountInformation
merchantCategoryCodeMerchant Category CodeTLV
transactionCurrencyTransaction CurrencyTLV
transactionAmountTransaction AmountTLV
tipOrConvenienceIndicatorTip or Convenience IndicatorTLV
valueOfConvenienceFeeFixedValue of Convenience Fee FixedTLV
valueOfConvenienceFeePercentageValue of Convenience Fee PercentageTLV
countryCodeCountry CodeTLV
merchantNameMerchant NameTLV
merchantCityMerchant CityTLV
postalCodePostal CodeTLV
additionalDataFieldTemplateAdditional Data Field TemplateAdditionalDataFieldTemplate
crcCRCTLV
merchantInformationLanguageTemplateMerchant Information - Language TemplateMerchantInformationLanguageTemplate
rfuForEMVCoRFU for EMVCoarray TLV
unreservedTemplatesUnreserved Templatesmap id(string) : UnreservedTemplate
Return TypeDescription
EMVQRIt means an object that represents an EMV QRCode.

buildAdditionalDataFieldTemplate

const additionalDataFieldTemplate = Merchant.buildAdditionalDataFieldTemplate();

// ... OR

const additionalDataFieldTemplate = Merchant.buildAdditionalDataFieldTemplate(
    billNumber,
    mobileNumber,
    storeLabel,
    loyaltyNumber,
    referenceLabel,
    customerLabel,
    terminalLabel,
    purposeTransaction,
    additionalConsumerDataRequest,
    rfuForEMVCo,
    paymentSystemSpecific
);
ParameterDescriptionType
billNumberBill NumberTLV
mobileNumberCountry CodeTLV
storeLabelStore LabelTLV
loyaltyNumberLoyalty NumberTLV
referenceLabelReference LabelTLV
customerLabelCustomer LabelTLV
terminalLabelTerminal LabelTLV
purposeTransactionPurpose of TransactionTLV
additionalConsumerDataRequestAdditional Consumer Data RequestTLV
rfuForEMVCoRFU for EMVCoarray TLV
paymentSystemSpecificPayment System specific templatesmap id(string) : PaymentSystemSpecific
Return TypeDescription
AdditionalDataFieldTemplateIt means an object that represents an additional data field template.

buildMerchantInformationLanguageTemplate

const merchantInformationLanguageTemplate = Merchant.buildMerchantInformationLanguageTemplate();

// ... OR

const merchantInformationLanguageTemplate = Merchant.buildMerchantInformationLanguageTemplate(
    languagePreference,
    merchantName,
    merchantCity,
    rfuForEMVCo,
);
ParameterDescriptionType
languagePreferenceLanguage PreferenceTLV
merchantNameName of the merchantTLV
merchantCityName of the marchant cityTLV
rfuForEMVCoRFU for EMVCoarray TLV
Return TypeDescription
MerchantInformationLanguageTemplateIt means an object that represents a merchant information language template.

buildMerchantAccountInformation

const merchantAccountInformation = Merchant.buildMerchantAccountInformation();

// ... OR

const merchantAccountInformation = Merchant.buildMerchantAccountInformation(
    globallyUniqueIdentifier,
    paymentNetworkSpecific,
);
ParameterDescriptionType
globallyUniqueIdentifierGlobally unique identifierTLV
paymentNetworkSpecificArray of payment network specificarray TLV
Return TypeDescription
MerchantAccountInformationIt means an object that represents a merchant account information.

buildUnreservedTemplate

const unreservedTemplate = Merchant.buildUnreservedTemplate();

// ... OR

const unreservedTemplate = Merchant.buildUnreservedTemplate(
    globallyUniqueIdentifier,
    paymentNetworkSpecific,
);
ParameterDescriptionType
globallyUniqueIdentifierGlobally unique identifierTLV
contextSpecificDataArray of context of specific dataarray TLV
Return TypeDescription
UnreservedTemplateIt means an object that represents an unreserved template.

Object Types

TLV

Represents a TAG + Length + Value.

const { Merchant } = require('steplix-emv-qrcps');
const { Constants } = Merchant;

const tag = "01";
const value = "Example";
const length = value.length;

const TLV = Merchant.buildTLV(tag, length, value);
Methods
toString
const tlvStringFormat = TLV.toString();
Return TypeDescription
stringTLV in string format
dataWithType
const tlvBinaryFormat = TLV.dataWithType(Constants.DATA_TYPE.BINARY, ' '); // Binary Data (shown as hex bytes)

// OR

const tlvRawFormat = TLV.dataWithType(Constants.DATA_TYPE.RAW, ' '); // Raw Data
ParametersDescriptionType
dataTypeData type valueConstants.DATA_TYPE.BINARY | Constants.DATA_TYPE.RAW
indentIndent character (Ex.: ' ')string
Return TypeDescription
stringTLV in binary OR raw data format

MerchantAccountInformation

Represents a merchant account information.

const { Merchant } = require('steplix-emv-qrcps');
const { Constants } = Merchant;

const merchantAccountInformation = Merchant.buildMerchantAccountInformation();
Methods
toString
const merchantAccountInformationStringFormat = merchantAccountInformation.toString();
Return TypeDescription
stringMerchantAccountInformation in TLV string format
dataWithType
const merchantAccountInformationBinaryFormat = merchantAccountInformation.dataWithType(Constants.DATA_TYPE.BINARY, ' '); // Binary Data (shown as hex bytes)

// OR

const merchantAccountInformationRawFormat = merchantAccountInformation.dataWithType(Constants.DATA_TYPE.RAW, ' '); // Raw Data
ParametersDescriptionType
dataTypeData type valueConstants.DATA_TYPE.BINARY | Constants.DATA_TYPE.RAW
indentIndent character (Ex.: ' ')string
Return TypeDescription
stringMerchantAccountInformation in TLV binary OR TLV raw data format
setGloballyUniqueIdentifier
const value = "15600000000";

merchantAccountInformation.setGloballyUniqueIdentifier(value);
ParametersDescriptionType
valueSome valuestring
addPaymentNetworkSpecific
const id = "03";
const value = "12345678";

merchantAccountInformation.addPaymentNetworkSpecific(id, value);
ParametersDescriptionType
idTag IDstring
valueSome valuestring

MerchantInformationLanguageTemplate

Represents a merchant information language template.

const { Merchant } = require('steplix-emv-qrcps');
const { Constants } = Merchant;

const merchantInformationLanguageTemplate = Merchant.buildMerchantInformationLanguageTemplate();
Methods
toString
const merchantInformationLanguageTemplateStringFormat = merchantInformationLanguageTemplate.toString();
Return TypeDescription
stringMerchantInformationLanguageTemplate in TLV string format
dataWithType
const merchantInformationLanguageTemplateBinaryFormat = merchantInformationLanguageTemplate.dataWithType(Constants.DATA_TYPE.BINARY, ' '); // Binary Data (shown as hex bytes)

// OR

const merchantInformationLanguageTemplateRawFormat = merchantInformationLanguageTemplate.dataWithType(Constants.DATA_TYPE.RAW, ' '); // Raw Data
ParametersDescriptionType
dataTypeData type valueConstants.DATA_TYPE.BINARY | Constants.DATA_TYPE.RAW
indentIndent character (Ex.: ' ')string
Return TypeDescription
stringMerchantInformationLanguageTemplate in TLV binary OR TLV raw data format
validate
const isValid = merchantInformationLanguageTemplate.validate();
Return TypeDescription
booleanTrue if required properties is valid otherwise throw an Error
setLanguagePreference
const value = "PT";

merchantInformationLanguageTemplate.setLanguagePreference(value);
ParametersDescriptionType
valueSome valuestring
setMerchantName
const value = "Merchant Organization";

merchantInformationLanguageTemplate.setMerchantName(value);
ParametersDescriptionType
valueSome valuestring
setMerchantCity
const value = "Brasilia";

merchantInformationLanguageTemplate.setMerchantCity(value);
ParametersDescriptionType
valueSome valuestring
addRFUforEMVCo
const id = "03";
const value = "12345678";

merchantInformationLanguageTemplate.addRFUforEMVCo(id, value);
ParametersDescriptionType
idTag IDstring
valueSome valuestring

UnreservedTemplate

Represents a merchant account information.

const { Merchant } = require('steplix-emv-qrcps');
const { Constants } = Merchant;

const unreservedTemplate = Merchant.buildUnreservedTemplate();
Methods
toString
const unreservedTemplateStringFormat = unreservedTemplate.toString();
Return TypeDescription
stringUnreservedTemplate in TLV string format
dataWithType
const unreservedTemplateBinaryFormat = unreservedTemplate.dataWithType(Constants.DATA_TYPE.BINARY, ' '); // Binary Data (shown as hex bytes)

// OR

const unreservedTemplateRawFormat = unreservedTemplate.dataWithType(Constants.DATA_TYPE.RAW, ' '); // Raw Data
ParametersDescriptionType
dataTypeData type valueConstants.DATA_TYPE.BINARY | Constants.DATA_TYPE.RAW
indentIndent character (Ex.: ' ')string
Return TypeDescription
stringUnreservedTemplate in TLV binary OR TLV raw data format
setGloballyUniqueIdentifier
const value = "15600000000";

unreservedTemplate.setGloballyUniqueIdentifier(value);
ParametersDescriptionType
valueSome valuestring
addContextSpecificData
const id = "03";
const value = "12345678";

unreservedTemplate.addContextSpecificData(id, value);
ParametersDescriptionType
idTag IDstring
valueSome valuestring

PaymentSystemSpecific

Represents a payment system specific.

const { Merchant } = require('steplix-emv-qrcps');
const { Constants } = Merchant;

const paymentSystemSpecific = Merchant.buildPaymentSystemSpecific();
Methods
toString
const paymentSystemSpecificStringFormat = paymentSystemSpecific.toString();
Return TypeDescription
stringPaymentSystemSpecific in TLV string format
dataWithType
const paymentSystemSpecificBinaryFormat = paymentSystemSpecific.dataWithType(Constants.DATA_TYPE.BINARY, ' '); // Binary Data (shown as hex bytes)

// OR

const paymentSystemSpecificRawFormat = paymentSystemSpecific.dataWithType(Constants.DATA_TYPE.RAW, ' '); // Raw Data
ParametersDescriptionType
dataTypeData type valueConstants.DATA_TYPE.BINARY | Constants.DATA_TYPE.RAW
indentIndent character (Ex.: ' ')string
Return TypeDescription
stringPaymentSystemSpecific in TLV binary OR TLV raw data format
setGloballyUniqueIdentifier
const value = "15600000000";

paymentSystemSpecific.setGloballyUniqueIdentifier(value);
ParametersDescriptionType
valueSome valuestring
addPaymentSystemSpecific
const id = "03";
const value = "12345678";

paymentSystemSpecific.addPaymentSystemSpecific(id, value);
ParametersDescriptionType
idTag IDstring
valueSome valuestring

AdditionalDataFieldTemplate

Represents an additional data field template.

const { Merchant } = require('steplix-emv-qrcps');
const { Constants } = Merchant;

const additionalDataFieldTemplate = Merchant.buildAdditionalDataFieldTemplate();
Methods
toString
const additionalDataFieldTemplateStringFormat = additionalDataFieldTemplate.toString();
Return TypeDescription
stringAdditionalDataFieldTemplate in TLV string format
dataWithType
const additionalDataFieldTemplateBinaryFormat = additionalDataFieldTemplate.dataWithType(Constants.DATA_TYPE.BINARY, ' '); // Binary Data (shown as hex bytes)

// OR

const additionalDataFieldTemplateRawFormat = additionalDataFieldTemplate.dataWithType(Constants.DATA_TYPE.RAW, ' '); // Raw Data
ParametersDescriptionType
dataTypeData type valueConstants.DATA_TYPE.BINARY | Constants.DATA_TYPE.RAW
indentIndent character (Ex.: ' ')string
Return TypeDescription
stringAdditionalDataFieldTemplate in TLV binary OR TLV raw data format
setBillNumber
const value = "34250";

additionalDataFieldTemplate.setBillNumber(value);
ParametersDescriptionType
valueSome valuestring
setMobileNumber
const value = "+5561991112222";

additionalDataFieldTemplate.setMobileNumber(value);
ParametersDescriptionType
valueSome valuestring
setStoreLabel
const value = "1234";

additionalDataFieldTemplate.setStoreLabel(value);
ParametersDescriptionType
valueSome valuestring
setLoyaltyNumber
const value = "12345";

additionalDataFieldTemplate.setLoyaltyNumber(value);
ParametersDescriptionType
valueSome valuestring
setReferenceLabel
const value = "example";

additionalDataFieldTemplate.setReferenceLabel(value);
ParametersDescriptionType
valueSome valuestring
setCustomerLabel
const value = "***";

additionalDataFieldTemplate.setCustomerLabel(value);
ParametersDescriptionType
valueSome valuestring
setTerminalLabel
const value = "A6008667";

additionalDataFieldTemplate.setTerminalLabel(value);
ParametersDescriptionType
valueSome valuestring
setPurposeTransaction
const value = "Some purpose";

additionalDataFieldTemplate.setPurposeTransaction(value);
ParametersDescriptionType
valueSome valuestring
setAdditionalConsumerDataRequest
const value = "ME";

additionalDataFieldTemplate.setAdditionalConsumerDataRequest(value);
ParametersDescriptionType
valueSome valuestring
addRFUforEMVCo
const id = "03";
const value = "12345678";

additionalDataFieldTemplate.addRFUforEMVCo(id, value);
ParametersDescriptionType
idTag IDstring
valueSome valuestring
addPaymentSystemSpecific
const id = "03";
const value = Merchant.buildPaymentSystemSpecific();
value.setGloballyUniqueIdentifier("15600000000");
value.addPaymentSystemSpecific("03", "12345678");

additionalDataFieldTemplate.addPaymentSystemSpecific(id, value);
ParametersDescriptionType
idTag IDstring
valueSome valuestring

EMVQR

Represents an EMV QRCode.

const { Merchant } = require('steplix-emv-qrcps');
const { Constants } = Merchant;

const emvqr = Merchant.buildEMVQR();
Methods
generatePayload
const emvqrStringFormat = emvqr.generatePayload();
Return TypeDescription
stringEMV QRCode payload in string format.
dataWithType
const emvqrBinaryFormat = emvqr.dataWithType(Constants.DATA_TYPE.BINARY, ' '); // Binary Data (shown as hex bytes)

// OR

const emvqrRawFormat = emvqr.dataWithType(Constants.DATA_TYPE.RAW, ' '); // Raw Data
ParametersDescriptionType
dataTypeData type valueConstants.DATA_TYPE.BINARY | Constants.DATA_TYPE.RAW
indentIndent character (Ex.: ' ')string
Return TypeDescription
stringEMV QRCode in binary OR raw data format
toBinary
const emvqrBinaryFormat = emvqr.toBinary(); // Binary Data (shown as hex bytes)
Return TypeDescription
stringEMV QRCode in binary format
rawData
const emvqrBinaryFormat = emvqr.rawData(); // Raw Data
Return TypeDescription
stringEMV QRCode in raw data format
validate
const isValid = emvqr.validate();
Return TypeDescription
booleanTrue if required properties is valid otherwise throw an Error
setPayloadFormatIndicator
const value = "01";

emvqr.setPayloadFormatIndicator(value);
ParametersDescriptionType
valueSome valuestring
setPointOfInitiationMethod
const value = "00";

emvqr.setPointOfInitiationMethod(value);
ParametersDescriptionType
valueSome valuestring
setMerchantCategoryCode
const value = "Technology";

emvqr.setMerchantCategoryCode(value);
ParametersDescriptionType
valueSome valuestring
setTransactionCurrency
const value = "BRL";

emvqr.setTransactionCurrency(value);
ParametersDescriptionType
valueSome valuestring
setTransactionAmount
const value = "20.5";

emvqr.setTransactionAmount(value);
ParametersDescriptionType
valueSome valuestring
setTipOrConvenienceIndicator
const value = "2";

emvqr.setTipOrConvenienceIndicator(value);
ParametersDescriptionType
valueSome valuestring
setValueOfConvenienceFeeFixed
const value = "2.00";

emvqr.setValueOfConvenienceFeeFixed(value);
ParametersDescriptionType
valueSome valuestring
setValueOfConvenienceFeePercentage
const value = "0.90";

emvqr.setValueOfConvenienceFeePercentage(value);
ParametersDescriptionType
valueSome valuestring
setCountryCode
const value = "55";

emvqr.setCountryCode(value);
ParametersDescriptionType
valueSome valuestring
setMerchantName
const value = "Merchant Organization";

emvqr.setMerchantName(value);
ParametersDescriptionType
valueSome valuestring
setMerchantCity
const value = "Brasilia";

emvqr.setMerchantCity(value);
ParametersDescriptionType
valueSome valuestring
setPostalCode
const value = "71715-000";

emvqr.setPostalCode(value);
ParametersDescriptionType
valueSome valuestring
setCRC
const value = "AF35";

emvqr.setCRC(value);
ParametersDescriptionType
valueSome valuestring
setAdditionalDataFieldTemplate
const additionalDataFieldTemplate = Merchant.buildAdditionalDataFieldTemplate();
additionalDataFieldTemplate.setStoreLabel("1234");
additionalDataFieldTemplate.setCustomerLabel("***");
additionalDataFieldTemplate.setTerminalLabel("A6008667");
additionalDataFieldTemplate.setAdditionalConsumerDataRequest("ME");

emvqr.setAdditionalDataFieldTemplate(additionalDataFieldTemplate);
ParametersDescriptionType
additionalDataFieldTemplateSome additional data field templateAdditionalDataFieldTemplate
setMerchantInformationLanguageTemplate
let merchantInformationLanguageTemplate = Merchant.buildMerchantInformationLanguageTemplate();
merchantInformationLanguageTemplate.setLanguagePreference("PT");
merchantInformationLanguageTemplate.setMerchantName("Merchant Organization");
merchantInformationLanguageTemplate.setMerchantCity("Brasilia");
emvqr.setMerchantInformationLanguageTemplate(merchantInformationLanguageTemplate);
ParametersDescriptionType
merchantInformationLanguageTemplateSome merchant information language templateMerchantInformationLanguageTemplate
addMerchantAccountInformation
const id = "27";

const merchantAccountInformation = Merchant.buildMerchantAccountInformation();
merchantAccountInformation.setGloballyUniqueIdentifier("com.p2pqrpay");
merchantAccountInformation.addPaymentNetworkSpecific("01", "PAPHPHM1XXX");
merchantAccountInformation.addPaymentNetworkSpecific("02", "99964403");
merchantAccountInformation.addPaymentNetworkSpecific("04", "09985903943");
merchantAccountInformation.addPaymentNetworkSpecific("05", "+639985903943");

emvqr.addMerchantAccountInformation(id, merchantAccountInformation);
ParametersDescriptionType
idTag IDstring
valueSome merchant account informationstring
addUnreservedTemplates
const id = "80";

const unreservedTemplate = Merchant.buildUnreservedTemplate();
unreservedTemplate.setGloballyUniqueIdentifier("A011223344998877");
unreservedTemplate.addContextSpecificData("07", "12345678");

emvqr.addUnreservedTemplates(id, unreservedTemplate);
ParametersDescriptionType
idTag IDstring
valueSome unreserved templatestring
addRFUforEMVCo
const id = "03";
const value = "12345678";

emvqr.addRFUforEMVCo(id, value);
ParametersDescriptionType
idTag IDstring
valueSome valuestring

Consumer Module

You can use this Module by importing:

const { Consumer } = require('steplix-emv-qrcps')

Methods

buildBERTLV

const berTLV = Consumer.buildBERTLV();

// ... OR

const berTLV = Consumer.buildBERTLV(
    dataApplicationDefinitionFileName,
    dataApplicationLabel,
    dataTrack2EquivalentData,
    dataApplicationPAN,
    dataCardholderName,
    dataLanguagePreference,
    dataIssuerURL,
    dataApplicationVersionNumber,
    dataIssuerApplicationData,
    dataTokenRequestorID,
    dataPaymentAccountReference,
    dataLast4DigitsOfPAN,
    dataApplicationCryptogram,
    dataApplicationTransactionCounter,
    dataUnpredictableNumber
);
ParameterDescriptionType
dataApplicationDefinitionFileNameApplication Definition Namestring(in-hex-decimal-format)
dataApplicationLabelApplication Labelstring
dataTrack2EquivalentDataTrack to equivalent datastring(in-hex-decimal-format)
dataApplicationPANApplication PANstring(in-hex-decimal-format)
dataCardholderNameCardholder Namestring
dataLanguagePreferenceLanguage Preferencestring
dataIssuerURLIssuer URLstring
dataApplicationVersionNumberApplication Version Numberstring(in-hex-decimal-format)
dataIssuerApplicationDataIssuer Application Datastring(in-hex-decimal-format)
dataTokenRequestorIDToken Requestor IDstring(in-hex-decimal-format)
dataPaymentAccountReferencePayment Account Referencestring(in-hex-decimal-format)
dataLast4DigitsOfPANLast 4 digits of PANstring(in-hex-decimal-format)
dataApplicationCryptogramApplication Cryptogramstring(in-hex-decimal-format)
dataApplicationTransactionCounterApplication Transaction Counterstring(in-hex-decimal-format)
dataUnpredictableNumberUnpredictable Numberstring(in-hex-decimal-format)
Return TypeDescription
BERTLVIt means the TLV Object of the consumer module.

buildApplicationSpecificTransparentTemplate

const applicationSpecificTransparentTemplate = Consumer.buildApplicationSpecificTransparentTemplate();

// ... OR

const applicationSpecificTransparentTemplate = Consumer.buildApplicationSpecificTransparentTemplate(
	berTLV = BERTLV()
);
ParameterDescriptionType
berTLVBERTLV ObjectBERTLV
Return TypeDescription
ApplicationSpecificTransparentTemplateIt means an object that stores an application specific transparent template.

buildApplicationTemplate

const applicationTemplate = Consumer.buildApplicationTemplate();

// ... OR

const applicationTemplate = Consumer.buildApplicationTemplate(
	berTLV = BERTLV(),
	applicationSpecificTransparentTemplates = []
);
ParameterDescriptionType
berTLVBERTLV ObjectBERTLV
applicationSpecificTransparentTemplatesApplication specific transparent templatesarray (ApplicationSpecificTransparentTemplate)
Return TypeDescription
ApplicationTemplateIt means an object that stores an application template.

buildCommonDataTransparentTemplate

const commonDataTransparentTemplate = Consumer.buildCommonDataTransparentTemplate();

// ... OR

const commonDataTransparentTemplate = Consumer.buildCommonDataTransparentTemplate(
    berTLV = BERTLV()
);
ParameterDescriptionType
berTLVBERTLV ObjectBERTLV
Return TypeDescription
CommonDataTransparentTemplateIt means an object that stores a common data transparent template.

buildCommonDataTemplate

const commonDataTemplate = Consumer.buildCommonDataTemplate();

// ... OR

const commonDataTemplate = Consumer.buildCommonDataTemplate(
    berTLV = BERTLV(),
	commonDataTransparentTemplates = [] 
);
ParameterDescriptionType
berTLVBERTLV ObjectBERTLV
commonDataTransparentTemplatesCommon data transparent templatesarray (CommonDataTransparentTemplate)
Return TypeDescription
CommonDataTemplateIt means an object that stores a common data template.

buildEMVQR

const EMVQR = Consumer.buildEMVQR();

// ... OR

const EMVQR = Consumer.buildEMVQR(
    dataPayloadFormatIndicator,
    applicationTemplates,
    commonDataTemplates
);
ParameterDescriptionType
dataPayloadFormatIndicatorPayload Format Indicatorstring
applicationTemplatesApplication Templatesarray ApplicationTemplate
commonDataTemplatesCommon Data templatesarray CommonDataTemplate
Return TypeDescription
EMVQRIt means an object that represents an EMV QRCode.

Object Types

BERTLV

Represents a Basic Encoding Rules TAG + Length + Value.

const { Consumer } = require('steplix-emv-qrcps');
const { Constants } = Merchant;

const berTLV = Merchant.buildBERTLV();
Methods
setDataApplicationDefinitionFileName
berTLV.setDataApplicationDefinitionFileName("A0000000555555");
ParametersDescriptionType
dataApplicationDefinitionFileNameApplication Definition File (ADF) Namestring(in-hex-decimal-format)
setDataApplicationLabel
berTLV.setDataApplicationLabel("Product1");
ParametersDescriptionType
setDataApplicationLabelApplication Labelstring
setDataTrack2EquivalentData
berTLV.setDataTrack2EquivalentData("AABBCCDD");
ParametersDescriptionType
dataTrack2EquivalentDataTrack 2 Equivalent Datastring(in-hex-decimal-format)
setDataApplicationPAN
berTLV.setDataApplicationPAN("1234567890123458");
ParametersDescriptionType
dataApplicationPANApplication PANstring(in-hex-decimal-format)
setDataCardholderName
berTLV.setDataCardholderName("CARDHOLDER/EMV");
ParametersDescriptionType
dataCardholderNameCardholder Namestring
setDataLanguagePreference
berTLV.setDataLanguagePreference("ruesdeen");
ParametersDescriptionType
dataLanguagePreferenceLanguage Preferencestring
setDataIssuerURL
berTLV.setDataIssuerURL("http://someuri.com");
ParametersDescriptionType
dataIssuerURLIssuer URLstring
setDataApplicationVersionNumber
berTLV.setDataApplicationVersionNumber("04");
ParametersDescriptionType
dataApplicationVersionNumberApplication Version Numberstring(in-hex-decimal-format)
setDataIssuerApplicationData
berTLV.setDataIssuerApplicationData("06010A03000000");
ParametersDescriptionType
dataIssuerApplicationDataIssuer application datastring(in-hex-decimal-format)
setDataTokenRequestorID
berTLV.setDataTokenRequestorID("0601AABBCC");
ParametersDescriptionType
dataTokenRequestorIDToken Requestor IDstring(in-hex-decimal-format)
setDataPaymentAccountReference
berTLV.setDataPaymentAccountReference("0708AABBCCDD");
ParametersDescriptionType
dataPaymentAccountReferencePayment Account Referencestring(in-hex-decimal-format)
setDataLast4DigitsOfPAN
berTLV.setDataLast4DigitsOfPAN("07080201");
ParametersDescriptionType
dataLast4DigitsOfPANLast 4 Digits of PANstring(in-hex-decimal-format)
setDataApplicationCryptogram
berTLV.setDataApplicationCryptogram("584FD385FA234BCC");
ParametersDescriptionType
dataApplicationCryptogramApplication Cryptogramstring(in-hex-decimal-format)
setDataApplicationTransactionCounter
berTLV.setDataApplicationTransactionCounter("0001");
ParametersDescriptionType
dataApplicationTransactionCounterApplication Transaction Counterstring(in-hex-decimal-format)
setDataUnpredictableNumber
berTLV.setDataUnpredictableNumber("6D58EF13");
ParametersDescriptionType
dataUnpredictableNumberUnpredictable Numberstring(in-hex-decimal-format)
format
berTLV.format();
Return TypeDescription
stringBERTLV in string format
dataWithType
const berTlvBinaryFormat = berTLV.dataWithType(Constants.DATA_TYPE.BINARY, ' '); // Binary Data (shown as hex bytes)

// OR

const berTlvRawFormat = berTLV.dataWithType(Constants.DATA_TYPE.RAW, ' '); // Raw Data
ParametersDescriptionType
dataTypeData type valueConstants.DATA_TYPE.BINARY | Constants.DATA_TYPE.RAW
indentIndent character (Ex.: ' ')string
Return TypeDescription
stringBERTLV in binary OR raw data format

ApplicationSpecificTransparentTemplate

Represents an application specific transparent template.

const { Consumer } = require('steplix-emv-qrcps');
const { Constants } = Consumer;

const applicationSpecificTransparentTemplate = Consumer.buildApplicationSpecificTransparentTemplate();
Methods
setBERTLV
const berTLV = Consumer.buildBERTLV();

// Setters assignments in berTLV

applicationSpecificTransparentTemplate.setBERTLV(berTLV);
ParametersDescriptionType
berTLVBERTLV ObjectBERTLV
format
applicationSpecificTransparentTemplate.format();
Return TypeDescription
stringApplicationSpecificTransparentTemplate in string format
dataWithType
const binaryFormat = applicationSpecificTransparentTemplate.dataWithType(Constants.DATA_TYPE.BINARY, ' '); // Binary Data (shown as hex bytes)

// OR

const rawFormat = applicationSpecificTransparentTemplate.dataWithType(Constants.DATA_TYPE.RAW, ' '); // Raw Data
ParametersDescriptionType
dataTypeData type valueConstants.DATA_TYPE.BINARY | Constants.DATA_TYPE.RAW
indentIndent character (Ex.: ' ')string
Return TypeDescription
stringApplication specific transparent template in binary OR raw data format

CommonDataTransparentTemplate

Represents a common data transparent template.

const { Consumer } = require('steplix-emv-qrcps');
const { Constants } = Consumer;

const commonDataTransparentTemplate = Consumer.buildCommonDataTransparentTemplate();
Methods
setBERTLV
const berTLV = Consumer.buildBERTLV();

// Setters assignments in berTLV

commonDataTransparentTemplate.setBERTLV(berTLV);
ParametersDescriptionType
berTLVBERTLV ObjectBERTLV
format
commonDataTransparentTemplate.format();
Return TypeDescription
stringCommonDataTransparentTemplate in string format
dataWithType
const binaryFormat = commonDataTransparentTemplate.dataWithType(Constants.DATA_TYPE.BINARY, ' '); // Binary Data (shown as hex bytes)

// OR

const rawFormat = commonDataTransparentTemplate.dataWithType(Constants.DATA_TYPE.RAW, ' '); // Raw Data
ParametersDescriptionType
dataTypeData type valueConstants.DATA_TYPE.BINARY | Constants.DATA_TYPE.RAW
indentIndent character (Ex.: ' ')string
Return TypeDescription
stringCommon data transparent template in binary OR raw data format

ApplicationTemplate

Represents an application template.

const { Consumer } = require('steplix-emv-qrcps');
const { Constants } = Consumer;

const applicationTemplate = Consumer.buildApplicationTemplate();
Methods
setBERTLV
const berTLV = Consumer.buildBERTLV();

// Setters assignments in berTLV

applicationTemplate.setBERTLV(berTLV);
ParametersDescriptionType
berTLVBERTLV ObjectBERTLV
addApplicationSpecificTransparentTemplate
const applicationSpecificTransparentTemplate = Consumer.buildApplicationSpecificTransparentTemplate();

const berTLV1 = Consumer.buildBERTLV();
berTLV1.setDataApplicationDefinitionFileName("A0000000555555");
berTLV1.setDataApplicationLabel("Product1");
applicationSpecificTransparentTemplate.setBERTLV(berTLV1);

applicationTemplate.addApplicationSpecificTransparentTemplate(applicationSpecificTransparentTemplate);
ParametersDescriptionType
applicationSpecificTransparentTemplateAn application specific transparent templateApplicationSpecificTransparentTemplate
format
applicationTemplate.format();
Return TypeDescription
stringApplicationTemplate in string format
dataWithType
const binaryFormat = applicationTemplate.dataWithType(Constants.DATA_TYPE.BINARY, ' '); // Binary Data (shown as hex bytes)

// OR

const rawFormat = applicationTemplate.dataWithType(Constants.DATA_TYPE.RAW, ' '); // Raw Data
ParametersDescriptionType
dataTypeData type valueConstants.DATA_TYPE.BINARY | Constants.DATA_TYPE.RAW
indentIndent character (Ex.: ' ')string
Return TypeDescription
stringCommon data transparent template in binary OR raw data format

CommonDataTemplate

Represents a common data template.

const { Consumer } = require('steplix-emv-qrcps');
const { Constants } = Consumer;

const commonDataTemplate = Consumer.buildCommonDataTemplate();
Methods
setBERTLV
const berTLV = Consumer.buildBERTLV();

// Setters assignments in berTLV

commonDataTemplate.setBERTLV(berTLV);
ParametersDescriptionType
berTLVBERTLV ObjectBERTLV
addCommonDataTransparentTemplate
const commonDataTransparentTemplate = Consumer.buildCommonDataTransparentTemplate();

const berTLV = Consumer.buildBERTLV();
berTLV.setDataIssuerApplicationData("06010A03000000");
berTLV.setDataApplicationCryptogram("584FD385FA234BCC");
berTLV.setDataApplicationTransactionCounter("0001");
berTLV.setDataUnpredictableNumber("6D58EF13");
commonDataTransparentTemplate.setBERTLV(berTLV);

commonDataTemplate.addCommonDataTransparentTemplate(commonDataTransparentTemplate);
ParametersDescriptionType
commonDataTransparentTemplateA common data transparent templateCommonDataTransparentTemplate
format
commonDataTemplate.format();
Return TypeDescription
stringCommonDataTemplate in string format
dataWithType
const binaryFormat = commonDataTemplate.dataWithType(Constants.DATA_TYPE.BINARY, ' '); // Binary Data (shown as hex bytes)

// OR

const rawFormat = commonDataTemplate.dataWithType(Constants.DATA_TYPE.RAW, ' '); // Raw Data
ParametersDescriptionType
dataTypeData type valueConstants.DATA_TYPE.BINARY | Constants.DATA_TYPE.RAW
indentIndent character (Ex.: ' ')string
Return TypeDescription
stringCommon data transparent template in binary OR raw data format

EMVQR

Represents an EMV QRCode.

const { Consumer } = require('steplix-emv-qrcps');
const { Constants } = Consumer;

const emvqr = Consumer.buildEMVQR();
Methods
setDataPayloadFormatIndicator
emvqr.setDataPayloadFormatIndicator("CPV01");
ParametersDescriptionType
dataPayloadFormatIndicatorPayload Format Indicatorstring
addApplicationTemplate
const applicationTemplate1 = Consumer.buildApplicationTemplate();
const berTLV1 = Consumer.buildBERTLV();
berTLV1.setDataApplicationDefinitionFileName("A0000000555555");
berTLV1.setDataApplicationLabel("Product1");
applicationTemplate1.setBERTLV(berTLV1);

emvqr.addApplicationTemplate(applicationTemplate1);

const applicationTemplate2 = Consumer.buildApplicationTemplate();
const berTLV2 = Consumer.buildBERTLV();
berTLV2.setDataApplicationDefinitionFileName("A0000000666666");
berTLV2.setDataApplicationLabel("Product2");
applicationTemplate2.setBERTLV(berTLV2);

emvqr.addApplicationTemplate(applicationTemplate2);
ParametersDescriptionType
applicationTemplateAn application templateApplicationTemplate
addCommonDataTemplate
const commonDataTemplate = Consumer.buildCommonDataTemplate();

const berTLV1 = Consumer.buildBERTLV();
berTLV1.setDataApplicationPAN("1234567890123458");
berTLV1.setDataCardholderName("CARDHOLDER/EMV");
berTLV1.setDataLanguagePreference("ruesdeen");
commonDataTemplate.setBERTLV(berTLV1);

const commonDataTransparentTemplate = Consumer.buildCommonDataTransparentTemplate();

const berTLV2 = Consumer.buildBERTLV();
berTLV2.setDataIssuerApplicationData("06010A03000000");
berTLV2.setDataApplicationCryptogram("584FD385FA234BCC");
berTLV2.setDataApplicationTransactionCounter("0001");
berTLV2.setDataUnpredictableNumber("6D58EF13");
commonDataTransparentTemplate.setBERTLV(berTLV2);

commonDataTemplate.addCommonDataTransparentTemplate(commonDataTransparentTemplate);

emvqr.addCommonDataTemplate(commonDataTemplate);
ParametersDescriptionType
commonDataTemplateA common data templateCommonDataTemplate
generatePayload
commonDataTemplate.generatePayload();
Return TypeDescription
stringEMVQR in base64 string format
toBinary
const emvqrBinaryFormat = emvqr.toBinary(); // Binary Data (shown as hex bytes)
Return TypeDescription
stringEMV QRCode in binary format
rawData
const emvqrBinaryFormat = emvqr.rawData(); // Raw Data
Return TypeDescription
stringEMV QRCode in raw data format