Auto detecting the credit card type...

20 views
Skip to first unread message

nahabed

unread,
Jun 28, 2008, 11:40:24 AM6/28/08
to Active Merchant
Hello, we are using Active_Merchant in an ecommerce up that we are
building for the U.S. market.

One feature that I understand the package does it "auto detecting" the
credit card type based on the number.

So when the user keys is a valid credit card number, the 4 card icons
reflect the type of credit card (so Visa, Mastercard, Amex and
Discover are up there and all 3 go "off" and only the card icon for
the selected one stays on).

Is there example code or the AJAX part of this? We're snowed-under
trying to finish other features and wondering if this code is out
there or available somewhere.

Thanks.

Cody Fauser

unread,
Jun 28, 2008, 12:13:51 PM6/28/08
to activem...@googlegroups.com
We added the Regex containing the card number patterns from
ActiveMerchant into JavaScript. Then when the card number field
changes you can attempt to detect a type from it. If you get a
particular card brand in the match then you highlight the appropriate
card logo.

--
Cody Fauser
http://shopify.com - e-commerce done right
http://www.codyfauser.com - blog
http://peepcode.com/products/activemerchant-pdf - ActiveMerchant PeepCode
http://www.oreilly.com/catalog/rjsrails - RJS Templates for Rails

Reply all
Reply to author
Forward
0 new messages