Magnetic Stripe Card
A magnetic stripe cardopen in new window is a type of card capable of storing data by modifying the magnetism of tiny iron-based magnetic particles on a band of magnetic material on the card.
Track 1
Example
B4000340099900505^John/Doe ^22251110000123000
| SS | FC | PAN | FS | NAME | FS | Additional data | Discretionary data | ES | LRC |
|---|---|---|---|---|---|---|---|---|---|
| Primary Acount Number (19 digits Max.) | Name (26 alphanumberic characters Max.) | Expiration date (YYMM) 4 Service code 3 | PVKI 1 PVV or Offset 4 CVV or CVC 3 |
SS Start Sentinel '%'
FC Format Code
FS Field Separator '^'
ES End Sentinel '?'
LRC Lohgitudinal Redundancy Check character
PVKI PIN Verification Key Indicator
PVV PIN Verification Value
CVV Card Verification Value
CVC Card Validation Code
Track 2
Example
4000340099900505=2225111123400001230
| SS | PAN | FS | Additional data | Discretionary data | ES | LRC |
|---|---|---|---|---|---|---|
| Primary Acount Number (19 digits Max.) | Expiration date (YYMM) 4 Service code 3 | PVKI 1 PVV or Offset 4 CVV or CVC 3 |
- SS Start Sentinel Hex B ';'
- FS Field Separator Hex D '='
- ES End Sentinel '?'
- LRC Lohgitudinal Redundancy Check character
Code Exmaple
private fun getMagneticTrack(track: Bundle?): Boolean {
try {
val split_track1 = track!!.getString(MagData.TRACK1)!!.split("^")
val track2CheckInterchangeDesignator = track.getString(MagData.TRACK2)!!.subSequence(21, 22)
if (track2CheckInterchangeDesignator == "c2" && dataSetting!!.allow_insert_card) {
hasEMVStartAgain!!.value = true
description!!.value = "This card is support chip. Please Insert card/ Card pass or Swipe card again"
return false
} else {
if (split_track1.size >= 3) {
doProcess!!.value = true
val name = if (split_track1[1].contains("/")) {
val split_name = split_track1[1].split("/")
split_name[1].replace(" ", "") + " " + split_name[0].replace("\\", "")
} else {
split_track1[1].replace("\\s+".toRegex(), " ")
}
jsonData!!.put("name", name)
jsonData.put("transaction_type", transactionType)
jsonData.put("operation", "magnetic")
jsonData.put("card_exp", track.getString(MagData.EXPIRED_DATE))
jsonData.put("card_number", track.getString(MagData.PAN))
jsonData.put("track1", split_track1[0] + "^" + name + "^" + split_track1[2])
jsonData.put("track2", track.getString(MagData.TRACK2))
return true
} else {
description!!.value = "Cannot find name on track1"
hasError!!.value = true
Log.d("TEST", "not found name")
return false
}
}
} catch (e: Exception) {
Log.e("test aa3a", e.message.toString())
description!!.value = "${e.message}"
hasError!!.value = true
return false
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39