从前端谈二维码的解析与生成过程

Technology Architecture

How to parse the QR code by RN 

  1. QR handles are independent and non-conflicting matching and parsing logic.
  2. EMVCo is just a format, specific services may include QRIS, Duitnow, NETS, etc.
  3. If matched, it will be parsed into a object carried by the QR code, including type, content, merchantName, merchantCity, countryCode...

 QR code parsing rules

        Here we mainly talk about EMVCo rules, other rules are relatively simple, if you don't know about EMVCo, please click this link.

  1. It can be clearly seen that starting from the first digit, the first two digits are the ID, the next two digits are the length, and then the digits of the changed length are intercepted as the value.
  2. But the value may also be of subSchema type. When it is of subSchema type, value itself also conforms to EMVCo rules.

For example 

00020101021226610016ID.CO.SHOPEE.WWW01189360091800200869990208200869990303UMI520453995303360540869300.005802ID5912Epoint DUMMY6015KOTA JAKARTA UT61051446062330521628008-A000037-1156460704T001630446E4

In fact, by EMVCo rule, we can parse it into

00 02 01 
01 02 12 
26 61 00 16 ID.CO.SHOPEE.WWW
      01 18 936009180020086999 
      02 08 20086999
      03 03 UMI 
52 04 5399 
53 03 360 
54 08 69300.00
58 02 ID 
59 12 Epoint DUMMY
60 15 KOTA JAKARTA UT
61 05 14460
62 33 05 21 628008-A000037-115646
      07 04 T001
63 04 46E4

Finally, how to generate an object with key name ?

yes, you guessed it right, according to many schemas.

...
const EMVCoSchema: Schema<QRISData> = [
  {
    ids: '01',
    name: 'pointOfInitiationMethod',
    mandatory: false,
    type: 'string',
  },
  {
    ids: ['26', '45'],
    name: 'merchantAccountInformation',
    mandatory: true,
    type: 'subSchemaById',
    schema: EMVCoMerchantSchema,
  },
  {
    ids: '51',
    name: 'merchantAccountInformation',
    mandatory: false,
    type: 'subSchemaById',
    schema: EMVCoMerchantSchema
  }
];
...

So, the flow looks like this

How to generate a QR code 

        According to the actual situation, the QR code generation rules of `C scan B` and `B scan C` are different.

        In addition, there is a difference between static QR code and dynamic QR code. Dynamic QR code contains Amount information, but static QR code does not.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值