Get programming code snippets and tips for HTML, CSS, ASP, SQL, JavaScript, RSS, XML, and more
Lee's Code        A web programmer's toolbox. SEARCH SITE
HOME  |  ABOUT LEE  |  CONTACT  |  SEARCH
Home > Code > ASP > Check Credit Card Validity in ASP

Navigation

Latest Additions

Links


 

Recommendations

Evolve Online
Powered by
Evolve Online
 

Check Credit Card Validity in ASP

By: Lee A. Shurie
 
Subject: eCommerce
Language: ASP
Rating:
 Rated 56 times. Rate or review this item: 1 2 3 4 5
 
See it in action
 
Information
This routine was actually written by someone else but didn't work right so I modified it. It is a very simple credit card verification routine which simply applies the Mod 11 algorithm to check whether the card number is among the universe of valid numbers. It does not check to see if the number has been issued to a person, if there is a balance in the account, and so on. It also doesn't check the expiration date (I have several methods for checking expiration dates - which are posted on this site).

This routine is very useful as a pre-check before submitting customer data to a credit card gateway.
 
Code


 
Instructions
Simply paste the function in an ASP page anywhere you like (as long as it is between the <% %> ASP delimiters).

To call the function simply use:

isCreditCard("1234567812345678")

or

myCreditCardNumber = "1234567812345678"
isCreditCard(myCreditCardNumber)

The function will return true or false. So, for example…

varTransactionSuccessful = isCreditCard("1234123412341234")
If varTransactionSuccessful Then
  --- some processing goes here
End If
 
Keywords:credit card verification, validate credit card, eCommerce, asp
 

Lee's Code programming tips and tricks. Back to top of page.

Programming tips and tricks for ASP, javaScript, SQL, SML, CSS, HTML HOME | ABOUT LEE | CONTACT | SEARCH
 
Copyright © 2001 - 2010 by Lee A. Shurie