Skip to content

Instantly share code, notes, and snippets.

@ChrisMoney
Created August 29, 2016 18:07
Show Gist options
  • Save ChrisMoney/9d8636f8572cd57031c43b7225fb6a37 to your computer and use it in GitHub Desktop.
Save ChrisMoney/9d8636f8572cd57031c43b7225fb6a37 to your computer and use it in GitHub Desktop.
Read track data from card - Return account number and site code
// acct number + site code: %6074=4369371343068064237?;6074=0000000000303942?
public static string FormatAcctNumber(string cardNumber, out string siteCode)
{
// split data by
string[] array = cardNumber.Split(';');
string data = array[1];
string[] dataArray = data.Split('=');
siteCode = dataArray[0];
string acctNumber = dataArray[1];
// remove question mark
int questionMark = acctNumber.IndexOf('?');
acctNumber = acctNumber.Remove(questionMark, 1);
// remove leading 0s
acctNumber = acctNumber.TrimStart(new char[] {'0'});
return acctNumber;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment