コード例 #1
0
ファイル: Validate.cs プロジェクト: webitpro/SimpleCore
            /// <summary>
            /// Returns Card Type
            /// </summary>
            /// <param name="strCC">(string) credit card number</param>
            /// <param name="cardType">(ccType) card type</param>
            /// <returns>(bool) </returns>
            public static bool CardType(string strCC, ccType cardType)
            {
                string strCardType = "";

                if (strCC.Length == 16)
                {
                    if (Int32.Parse(strCC.Substring(0, 2)) >= 51 && Int32.Parse(strCC.Substring(0, 2)) <= 55)
                    {
                        strCardType = "MasterCard";
                    }
                    if (Int32.Parse(strCC.Substring(0, 1)) == 4)
                    {
                        strCardType = "VISA";
                    }
                    if (Int32.Parse(strCC.Substring(0, 4)) == 6011)
                    {
                        strCardType = "Discover";
                    }
                    if (Int32.Parse(strCC.Substring(0, 1)) == 3)
                    {
                        strCardType = "JCB";
                    }
                }
                else
                {
                    if (strCC.Length == 15)
                    {
                        if (Int32.Parse(strCC.Substring(0, 2)) == 34 || Int32.Parse(strCC.Substring(0, 2)) == 37)
                        {
                            strCardType = "American_Express";
                        }
                        if (Int32.Parse(strCC.Substring(0, 4)) == 2014 || Int32.Parse(strCC.Substring(0, 4)) == 2149)
                        {
                            strCardType = "enRoute";
                        }
                        if (Int32.Parse(strCC.Substring(0, 4)) == 2131 || Int32.Parse(strCC.Substring(0, 4)) == 1800)
                        {
                            strCardType = "JCB";
                        }
                    }
                    else
                    {
                        if (strCC.Length == 14)
                        {
                            if (Int32.Parse(strCC.Substring(0, 2)) == 36 || Int32.Parse(strCC.Substring(0, 2)) == 38 || (Int32.Parse(strCC.Substring(0, 3)) >= 300 && Int32.Parse(strCC.Substring(0, 3)) <= 305))
                            {
                                strCardType = "Diners_Club_Carte_Blache";
                            }
                        }
                        else
                        {
                            if (strCC.Length == 13)
                            {
                                if (Int32.Parse(strCC.Substring(0, 1)) == 4)
                                {
                                    strCardType = "VISA";
                                }
                            }
                            else
                            {
                                strCardType = "Unknown";
                            }
                        }
                    }
                }

                return ((strCardType.Equals(cardType.ToString())) ? true : false);
            }
コード例 #2
0
            /// <summary>
            /// Returns Card Type
            /// </summary>
            /// <param name="strCC">(string) credit card number</param>
            /// <param name="cardType">(ccType) card type</param>
            /// <returns>(bool) </returns>
            public static bool CardType(string strCC, ccType cardType)
            {
                string strCardType = "";

                if (strCC.Length == 16)
                {
                    if (Int32.Parse(strCC.Substring(0, 2)) >= 51 && Int32.Parse(strCC.Substring(0, 2)) <= 55)
                    {
                        strCardType = "MasterCard";
                    }
                    if (Int32.Parse(strCC.Substring(0, 1)) == 4)
                    {
                        strCardType = "VISA";
                    }
                    if (Int32.Parse(strCC.Substring(0, 4)) == 6011)
                    {
                        strCardType = "Discover";
                    }
                    if (Int32.Parse(strCC.Substring(0, 1)) == 3)
                    {
                        strCardType = "JCB";
                    }
                }
                else
                {
                    if (strCC.Length == 15)
                    {
                        if (Int32.Parse(strCC.Substring(0, 2)) == 34 || Int32.Parse(strCC.Substring(0, 2)) == 37)
                        {
                            strCardType = "American_Express";
                        }
                        if (Int32.Parse(strCC.Substring(0, 4)) == 2014 || Int32.Parse(strCC.Substring(0, 4)) == 2149)
                        {
                            strCardType = "enRoute";
                        }
                        if (Int32.Parse(strCC.Substring(0, 4)) == 2131 || Int32.Parse(strCC.Substring(0, 4)) == 1800)
                        {
                            strCardType = "JCB";
                        }
                    }
                    else
                    {
                        if (strCC.Length == 14)
                        {
                            if (Int32.Parse(strCC.Substring(0, 2)) == 36 || Int32.Parse(strCC.Substring(0, 2)) == 38 || (Int32.Parse(strCC.Substring(0, 3)) >= 300 && Int32.Parse(strCC.Substring(0, 3)) <= 305))
                            {
                                strCardType = "Diners_Club_Carte_Blache";
                            }
                        }
                        else
                        {
                            if (strCC.Length == 13)
                            {
                                if (Int32.Parse(strCC.Substring(0, 1)) == 4)
                                {
                                    strCardType = "VISA";
                                }
                            }
                            else
                            {
                                strCardType = "Unknown";
                            }
                        }
                    }
                }

                return((strCardType.Equals(cardType.ToString())) ? true : false);
            }