code: public static boolean isCreditCard(String stPassed) {
          if (isEmpty(stPassed)) return defaultEmptyOK;
          String st = stripCharsInBag(stPassed, creditCardDelimiters);
  
          int sum = 0;
          int mul = 1;
          int l = st.length();
  
          // Encoding only works on cards with less than 19 digits
          if (l > 19) return (false);
          for (int i = 0; i < l; i++) {
              String digit = st.substring(l - i - 1, l - i);
              int tproduct = 0;
  
              try {
                  tproduct = Integer.parseInt(digit, 10) * mul;
              } catch (Exception e) {
                  Debug.logWarning(e.getMessage());
                  return false;
              }
              if (tproduct >= 10)
                  sum += (tproduct % 10) + 1;
              else
                  sum += tproduct;
              if (mul == 1)
                  mul++;
              else
                  mul--;
          }
          // Uncomment the following line to help create credit card numbers
          // 1. Create a dummy number with a 0 as the last digit
          // 2. Examine the sum written out
          // 3. Replace the last digit with the difference between the sum and
          // the next multiple of 10.
  
          // document.writeln("<BR>Sum      = ",sum,"<BR>");
          // alert("Sum      = " + sum);
  
          if ((sum % 10) == 0)
              return true;
          else
              return false;
      }
docs: Checks credit card number with Luhn Mod-10 test
  
  @param stPassed a string representing a credit card number
  @return true, if the credit card number passes the Luhn Mod-10 test, false otherwise