Skip to content

Commit

Permalink
Resolve #3
Browse files Browse the repository at this point in the history
  • Loading branch information
adefirmanf committed Jun 12, 2019
1 parent 50dd755 commit a1bc50c
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions iso8583.js
Expand Up @@ -59,6 +59,33 @@ class ISO8583 {
}
get(name, value) {}
wrapMsg(mti = '', opts) {
/**
* Define the MTI with name as key
*/
const MTIBit = new Map([
['AUTHORIZATION_REQUEST', '0100' ],
['AUTHORIZATION_RESPONSE', '0110'],
['AUTHORIZATION_ADVICE', '0120'],
['AUTHORIZATION_ADVICE_REPEAT', '0121'],
['ISSUER_RESPONSE_TO_AUTHORIZATION_ADVICE', '0130'],
['ACQUIRER_FINANCIAL_REQUEST', '0200'],
['ISSUER_RESPONSE_TO_FINANCIAL_REQUEST', '0210'],
['ACQUIRER_FINANCIAL_ADVICE', '0220'],
['ACQUIRER_FINANCIAL_ADVICE_REPEAT', '0221'],
['CONFIRMATION_OF_RECEIPT_OF_FINANCIAL_ADVICE', '0230'],
['BATCH_UPLOAD', '0320'],
['BATCH_UPLOAD_RESPONSE', '0330'],
['ACQUIRER_REVERSAL_REQUEST', '0400'],
['ACQUIRER_REVERSAL_ADVICE', '0420'],
['ACQUIRER_REVERSAL_ADVICE_RESPONSE', '0430'],
['BATCH_SETTLEMENT_RESPONSE', '0510'],
['NETWORK_MANAGEMENT_REQUEST', '0800'],
['NETWORK_MANAGEMENT_RESPONSE', '0810'],
['NETWORK_MANAGEMENT_ADVICE', '0820']
])

mti = MTIBit.get(mti) || mti

this._string = '';
let bitmap = [];
let total_length = 0;
Expand Down Expand Up @@ -89,6 +116,30 @@ class ISO8583 {

unWrapMsg(hex, opts = {output : 'array'}) {
const { output = 'array', validate = false } = opts;
/**
* Define the MTI with BIT as key
*/
const MTIName = new Map([
['0100', 'AUTHORIZATION_REQUEST' ],
['0110', 'AUTHORIZATION_RESPONSE'],
['0120', 'AUTHORIZATION_ADVICE'],
['0121', 'AUTHORIZATION_ADVICE_REPEAT'],
['0130', 'ISSUER_RESPONSE_TO_AUTHORIZATION_ADVICE'],
['0200', 'ACQUIRER_FINANCIAL_REQUEST'],
['0210', 'ISSUER_RESPONSE_TO_FINANCIAL_REQUEST'],
['0220', 'ACQUIRER_FINANCIAL_ADVICE'],
['0221', 'ACQUIRER_FINANCIAL_ADVICE_REPEAT'],
['0230', 'CONFIRMATION_OF_RECEIPT_OF_FINANCIAL_ADVICE'],
['0320', 'BATCH_UPLOAD'],
['0330', 'BATCH_UPLOAD_RESPONSE'],
['0400', 'ACQUIRER_REVERSAL_REQUEST'],
['0420', 'ACQUIRER_REVERSAL_ADVICE'],
['0430', 'ACQUIRER_REVERSAL_ADVICE_RESPONSE'],
['0510', 'BATCH_SETTLEMENT_RESPONSE'],
['0800', 'NETWORK_MANAGEMENT_REQUEST'],
['0810', 'NETWORK_MANAGEMENT_RESPONSE'],
['0820', 'NETWORK_MANAGEMENT_ADVICE'],
])

let _Temp_Bitmap = new Map([
['TYPE', 'NOT GIVEN VALUE']
Expand Down Expand Up @@ -130,6 +181,7 @@ class ISO8583 {

_Bitmap.set('PRIMARY_BITMAP', hex.substring(0, 16));
_Bitmap.set('TYPE', _Temp_Bitmap.get('TYPE'))
_Bitmap.set('TYPE_NAME', MTIName.get(_Bitmap.get('TYPE')))

hex = hex.substring(16, hex.length + 16);

Expand Down

0 comments on commit a1bc50c

Please sign in to comment.