• User Newbie

    Funzioni per verifica validità carte di credito

    Ciao a tutti, nel norum ho trovato i seguemti scripts. qualcuno mi sa dire come applicarli?

    io ho una pagina con un modulo ed ho i seguenti campi:

    • Tipo carta = cctype
    • Numero Carta = ccnumber
    • Cod. di Controllo = cvc_code

    l'ho messo on-line ma credo che non ha i controlli dovuti, ovvero non da il minimo avviso. cosa sbaglio?

    <%
    Function ValidCcNumber(ccnumber)
    ccnumber = cleanccnum(ccnumber)
    If ccnumber = "" then
    validccnumber = false
    Else
    iseven = false
    digits = ""
    For i = len(ccnumber) to 1 step -1
    If iseven then
    digits = digits & cint(mid(ccnumber, i, 1))*2
    Else
    digits = digits & cint(mid(ccnumber,i,1))
    End if
    iseven= (not iseven)
    Next
    checksum = 0
    For i = 1 to len(digits) Step 1
    checksum = checksum + cint(mid(digits, i, 1))
    Next
    validccnumber = ((checksum mod 10)=0)
    End if
    End function
    %>
    <%
    Function ValidCcType(ccnumber,cctype)
    ValidCcType = true
    If cctype = "Visa" then
    If CInt(cleanccnum(Left(ccnumber,1))) <> 4 then ValidCcType = false
    Elseif cctype = "MasterCard" then
    If not (CInt(cleanccnum(Left(ccnumber,2))) > 50 and CInt(cleanccnum(Left(ccnumber,2))) < 56) then ValidCcType = false

    Elseif cctype = "AmericanExpress" then
        If not CInt(cleanccnum(Left(ccnumber,2))) = 34 and not CInt(cleanccnum(Left(ccnumber,2))) = 37 then ValidCcType = false
    Elseif cctype = "DinersClubCarteBlanche" then
        If not (CInt(cleanccnum(Left(ccnumber,3))) > 299 and CInt(cleanccnum(Left(ccnumber,3))) < 306) and not CInt(cleanccnum(Left(ccnumber,2))) = 37 and not CInt(cleanccnum(Left(ccnumber,2))) = 36 and not CInt(cleanccnum(Left(ccnumber,2))) = 38 then ValidCcType = false
    Elseif cctype = "Discover" then
        If not CInt(cleanccnum(Left(ccnumber,2))) = 6011 then ValidCcType = false
    End if
    

    End function
    %>
    <%
    Function ValidCcLength(ccnumber,cctype)
    ValidCcLength = true
    If cctype = "Visa" then
    If Len(ccnumber) <> 16 and Len(ccnumber) <> 13 then ValidCcLength = false
    Elseif cctype = "MasterCard" then
    If Len(ccnumber) <> 16 then ValidCcLength = false
    Elseif cctype = "AmericanExpress" then
    If Len(ccnumber) <> 15 then ValidCcLength = false
    Elseif cctype = "DinersClubCarteBlanche" then
    If Len(ccnumber) <> 14 then ValidCcLength = false
    Elseif cctype = "Discover" then
    If Len(ccnumber) <> 16 then ValidCcLength = false
    End if
    End function
    %>
    <%
    Function ValidCvcLength(cvc_code,cctype)
    ValidCvcLength = true
    If cctype = "Visa" then
    If Len(cvc_code) <> 3 then ValidCvcLength = false
    Elseif cctype = "MasterCard" then
    If Len(cvc_code) <> 3 then ValidCvcLength = false
    Elseif cctype = "AmericanExpress" then
    If Len(cvc_code) <> 4 then ValidCvcLength = false
    Elseif cctype = "DinersClubCarteBlanche" then
    If Len(cvc_code) <> 3 then ValidCvcLength = false
    Elseif cctype = "Discover" then
    If Len(cvc_code) <> 3 then ValidCvcLength = false
    End if
    End function
    %>
    <%
    Function cleanccnum(ccnumber)
    For i = 1 to len(ccnumber)
    If isnumeric (mid(ccnumber, i, 1)) then
    cleanccnum = cleanccnum & mid(ccnumber, i,1)
    End if
    Next
    End function
    %>

    Grazie