View Source Simple Card Brand

Determine a payment card's brand from the leading digits and length of the account number (PAN).

Uses the rules documented on Wikipedia.

Card Brands

  • American Express (:americanexpress)
  • BORICA (:borica)
  • China T-Union (:chinatunion)
  • China UnionPay (:chinaunionpay)
  • Dankort (:dankort)
  • Diners Club (:dinersclub)
  • Diners Club International (:dinersclubinternational)
  • Discover (:discover)
  • GPN (:gpn)
  • Humo (:humo)
  • InstaPayment (:instapayment)
  • InterPayment (:interpayment)
  • JCB: (:jcb)
  • LankaPay: (:lankapay)
  • Maestro (:maestro)
  • Maestro UK (:maestrouk)
  • Mastercard (:mastercard)
  • Mir (:mir)
  • Napas (:napas)
  • RuPay (:rupay)
  • Troy (:troy)
  • UATP (:uatp)
  • UkrCard (:ukrcard)
  • UzCard (:uzcard)
  • Verve (:verve)
  • Visa (:visa)
  • Visa Electron (:visaelectron)

Conflicts

The Wikipedia page has several account number range conflicts that need to be researched.

  • 65 is always recognized as Discover. Overrides RuPay and Troy.

  • 6759 is documented as both Maestro and Maestro UK.

    • Recognized as Maestro UK.
  • 54 is documented as both Diners Club in the US and Mastercard.

    • Recognized as Diners Club.

Mix Commands

  • mix format
  • mix test
  • mix credo

Installation

TO DO

If available in Hex, the package can be installed by adding simplecardbrand to your list of dependencies in mix.exs:

def deps do
  [
    {:simplecardbrand, "~> 0.1.0"}
  ]
end

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/simplecardbrand.