Parse Credit Card input from Magnetic Stripe

前端 未结 6 1821
故里飘歌
故里飘歌 2020-12-23 17:36

Does anyone know how to parse a credit card string input from a Magnetic Card Swiper?

I tried a JavaScript parser but never got it to work. This is what the input l

6条回答
  •  -上瘾入骨i
    2020-12-23 18:15

    From what I can remember:

    That is a two-track magnetic strip data - first track starts with % and ends with ?, the second track starts with ; and ends with ?. These are Start/End markers.

    The first track is alphanumeric, the second track is numeric, and there is a third track which is numeric also (if my memory serves correct).

    The data between the start/end markers can be variable depending on the recording density of the magnetic strip. The higher the density, the more it can be recorded on one track.

    Using a regex to get at the data may not be a reliable method to pick out the information required.

    And not all credit cards have exactly two tracks, some uses three tracks.

提交回复
热议问题