{"id":4148,"date":"2010-02-23T22:32:00","date_gmt":"2010-02-24T06:32:00","guid":{"rendered":"https:\/\/mikeindustries.com\/blog\/?p=4148"},"modified":"2016-05-25T23:34:26","modified_gmt":"2016-05-26T06:34:26","slug":"better-e-commerice-design-using-the-luhn-algorithm","status":"publish","type":"post","link":"https:\/\/mikeindustries.com\/blog\/archive\/2010\/02\/better-e-commerice-design-using-the-luhn-algorithm","title":{"rendered":"Better E-Commerce Design using the Luhn Algorithm?"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" src=\"\/blog\/images\/inline\/designingobama.jpg\" alt=\"\" width=\"171\" height=\"250\" class=\"rightinline\" \/>I finally put in my pre-order for <a href=\"http:\/\/www.designing-obama.com\/products\/designing-obama\" target=\"_blank\">SimpleScott&#8217;s Designing Obama book<\/a> a few minutes ago. I wanted to buy it earlier but never overcame the inertia until I got a chance to have beers with <a href=\"http:\/\/simplescott.com\" target=\"_blank\">Scott<\/a> and then listen to him speak at the excellent <a href=\"http:\/\/www.webstock.org.nz\/\" target=\"_blank\">Webstock conference<\/a> in New Zealand last week (by the way, thanks to <a href=\"http:\/\/www.subtraction.com\" target=\"_blank\">Khoi Vinh<\/a> for asking me to step in for him as a <a href=\"http:\/\/www.flickr.com\/photos\/webstock06\/4380748159\/in\/set-72157623366859689\/\" target=\"_blank\">speaker<\/a>). Can I also just say that Webstock is the best designed conference I&#8217;ve ever seen?<\/p>\n<p>Scott&#8217;s a great designer, obviously, but hearing about the care that&#8217;s going into just the <em>production<\/em> of the book is going to make this piece of art a must-have. I may even order two and keep one suspended in formaldehyde.<\/p>\n<p>While ordering the book, one part of the process stuck out to me as something I&#8217;d never seen before, even having ordered probably a thousand items online in the past: when I typed in my credit card number, a green checkmark showed up immediately after the last digit was entered. My immediate suspicion was that they were counting digits and gave me a check to indicate I had typed in enough of them, but again, having never seen that before, my interest was piqued. I tried deleting the last digit and replacing it with a 1, then a 2, then a 3, and so on.  Only when I typed the actual digit from the credit card did I get the green checkmark again.<\/p>\n<p>Further investigation revealed that no server calls were being made, which means this was some sort client-side algorithm that verified credit card patterns. <em>Iiiiiiiiiinteresting!<\/em>. Even more investigation revealed that this was the work of something I&#8217;d never heard of: <a href=\"http:\/\/en.wikipedia.org\/wiki\/Luhn_algorithm\" target=\"_blank\">The Luhn Algorithm<\/a>.<\/p>\n<p>The Luhn Algorithm is a formula which can be run in javascript, PHP, and most other programming languages that uses some mathematical rules to determine if a credit card number is likely to be valid. Apparently, credit card companies issue numbers according to this algorithm, and if a number doesn&#8217;t fit it, it&#8217;s definitely not valid.  Before you say to yourself &#8220;wow, that&#8217;s some neat, new technology I can use!&#8221;, note that <em>the Luhn Algorithm has been around since 1954!<\/em><\/p>\n<p>Although using this algorithm in your own projects is clearly not a necessity, I see a couple of potential advantages and a couple of potential disadvantages:<\/p>\n<h3>Advantages<\/h3>\n<ul>\n<li>Instant UI feedback is a great tool to help users correct errors<\/li>\n<li>The checkmark is a nice bit of instant emotional validation to make sure users complete the process<\/li>\n<\/ul>\n<h3>Disadvantages<\/h3>\n<ul>\n<li>Is there a guarantee that every card will always follow this pattern? What happens if one or many stop following it?<\/li>\n<li>Since it&#8217;s an unusual experience, does it add a bit of suspicion in some users? Would a less technical user assume their number was being broadcast across the internet more times than necessary?<\/li>\n<\/ul>\n<p>I&#8217;m curious to see if this catches on as a trend.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I finally put in my pre-order for SimpleScott&#8217;s Designing Obama book a few minutes ago. I wanted to buy it earlier but never overcame the inertia until I got a chance to have beers with Scott and then listen to him speak at the excellent Webstock conference in New Zealand last week (by the way, [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[37,36,282],"tags":[],"class_list":["post-4148","post","type-post","status-publish","format-standard","hentry","category-code","category-design","category-original"],"_links":{"self":[{"href":"https:\/\/mikeindustries.com\/blog\/wp-json\/wp\/v2\/posts\/4148","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mikeindustries.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mikeindustries.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mikeindustries.com\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/mikeindustries.com\/blog\/wp-json\/wp\/v2\/comments?post=4148"}],"version-history":[{"count":0,"href":"https:\/\/mikeindustries.com\/blog\/wp-json\/wp\/v2\/posts\/4148\/revisions"}],"wp:attachment":[{"href":"https:\/\/mikeindustries.com\/blog\/wp-json\/wp\/v2\/media?parent=4148"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mikeindustries.com\/blog\/wp-json\/wp\/v2\/categories?post=4148"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mikeindustries.com\/blog\/wp-json\/wp\/v2\/tags?post=4148"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}