Thunder Data Systems

Magnets in a Digital World: Credit Card Swipe Processing

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


is an account number,


are the account holder’s name,


is the expiration date, and


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]

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.

2 thoughts on “Magnets in a Digital World: Credit Card Swipe Processing

  1. Dan James

    Hello, maybe our posting is off topic but anyways, Having been surfing around your blog and it looks very neat. It is obvious that you know your subject and you are passionate about it. I’m constructing a new weblog and I’m striving to make it look great, as well as offer top quality content. Having discovered a good deal at your web site in addition to I look forward to more quality information and will be back soon. Thanks you.

Leave a Reply

Your email address will not be published. Required fields are marked *