Magnets in a Digital World: Credit Card Swipe Processing
In a traditional store, paying by credit card involves swiping the card through a swipe machine, which reads the data stored on a credit card’s magnetic stripe. The data includes a few key bits of information, namely:
- The account number and expiration date of the card
- The account holder’s name
- Some provider-specific data for verification
For a typical online transaction, the magnetic stripe on a card is not used. Purchases are made by entering account information manually, along with verification values not found in the magnetic stripe. This is acceptable for most people, as few computers come with magnetic card swipes.
However, what if someone wants to use an online system to run in-person transactions? With ThunderTix, many of our clients use our system for ticket sales on site. Typing every bit of data for each customer is slow, and tends to make people in line cranky. Fortunately, the magnetic stripe comes to our rescue. The first part of a magnetic stripe’s data looks something like this:
%Bxxxxxxx^LASTNAME/FIRSTNAME ^yymmzzzzzzzzzzzzzzz?
where the
xxxxxxx
is an account number,
LASTNAME/FIRSTNAME
are the account holder’s name,
yymm
is the expiration date, and
zzzzzzzzzz
is additional numbers. Using the standard format to detect a card swipe transaction, we can extract this information to expedite order processing:
if credit_card_number =~ /^%B(.)*?$/
card_fields = params[:cc][:number][2..-1].split(’^')
card_number = card_fields[0]
name = card_fields[1].strip.split(’/')
first_name = name[0]
last_name = name[1]
expiration_year = card_fields[2][0,2]
expiration_month = card_fields[2][2,2]
end
A few bits of additional data (magnetic stripes do not contain the verification values used for online transactions), and we’ve managed to cut each patron’s wait time significantly.










