Slide 11: Parse Before Applying Policy
Preserve all three service-code digits and consult the selected acceptance specification. Historical public examples use 101 for a stripe card and 201 for a chip card; the old reversed mapping was incorrect.
DE22 describes entry mode and, in these examples, PIN capability. It does not prove that PIN verification succeeded. Track data remains sensitive authentication data even without a cardholder name.
Slide 12: Parsing Track 2 in Go
type Track2Data struct {
PAN string
ExpiryYYMM string
ServiceCode string
Discretionary string
}
func ParseTrack2(track2 string) (Track2Data, error) {
// Find separator (= or D)
sepIdx := strings.IndexAny(track2, "=D")
if sepIdx == -1 {
return Track2Data{}, fmt.Errorf("no separator")
}
pan := track2[:sepIdx]
rest := track2[sepIdx+1:]
// Expiry (4) + Service code (3) + Discretionary
return Track2Data{
PAN: pan,
ExpiryYYMM: rest[0:4],
ServiceCode: rest[4:7],
Discretionary: rest[7:],
}, nil
}