.NET  |   IIS 5.0  |   IIS 4.0  |   Data Access  |   Beginning  |   Troubleshooting  |   Security  |   Performance  |   Component Building  |   ADSI  |   ISAPI  |   Site Server  |   FTP  |   Upload  |   State  |   Email  |   Scripting  |   XML
  Pioneering Active Server

Search


Power Search
15 Seconds
Home
Site Map
Press
Legal
Privacy Policy
Reference
News
Articles
Books
Code Samples
Components
FAQ
Glossary
KB Index
Links
News Groups
Tools
New
Free
Downloads
Vendors
Archives
Community
List Servers
Sweepstakes
Mailing List
Consultants
Jobs
internet.com
     Internet News
     Internet Investing
     Internet Technology
     Windows Internet Tech.
     Linux/Open Source
     Web Developer
     E-Commerce/Marketing
     ISP Resources
     ASP Resources
     Wireless Internet
     Downloads
     Internet Resources
     Internet Lists
     International
     EarthWeb
     Career Resources

     Search internet.com
     Advertising Info
     Corporate Info
     Internet Trade Shows
internet.commerce
     Accept Credit Cards
     E-Business Exchange
     International Domains
     Buy Cameras for Less
     Buy Linux Products
     Find a Web Host
     Document Management
     
     
     
cctest.asp


<html>
<!-- Test Script for credit card information -->
<!-- (c) 1998 by Click Online -->
<!-- http://www.click-online.de -->
<!-- [email protected] -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="GENERATOR" content="Microsoft FrontPage 3.0">
<!-- #include file="checkcc.inc"-->
<title>Click Online Credit Card Test </title>
</head>

<body
<%
 response.write "text=""" & textcol1 &_
	 """ link=""" & textlink &_
	 """ vlink=""" & textvlink &_
	 """ alink=""" & textalink &_
	 """ background=""../images/" &_
	 bgimgurl & """ bgcolor=""" &_
	 bgcolor & """" %>>

<p><%number=request("number")
cctype=request("cctype")
if number<>"" then
  chk=checkcc(number,cctype)
  response.write "<br>Result: "
  select case chk
  case 0
    response.write "Card is ok!"
  case 1
    response.write "Wrong card type"
  case 2
    response.write "Wrong length"
  case 3
    response.write "Wrong length and card type"
  case 4 
    response.write "Wrong checksum"
  case 5 
    response.write "Wrong checksum and card type"
  case 6
    response.write "Wrong checksum and length"
  case 7
    response.write "Wrong checksum, length and card type"
  case 8
    response.write "unknown cardtype"
  end select
else
  response.write "Please enter a card number"
end if%></p>

<form method="POST">
  <p>Card number: <input type="text" name="number" size="20"
	value="<%=number%>"></p>
  <p>Type: <select name="cctype" size="1">
    <option value="V" <%if cctype="V" then response.write "selected"%>>
	VISA</option>
    <option value="M" <%if cctype="M" then response.write "selected"%>>
	Mastercard/Eurocard</option>
    <option value="A" <%if cctype="A" then response.write "selected"%>>
	American Express</option>
    <option value="C" <%if cctype="C" then response.write "selected"%>>
	Diners Club / Carte Blanche</option>
    <option value="D" <%if cctype="D" then response.write "selected"%>>
	Discover</option>
    <option value="E" <%if cctype="E" then response.write "selected"%>>
	enRoute</option>
    <option value="J" <%if cctype="J" then response.write "selected"%>>
	JCB</option>
    <option value="U" <%if cctype="U" then response.write "selected"%>>
	unknown cardtype (test)</option>
  </select></p>
  <p><input type="submit" value="Test it!" name="B1"></p>
</form>

<p>� 1998 by <a href="http://www.click-online.de">Click Online</a></p>
</body>
</html>


checkcc.inc



<%
' Credit Card check routine for ASP
' (c) 1998 by Click Online
' You may use these functions only if this header is not removed
' http://www.click-online.de
' [email protected]


function trimtodigits(tstring)
'removes all chars except of 0-9
  s="" 
  ts=tstring
  for x=1 to len(ts)
    ch=mid(ts,x,1)
    if asc(ch)>=48 and asc(ch)<=57 then
      s=s & ch
    end if
  next
  trimtodigits=s
end function

function checkcc(ccnumber,cctype)
  'checks credit card number for checksum,length and type
  'ccnumber= credit card number (all useless characters are
  '	being removed before check)
  '
  'cctype:
  '       "V" VISA
  '       "M" Mastercard/Eurocard
  '       "A" American Express
  '       "C" Diners Club / Carte Blanche
  '       "D" Discover
  '       "E" enRoute
  '       "J" JCB
  'returns:  checkcc=0 (Bit0)  : card valid
  '          checkcc=1 (Bit1) : wrong type
  '          checkcc=2 (Bit2) : wrong length
  '          checkcc=4 (Bit3) : wrong checksum (MOD10-Test)
  '          checkcc=8 (Bit4) : cardtype unknown
  '
  ctype=ucase(cctype)
  select case ctype
    case "V"
      cclength="13;16"
      ccprefix="4"
    case "M"
      cclength="16"
      ccprefix="51;52;53;54;55"
    case "A"
      cclength="15"
      ccprefix="34;37"
    case "C"
      cclength="14"
      ccprefix="300;301;302;303;304;305;36;38"
    case "D"
      cclength="16"
      ccprefix="6011"
    case "E"
      cclength="15"
      ccprefix="2014;2149"
    case "J"
      cclength="15;16"
      ccprefix="3;2131;1800"
    case else
      cclength=""
      ccprefix=""
  end select
  prefixes=split(ccprefix,";",-1)
  lengths=split(cclength,";",-1)
  number=trimtodigits(ccnumber)
  prefixvalid=false
  lengthvalid=false
  for each prefix in prefixes
    if instr(number,prefix)=1 then
      prefixvalid=true
    end if
  next  
  for each length in lengths
    if cstr(len(number))=length then
      lengthvalid=true
    end if
  next
  result=0
  if not prefixvalid then
    result=result+1
  end if  
  if not lengthvalid then
    result=result+2
  end if  
  qsum=0
  for x=1 to len(number)
    ch=mid(number,len(number)-x+1,1)
    'response.write ch
    if x mod 2=0 then
      sum=2*cint(ch)
      qsum=qsum+(sum mod 10)
      if sum>9 then 
        qsum=qsum+1
      end if
    else
      qsum=qsum+cint(ch)
    end if
  next
  'response.write qsum
  if qsum mod 10<>0 then
    result=result+4
  end if
  if cclength="" then
    result=result+8
  end if
  checkcc=result
end function
%>






email this code sample to a colleague


Support the Active Server Industry

Copyright 2001 internet.com Corp. All Rights Reserved.
Legal Notices,  Licensing, Reprints, & Permissions,  Privacy Policy.