Question: Please I need Answers in JAVA ONLY!!! Credit card processing requires a lookup of the card-type (Visa, MasterCard, American Express, Discover ...) used for the
Please I need Answers in JAVA ONLY!!!


Credit card processing requires a lookup of the card-type (Visa, MasterCard, American Express, Discover ...) used for the payment. The shopper/card holder enters the card number and the processor routes the payment based on the card-type. This card-type lookup is done based on the BIN (Bank Identification Number), which consists of the first few positions of a card number (card number prefix) that uniquely identify the bank that issued the card. For example, the BIN for the card number 4111111111111111 could be 411111111111. Instead of mapping every single BIN to a card-type, we specify ranges of BINs that are associated with a card-type. For this exercise we assume that each BIN range is mapped to only one card-type and that there are no overlapping ranges, but there may be gaps in between ranges for which we don't have any card-types. Objective: Implement a cache from a list of card BIN ranges to support efficient lookup of the card-type by card number. Example*: bin-range table end start cardtype 400000000000 419999999999 visa 420008000000 420008999999 visadebit 435000000000 435000999999 visa 540000000000 599999999999 mc For example, a card number 4111iiiiiiiiiiii would match the first bin range and so the card-type would be visa. v class Result { /** * An entity to hold bin range details. A bin range is a pair of 12 digit numbers that * mark the boundaries of the range which is maped to other bin range properties such * as a card type. The range boundaries are inclusive. */ static final class BinRange { final String start; final String end; final String cardType; BinRange(String start, String end, String cardType) { this.start = start; this.end = end; this.cardType = cardType; } } interface CardTypeCache { /** * @param cardNumber 12 to 23 digit card number. * @return the card type for this cardNumber or null if the card number does not fall into any valid bin ranges. String get(String cardNumber); } /** * @param binRanges the list of card bin ranges to build a cache from. * * @return an implementation of CardTypeCache. * public static CardTypeCache buildCache (List
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
