Created
October 14, 2023 02:52
-
-
Save ThinhVu/1aba1f700f3eabe41ea504772cd3033a to your computer and use it in GitHub Desktop.
NASPAS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const _ = require('lodash') | |
const crc = require('crc') | |
// RFU: Reserved for Future Use | |
// https://vietqr.net/portal-service/resources/icons/ABB.png | |
const range = (first, last) => _.range(first, last, 1).map(v => _.padStart(v, 2, '0')) | |
const bankLists = [ | |
{ | |
"id": 1, | |
"name": "Ngân hàng TMCP An Bình", | |
"code": "ABB", | |
"bin": "970425", | |
"isTransfer": 1, | |
"filePath": "/icons/ABB.png" | |
}, | |
{ | |
"id": 2, | |
"name": "Ngân hàng TMCP Á Châu", | |
"code": "ACB", | |
"bin": "970416", | |
"isTransfer": 1, | |
"filePath": "/icons/ACB.png" | |
}, | |
{ | |
"id": 3, | |
"name": "Ngân hàng TMCP Bắc Á", | |
"code": "BAB", | |
"bin": "970409", | |
"isTransfer": 1, | |
"filePath": "/icons/BAB.png" | |
}, | |
{ | |
"id": 4, | |
"name": "Ngân hàng TMCP Đầu tư và Phát triển Việt Nam", | |
"code": "BIDV", | |
"bin": "970418", | |
"isTransfer": 1, | |
"filePath": "/icons/BIDV.png" | |
}, | |
{ | |
"id": 5, | |
"name": "Ngân hàng TMCP Bảo Việt", | |
"code": "BVB", | |
"bin": "970438", | |
"isTransfer": 1, | |
"filePath": "/icons/BVB.png" | |
}, | |
{ | |
"id": 53, | |
"name": "TMCP Việt Nam Thịnh Vượng - Ngân hàng số CAKE by VPBank", | |
"code": "CAKE", | |
"bin": "546034", | |
"isTransfer": 1, | |
"filePath": "/icons/CAKE.png" | |
}, | |
{ | |
"id": 6, | |
"name": "Ngân hàng Thương mại TNHH MTV Xây dựng Việt Nam", | |
"code": "CBB", | |
"bin": "970444", | |
"isTransfer": 1, | |
"filePath": "/icons/CBB.png" | |
}, | |
{ | |
"id": 7, | |
"name": "Ngân hàng TNHH MTV CIMB Việt Nam", | |
"code": "CIMB", | |
"bin": "422589", | |
"isTransfer": 1, | |
"filePath": "/icons/CIMB.png" | |
}, | |
{ | |
"id": 63, | |
"name": "Ngân hàng Citibank, N.A. - Chi nhánh Hà Nội", | |
"code": "CITIBANK", | |
"bin": "533948", | |
"isTransfer": 0, | |
"filePath": "/icons/CITIBANK.png" | |
}, | |
{ | |
"id": 52, | |
"name": "Ngân hàng Hợp tác xã Việt Nam", | |
"code": "COOPBANK", | |
"bin": "970446", | |
"isTransfer": 1, | |
"filePath": "/icons/COOPBANK.png" | |
}, | |
{ | |
"id": 8, | |
"name": "DBS Bank Ltd - Chi nhánh Thành phố Hồ Chí Minh", | |
"code": "DBS", | |
"bin": "796500", | |
"isTransfer": 0, | |
"filePath": "/icons/DBS.png" | |
}, | |
{ | |
"id": 9, | |
"name": "Ngân hàng TMCP Đông Á", | |
"code": "DOB", | |
"bin": "970406", | |
"isTransfer": 0, | |
"filePath": "/icons/DOB.png" | |
}, | |
{ | |
"id": 10, | |
"name": "Ngân hàng TMCP Xuất Nhập khẩu Việt Nam", | |
"code": "EIB", | |
"bin": "970431", | |
"isTransfer": 1, | |
"filePath": "/icons/EIB.png" | |
}, | |
{ | |
"id": 11, | |
"name": "Ngân hàng Thương mại TNHH MTV Dầu Khí Toàn Cầu", | |
"code": "GPB", | |
"bin": "970408", | |
"isTransfer": 0, | |
"filePath": "/icons/GPB.png" | |
}, | |
{ | |
"id": 12, | |
"name": "Ngân hàng TMCP Phát triển Thành phố Hồ Chí Minh", | |
"code": "HDB", | |
"bin": "970437", | |
"isTransfer": 1, | |
"filePath": "/icons/HDB.png" | |
}, | |
{ | |
"id": 13, | |
"name": "Ngân hàng TNHH MTV Hong Leong Việt Nam", | |
"code": "HLBVN", | |
"bin": "970442", | |
"isTransfer": 0, | |
"filePath": "/icons/HLBVN.png" | |
}, | |
{ | |
"id": 14, | |
"name": "Ngân hàng TNHH MTV HSBC (Việt Nam)", | |
"code": "HSBC", | |
"bin": "458761", | |
"isTransfer": 0, | |
"filePath": "/icons/HSBC.png" | |
}, | |
{ | |
"id": 16, | |
"name": "Ngân hàng Công nghiệp Hàn Quốc - Chi nhánh TP. Hồ Chí Minh", | |
"code": "IBK - HCM", | |
"bin": "970456", | |
"isTransfer": 0, | |
"filePath": "/icons/IBK.png" | |
}, | |
{ | |
"id": 15, | |
"name": "Ngân hàng Công nghiệp Hàn Quốc - Chi nhánh Hà Nội", | |
"code": "IBK - HN", | |
"bin": "970455", | |
"isTransfer": 0, | |
"filePath": "/icons/IBK.png" | |
}, | |
{ | |
"id": 17, | |
"name": "Ngân hàng TMCP Công thương Việt Nam", | |
"code": "ICB", | |
"bin": "970415", | |
"isTransfer": 1, | |
"filePath": "/icons/ICB.png" | |
}, | |
{ | |
"id": 18, | |
"name": "Ngân hàng TNHH Indovina", | |
"code": "IVB", | |
"bin": "970434", | |
"isTransfer": 1, | |
"filePath": "/icons/IVB.png" | |
}, | |
{ | |
"id": 51, | |
"name": "Ngân hàng Kookmin - Chi nhánh Thành phố Hồ Chí Minh", | |
"code": "KBHCM", | |
"bin": "970463", | |
"isTransfer": 0, | |
"filePath": "/icons/KB.png" | |
}, | |
{ | |
"id": 50, | |
"name": "Ngân hàng Kookmin - Chi nhánh Hà Nội", | |
"code": "KBHN", | |
"bin": "970462", | |
"isTransfer": 0, | |
"filePath": "/icons/KB.png" | |
}, | |
{ | |
"id": 55, | |
"name": "Ngân hàng Đại chúng TNHH Kasikornbank", | |
"code": "KBank", | |
"bin": "668888", | |
"isTransfer": 1, | |
"filePath": "/icons/KBank.png" | |
}, | |
{ | |
"id": 59, | |
"name": "Ngân hàng KEB Hana – Chi nhánh Thành phố Hồ Chí Minh", | |
"code": "KEBHANAHCM", | |
"bin": "970466", | |
"isTransfer": 0, | |
"filePath": "/icons/KEBHANAHCM.png" | |
}, | |
{ | |
"id": 60, | |
"name": "Ngân hàng KEB Hana – Chi nhánh Hà Nội", | |
"code": "KEBHANAHN", | |
"bin": "970467", | |
"isTransfer": 0, | |
"filePath": "/icons/KEBHANAHN.png" | |
}, | |
{ | |
"id": 19, | |
"name": "Ngân hàng TMCP Kiên Long", | |
"code": "KLB", | |
"bin": "970452", | |
"isTransfer": 1, | |
"filePath": "/icons/KLB.png" | |
}, | |
{ | |
"id": 20, | |
"name": "Ngân hàng TMCP Bưu điện Liên Việt", | |
"code": "LPBANK", | |
"bin": "970449", | |
"isTransfer": 1, | |
"filePath": "/icons/LPBANK.png" | |
}, | |
{ | |
"id": 62, | |
"name": "Công ty Tài chính TNHH MTV Mirae Asset (Việt Nam) ", | |
"code": "MAFC", | |
"bin": "977777", | |
"isTransfer": 0, | |
"filePath": "/icons/MAFC.png" | |
}, | |
{ | |
"id": 21, | |
"name": "Ngân hàng TMCP Quân đội", | |
"code": "MB", | |
"bin": "970422", | |
"isTransfer": 1, | |
"filePath": "/icons/MB.png" | |
}, | |
{ | |
"id": 22, | |
"name": "Ngân hàng TMCP Hàng Hải", | |
"code": "MSB", | |
"bin": "970426", | |
"isTransfer": 1, | |
"filePath": "/icons/MSB.png" | |
}, | |
{ | |
"id": 23, | |
"name": "Ngân hàng TMCP Nam Á", | |
"code": "NAB", | |
"bin": "970428", | |
"isTransfer": 1, | |
"filePath": "/icons/NAB.png" | |
}, | |
{ | |
"id": 24, | |
"name": "Ngân hàng TMCP Quốc Dân", | |
"code": "NCB", | |
"bin": "970419", | |
"isTransfer": 1, | |
"filePath": "/icons/NCB.png" | |
}, | |
{ | |
"id": 25, | |
"name": "Ngân hàng Nonghyup - Chi nhánh Hà Nội", | |
"code": "NHB HN", | |
"bin": "801011", | |
"isTransfer": 0, | |
"filePath": "/icons/NHB%20HN.png" | |
}, | |
{ | |
"id": 26, | |
"name": "Ngân hàng TMCP Phương Đông", | |
"code": "OCB", | |
"bin": "970448", | |
"isTransfer": 1, | |
"filePath": "/icons/OCB.png" | |
}, | |
{ | |
"id": 27, | |
"name": "Ngân hàng Thương mại TNHH MTV Đại Dương", | |
"code": "Oceanbank", | |
"bin": "970414", | |
"isTransfer": 1, | |
"filePath": "/icons/Oceanbank.png" | |
}, | |
{ | |
"id": 28, | |
"name": "Ngân hàng TNHH MTV Public Việt Nam", | |
"code": "PBVN", | |
"bin": "970439", | |
"isTransfer": 0, | |
"filePath": "/icons/PBVN.png" | |
}, | |
{ | |
"id": 29, | |
"name": "Ngân hàng TMCP Xăng dầu Petrolimex", | |
"code": "PGB", | |
"bin": "970430", | |
"isTransfer": 1, | |
"filePath": "/icons/PGB.png" | |
}, | |
{ | |
"id": 30, | |
"name": "Ngân hàng TMCP Đại Chúng Việt Nam", | |
"code": "PVCB", | |
"bin": "970412", | |
"isTransfer": 1, | |
"filePath": "/icons/PVCB.png" | |
}, | |
{ | |
"id": 31, | |
"name": "Ngân hàng TMCP Sài Gòn", | |
"code": "SCB", | |
"bin": "970429", | |
"isTransfer": 1, | |
"filePath": "/icons/SCB.png" | |
}, | |
{ | |
"id": 32, | |
"name": "Ngân hàng TNHH MTV Standard Chartered Bank Việt Nam", | |
"code": "SCVN", | |
"bin": "970410", | |
"isTransfer": 0, | |
"filePath": "/icons/SCVN.png" | |
}, | |
{ | |
"id": 33, | |
"name": "Ngân hàng TMCP Đông Nam Á", | |
"code": "SEAB", | |
"bin": "970440", | |
"isTransfer": 1, | |
"filePath": "/icons/SEAB.png" | |
}, | |
{ | |
"id": 34, | |
"name": "Ngân hàng TMCP Sài Gòn Công Thương", | |
"code": "SGICB", | |
"bin": "970400", | |
"isTransfer": 1, | |
"filePath": "/icons/SGICB.png" | |
}, | |
{ | |
"id": 35, | |
"name": "Ngân hàng TMCP Sài Gòn - Hà Nội", | |
"code": "SHB", | |
"bin": "970443", | |
"isTransfer": 1, | |
"filePath": "/icons/SHB.png" | |
}, | |
{ | |
"id": 37, | |
"name": "Ngân hàng TNHH MTV Shinhan Việt Nam", | |
"code": "SHBVN", | |
"bin": "970424", | |
"isTransfer": 1, | |
"filePath": "/icons/SHBVN.png" | |
}, | |
{ | |
"id": 36, | |
"name": "Ngân hàng TMCP Sài Gòn Thương Tín", | |
"code": "STB", | |
"bin": "970403", | |
"isTransfer": 1, | |
"filePath": "/icons/STB.png" | |
}, | |
{ | |
"id": 38, | |
"name": "Ngân hàng TMCP Kỹ thương Việt Nam", | |
"code": "TCB", | |
"bin": "970407", | |
"isTransfer": 1, | |
"filePath": "/icons/TCB.png" | |
}, | |
{ | |
"id": 58, | |
"name": "Ngân hàng số Timo by Ban Viet Bank (Timo by Ban Viet Bank)", | |
"code": "TIMO", | |
"bin": "963388", | |
"isTransfer": 1, | |
"filePath": "/icons/TIMO.png" | |
}, | |
{ | |
"id": 39, | |
"name": "Ngân hàng TMCP Tiên Phong", | |
"code": "TPB", | |
"bin": "970423", | |
"isTransfer": 1, | |
"filePath": "/icons/TPB.png" | |
}, | |
{ | |
"id": 40, | |
"name": "Ngân hàng United Overseas - Chi nhánh TP. Hồ Chí Minh", | |
"code": "UOB", | |
"bin": "970458", | |
"isTransfer": 0, | |
"filePath": "/icons/UOB.png" | |
}, | |
{ | |
"id": 54, | |
"name": "TMCP Việt Nam Thịnh Vượng - Ngân hàng số Ubank by VPBank", | |
"code": "Ubank", | |
"bin": "546035", | |
"isTransfer": 1, | |
"filePath": "/icons/Ubank.png" | |
}, | |
{ | |
"id": 41, | |
"name": "Ngân hàng TMCP Việt Á", | |
"code": "VAB", | |
"bin": "970427", | |
"isTransfer": 1, | |
"filePath": "/icons/VAB.png" | |
}, | |
{ | |
"id": 42, | |
"name": "Ngân hàng Nông nghiệp và Phát triển Nông thôn Việt Nam", | |
"code": "VBA", | |
"bin": "970405", | |
"isTransfer": 1, | |
"filePath": "/icons/VBA.png" | |
}, | |
{ | |
"id": 61, | |
"name": "Ngân hàng Chính sách Xã hội", | |
"code": "VBSP", | |
"bin": "999888", | |
"isTransfer": 0, | |
"filePath": "/icons/VBSP.png" | |
}, | |
{ | |
"id": 43, | |
"name": "Ngân hàng TMCP Ngoại Thương Việt Nam", | |
"code": "VCB", | |
"bin": "970436", | |
"isTransfer": 1, | |
"filePath": "/icons/VCB.png" | |
}, | |
{ | |
"id": 44, | |
"name": "Ngân hàng TMCP Bản Việt", | |
"code": "VCCB", | |
"bin": "970454", | |
"isTransfer": 1, | |
"filePath": "/icons/VCCB.png" | |
}, | |
{ | |
"id": 45, | |
"name": "Ngân hàng TMCP Quốc tế Việt Nam", | |
"code": "VIB", | |
"bin": "970441", | |
"isTransfer": 1, | |
"filePath": "/icons/VIB.png" | |
}, | |
{ | |
"id": 46, | |
"name": "Ngân hàng TMCP Việt Nam Thương Tín", | |
"code": "VIETBANK", | |
"bin": "970433", | |
"isTransfer": 1, | |
"filePath": "/icons/VIETBANK.png" | |
}, | |
{ | |
"id": 56, | |
"name": "Trung tâm dịch vụ tài chính số VNPT- Chi nhánh Tổng công ty truyền thông (VNPT Fintech)", | |
"code": "VNPTMONEY", | |
"bin": "971011", | |
"isTransfer": 0, | |
"filePath": "/icons/VNPTMONEY.png" | |
}, | |
{ | |
"id": 47, | |
"name": "Ngân hàng TMCP Việt Nam Thịnh Vượng", | |
"code": "VPB", | |
"bin": "970432", | |
"isTransfer": 1, | |
"filePath": "/icons/VPB.png" | |
}, | |
{ | |
"id": 48, | |
"name": "Ngân hàng Liên doanh Việt - Nga", | |
"code": "VRB", | |
"bin": "970421", | |
"isTransfer": 0, | |
"filePath": "/icons/VRB.png" | |
}, | |
{ | |
"id": 57, | |
"name": "Tổng Công ty Dịch vụ số Viettel - Chi nhánh tập đoàn công nghiệp viễn thông Quân Đội", | |
"code": "VTLMONEY", | |
"bin": "971005", | |
"isTransfer": 0, | |
"filePath": "/icons/VTLMONEY.png" | |
}, | |
{ | |
"id": 49, | |
"name": "Ngân hàng TNHH MTV Woori Việt Nam", | |
"code": "WVN", | |
"bin": "970457", | |
"isTransfer": 1, | |
"filePath": "/icons/WVN.png" | |
} | |
] | |
const listReceivable = [ | |
{ | |
"code": "ABB", | |
"filePath": "/icons/ABB.png" | |
}, | |
{ | |
"code": "ACB", | |
"filePath": "/icons/ACB.png" | |
}, | |
{ | |
"code": "BAB", | |
"filePath": "/icons/BAB.png" | |
}, | |
{ | |
"code": "BIDV", | |
"filePath": "/icons/BIDV.png" | |
}, | |
{ | |
"code": "BVB", | |
"filePath": "/icons/BVB.png" | |
}, | |
{ | |
"code": "CAKE", | |
"filePath": "/icons/CAKE.png" | |
}, | |
{ | |
"code": "CBB", | |
"filePath": "/icons/CBB.png" | |
}, | |
{ | |
"code": "CIMB", | |
"filePath": "/icons/CIMB.png" | |
}, | |
{ | |
"code": "CITIBANK", | |
"filePath": "/icons/CITIBANK.png" | |
}, | |
{ | |
"code": "COOPBANK", | |
"filePath": "/icons/COOPBANK.png" | |
}, | |
{ | |
"code": "DBS", | |
"filePath": "/icons/DBS.png" | |
}, | |
{ | |
"code": "DOB", | |
"filePath": "/icons/DOB.png" | |
}, | |
{ | |
"code": "EIB", | |
"filePath": "/icons/EIB.png" | |
}, | |
{ | |
"code": "GPB", | |
"filePath": "/icons/GPB.png" | |
}, | |
{ | |
"code": "HDB", | |
"filePath": "/icons/HDB.png" | |
}, | |
{ | |
"code": "HLBVN", | |
"filePath": "/icons/HLBVN.png" | |
}, | |
{ | |
"code": "HSBC", | |
"filePath": "/icons/HSBC.png" | |
}, | |
{ | |
"code": "IBK - HCM", | |
"filePath": "/icons/IBK.png" | |
}, | |
{ | |
"code": "ICB", | |
"filePath": "/icons/ICB.png" | |
}, | |
{ | |
"code": "IVB", | |
"filePath": "/icons/IVB.png" | |
}, | |
{ | |
"code": "KBHCM", | |
"filePath": "/icons/KB.png" | |
}, | |
{ | |
"code": "KBank", | |
"filePath": "/icons/KBank.png" | |
}, | |
{ | |
"code": "KEBHANAHCM", | |
"filePath": "/icons/KEBHANAHCM.png" | |
}, | |
{ | |
"code": "KEBHANAHN", | |
"filePath": "/icons/KEBHANAHN.png" | |
}, | |
{ | |
"code": "KLB", | |
"filePath": "/icons/KLB.png" | |
}, | |
{ | |
"code": "LPBANK", | |
"filePath": "/icons/LPBANK.png" | |
}, | |
{ | |
"code": "MAFC", | |
"filePath": "/icons/MAFC.png" | |
}, | |
{ | |
"code": "MB", | |
"filePath": "/icons/MB.png" | |
}, | |
{ | |
"code": "MSB", | |
"filePath": "/icons/MSB.png" | |
}, | |
{ | |
"code": "NAB", | |
"filePath": "/icons/NAB.png" | |
}, | |
{ | |
"code": "NCB", | |
"filePath": "/icons/NCB.png" | |
}, | |
{ | |
"code": "NHB HN", | |
"filePath": "/icons/NHB%20HN.png" | |
}, | |
{ | |
"code": "OCB", | |
"filePath": "/icons/OCB.png" | |
}, | |
{ | |
"code": "Oceanbank", | |
"filePath": "/icons/Oceanbank.png" | |
}, | |
{ | |
"code": "PBVN", | |
"filePath": "/icons/PBVN.png" | |
}, | |
{ | |
"code": "PGB", | |
"filePath": "/icons/PGB.png" | |
}, | |
{ | |
"code": "PVCB", | |
"filePath": "/icons/PVCB.png" | |
}, | |
{ | |
"code": "SCB", | |
"filePath": "/icons/SCB.png" | |
}, | |
{ | |
"code": "SCVN", | |
"filePath": "/icons/SCVN.png" | |
}, | |
{ | |
"code": "SEAB", | |
"filePath": "/icons/SEAB.png" | |
}, | |
{ | |
"code": "SGICB", | |
"filePath": "/icons/SGICB.png" | |
}, | |
{ | |
"code": "SHB", | |
"filePath": "/icons/SHB.png" | |
}, | |
{ | |
"code": "SHBVN", | |
"filePath": "/icons/SHBVN.png" | |
}, | |
{ | |
"code": "STB", | |
"filePath": "/icons/STB.png" | |
}, | |
{ | |
"code": "TCB", | |
"filePath": "/icons/TCB.png" | |
}, | |
{ | |
"code": "TIMO", | |
"filePath": "/icons/TIMO.png" | |
}, | |
{ | |
"code": "TPB", | |
"filePath": "/icons/TPB.png" | |
}, | |
{ | |
"code": "UOB", | |
"filePath": "/icons/UOB.png" | |
}, | |
{ | |
"code": "Ubank", | |
"filePath": "/icons/Ubank.png" | |
}, | |
{ | |
"code": "VAB", | |
"filePath": "/icons/VAB.png" | |
}, | |
{ | |
"code": "VBA", | |
"filePath": "/icons/VBA.png" | |
}, | |
{ | |
"code": "VBSP", | |
"filePath": "/icons/VBSP.png" | |
}, | |
{ | |
"code": "VCB", | |
"filePath": "/icons/VCB.png" | |
}, | |
{ | |
"code": "VCCB", | |
"filePath": "/icons/VCCB.png" | |
}, | |
{ | |
"code": "VIB", | |
"filePath": "/icons/VIB.png" | |
}, | |
{ | |
"code": "VIETBANK", | |
"filePath": "/icons/VIETBANK.png" | |
}, | |
{ | |
"code": "VNPTMONEY", | |
"filePath": "/icons/VNPTMONEY.png" | |
}, | |
{ | |
"code": "VPB", | |
"filePath": "/icons/VPB.png" | |
}, | |
{ | |
"code": "VRB", | |
"filePath": "/icons/VRB.png" | |
}, | |
{ | |
"code": "VTLMONEY", | |
"filePath": "/icons/VTLMONEY.png" | |
}, | |
{ | |
"code": "WVN", | |
"filePath": "/icons/WVN.png" | |
} | |
] | |
const receivableCode = new Set() | |
listReceivable.forEach(item => receivableCode.add(item.code)) | |
const receivableBankLists = bankLists.filter(bank => receivableCode.has(bank.code)) | |
// QR Push | |
const QRPushFieldId = { | |
payloadFormatIndicator: '00', | |
pointOfInitiationMethod: '01', | |
merchantAccountInformation: range(2, 51), | |
merchantCategoryCode: '52', | |
transactionCurrency: '53', | |
transactionAmount: '54', | |
tipOrConvenienceIndicator: '55', | |
valueOfConvenienceFeeFixed: '56', | |
valueOfConvenienceFeePercentage: '57', | |
countryCode: '58', | |
merchantName: '59', | |
merchantCity: '60', | |
postalCode: '61', | |
additionDataFieldTemplate: '62', | |
crc: '63', | |
merchantInformation: '64', | |
RFUForEMVCo: range(65, 79), | |
unReservedTemplate: range(80, 99), | |
} | |
const QRPushAdditionFieldTemplateId = { | |
billNumber: '01', | |
mobileNumber: '02', | |
storeLabel: '03', | |
loyaltyNumber: '04', | |
referenceLabel: '05', | |
customerLabel: '06', | |
terminalLabel: '07', | |
purposeOfTransaction: '08', | |
additionConsumerDataRequest: '09', | |
RFUForEMVCo: range(10, 49), | |
paymentSystemSpecificTemplate: range(50, 99) | |
} | |
// QR Cash | |
const QRCashFieldId = { | |
payloadFormatIndicator: '00', | |
pointOfInitiationMethod: '01', | |
merchantAccountInformation: range(2, 51), | |
merchantCategoryCode: '52', | |
transactionCurrency: '53', | |
transactionAmount: '54', | |
tipOrConvenienceIndicator: '55', | |
valueOfConvenienceFeeFixed: '56', | |
valueOfConvenienceFeePercentage: '57', | |
countryCode: '58', | |
merchantName: '59', | |
merchantCity: '60', | |
postalCode: '61', | |
additionDataFieldTemplate: '62', | |
crc: '63', | |
merchantInformation: '64', | |
RFUForEMVCo: range(65, 79), | |
unReservedTemplate: range(80, 99), | |
} | |
const QRCashAdditionFieldTemplateId = { | |
billNumber: '01', | |
mobileNumber: '02', | |
storeLabel: '03', | |
loyaltyNumber: '04', | |
referenceLabel: '05', | |
customerLabel: '06', | |
terminalLabel: '07', | |
purposeOfTransaction: '08', | |
additionConsumerDataRequest: '09', | |
RFUForEMVCo: range(10, 49), | |
paymentSystemSpecificTemplate: range(50, 99) | |
} | |
// QR IBFT | |
const QRIBFTFieldId = { | |
payloadFormatIndicator: '00', | |
pointOfInitiationMethod: '01', | |
merchantAccountInformation: range(2, 51), | |
merchantCategoryCode: '52', | |
transactionCurrency: '53', | |
transactionAmount: '54', | |
tipOrConvenienceIndicator: '55', | |
valueOfConvenienceFeeFixed: '56', | |
valueOfConvenienceFeePercentage: '57', | |
countryCode: '58', | |
merchantName: '59', | |
merchantCity: '60', | |
postalCode: '61', | |
additionDataFieldTemplate: '62', | |
crc: '63', | |
merchantInformation: '64', | |
RFUForEMVCo: range(65, 79), | |
unReservedTemplate: range(80, 99), | |
} | |
const QRIBFTAdditionFieldTemplateId = { | |
billNumber: '01', | |
mobileNumber: '02', | |
storeLabel: '03', | |
loyaltyNumber: '04', | |
referenceLabel: '05', | |
customerLabel: '06', | |
terminalLabel: '07', | |
purposeOfTransaction: '08', | |
additionConsumerDataRequest: '09', | |
RFUForEMVCo: range(10, 49), | |
paymentSystemSpecificTemplate: range(50, 99) | |
} | |
const PointOfInitiationMethod = { | |
StaticQR: '11', // Static QR – apply when allows a QR code to process more than one transaction | |
Dynamic: '12' // Dynamic QR – apply when allow a QR code to process only one transaction | |
} | |
function len(v) { | |
return _.padStart(v.length, 2, '0') | |
} | |
/** | |
* generateQRIBFTACode | |
* @param bankBin see bankLists | |
* @param bankAccountNo bnb account | |
* @param totalAmount money <= 13 char | |
* @param purposeOfTx string message <= 25 char | |
* @return {string} qr code str | |
*/ | |
function generateQRIBFTACode({bankBin, bankAccountNo, totalAmount, purposeOfTx}) { | |
const paymentFormatIndicator = '000201' | |
const pointOfInitiationMethod = '010212' | |
const naspasID = '38' | |
const GUID = '0010A000000727' | |
const paymentNetworkID = '01' | |
const paymentNetworkSubTab00ID = '00' | |
const paymentNetworkSubTab01ID = '01' | |
const serviceCodeID = '02', serviceCodeLength = '08', serviceCodeValue = 'QRIBFTTA' | |
const currencyID = '53', currencyLength = '03', currencyValue = '704' | |
const txAmountID = '54' | |
const countryCodeID = '58', countryCodeLength = '02', countryCodeValue = 'VN' | |
const additionalDataFieldTemplate = '62' | |
const purposeOfTxID = '08' | |
const crcID = '63', crcLength = '04' | |
// computed | |
const paymentNetworkSubTab00Length = len(bankBin) | |
const paymentNetworkSubTab00Value = bankBin | |
const paymentNetworkSubTab01Length = len(bankAccountNo) | |
const paymentNetworkSubTab01Value = bankAccountNo | |
const paymentNetwork = (paymentNetworkSubTab00ID + paymentNetworkSubTab00Length + paymentNetworkSubTab00Value + | |
paymentNetworkSubTab01ID + paymentNetworkSubTab01Length + paymentNetworkSubTab01Value) | |
const paymentNetworkLength = len(paymentNetwork) | |
const merchantAccountInfo = ( | |
GUID + | |
paymentNetworkID + paymentNetworkLength + paymentNetwork + | |
serviceCodeID + serviceCodeLength + serviceCodeValue | |
) | |
const merchantAccountInfoLength = len(merchantAccountInfo) | |
// amount | |
const txAmountVal = (totalAmount || 0).toString() | |
const txAmountLen = len(txAmountVal) | |
// extra info | |
const purposeOfTxVal = purposeOfTx | |
const purposeOfTxLen = len(purposeOfTxVal) | |
const additionalDataFieldTemplateLength = len(purposeOfTxID + purposeOfTxLen + purposeOfTxVal) | |
const payload = [ | |
paymentFormatIndicator, | |
pointOfInitiationMethod, | |
naspasID, | |
merchantAccountInfoLength, merchantAccountInfo, | |
currencyID, currencyLength, currencyValue, | |
txAmountID, txAmountLen, txAmountVal, | |
countryCodeID, countryCodeLength, countryCodeValue, | |
additionalDataFieldTemplate, additionalDataFieldTemplateLength, purposeOfTxID, purposeOfTxLen, purposeOfTxVal, | |
crcID, crcLength | |
].join('') | |
const crcStr = crc.crc16ccitt(payload, '0xFFFF').toString(16).toUpperCase() | |
return payload + _.padStart(crcStr, 4, '0') | |
} | |
module.exports = { | |
generateQRIBFTACode, | |
receivableBankLists | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment