Search This Blog

Title of the confirm dialog

Description of what is about to happen

Showing posts with label generator. Show all posts
Showing posts with label generator. Show all posts

Payment Card Number Validation


A payment card is a device that enables its owner (the cardholder) to make a payment by electronic funds transfer. The most common types of payment cards are credit cards and debit cards. Payment cards are usually embossed plastic cards, 85.60 × 53.98 mm in size, which comply with the ISO/IEC 7810 ID-1 standard. They usually also have an embossed card number conforming with the ISO/IEC 7812 numbering standard.

ref: https://en.wikipedia.org/wiki/Payment_card

Today there are many types of cards (payment / credit), there is one of simple way to test the card number, whether valid / invalid, using the Luhn algorithm. Matching publisher network can also be done if it had known the data of the card's issuer networking.




What goal?
○ Check/validate Card Number based on Luhn Algorithm.
○ Check Type, Issuer, Active.
○ Random Card Number Generator Simulation.
○ For Learning Purpose.



Main Class for PayCard Checker

Source Code

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89 
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq; // .Net Framework 4.0

namespace TechScales
{ 
    internal class PayCardEngine
    {
        ~PaymentCardEngine()
        {
            if (Cards != null && Cards.Count > 0) { Cards.Clear(); Cards = null; }
            GC.Collect();
            GC.WaitForPendingFinalizers();
        }
        internal enum CardType
        {
            Unidentify = -1,
            AmericanExpress = 0,
            Bankcard,
            ChinaUnionPay,
            DinersClubCarteBlanche,
            DinersClubenRoute,
            DinersClubInternational,
            DinersClubUSA_Canada,
            DiscoverCard,
            InterPayment,
            InstaPayment,
            JCB,
            Laser,
            Maestro,
            Dankort,
            NSPKMIR,
            MasterCard,
            Solo,
            Switch,
            Visa,
            UATP,
            Verve,
            CardguardEadbGils,
        }
        internal enum Active
        {
            Undefined = -1,
            No = 0,
            Yes = 1,
        }
        internal enum Checker
        {
            None = 0,
            Luhn = 1,
        }
        internal class ValidThrough
        {
            public ValidThrough(int month, int year)
            {
                Month = month; Year = year;
            }
            public int Month
            {
                get;
                set;
            }
            public int Year
            {
                get;
                set;
            }
            public override string ToString()
            {
                return string.Concat(Month, "/", (Year % 1000));
            }
        }
        internal static void ResetCardsData()
        {
            if (Cards != null)
            {
                Cards.Clear(); Cards = null;
            }
            Cards = new List<PayCard>();
        }
        static List<PayCard> Cards { get; set; }

        internal class PayCard
        {
        }
    }
}

Card Type, can be added within enum PayCardEngine.CardType after line41. Card Type also can be taken uniquely from added card data network. Class PayCard will described in here.

Top    Payment Card Live Validation