go-credit-card

Credit card validation with the Luhn algorithm for golang

  • Owner: durango/go-credit-card
  • Platform:
  • License:: Other
  • Category::
  • Topic:
  • Like:
    0
      Compare:

Github stars Tracking Chart

go-credit-card Build Status Coverage Status GoDoc

Basic credit card validation using the Luhn algorithm

Currently identifies the following credit card companies:

  • American Express
  • Bankcard
  • China Unionpay
  • Dankort
  • Diners Club Carte Blanche
  • Diners Club enRoute
  • Diners Club International
  • Discover
  • InterPayment
  • InstaPayment
  • JCB
  • Maestro
  • MasterCard
  • Visa
  • Visa Electron

Installation

go get github.com/durango/go-credit-card

Quick Start

// Initialize a new card:
card := creditcard.Card{Number: "4242424242424242", Cvv: "11111", Month: "02", Year: "2016"}

// Retrieve the card's method (which credit card company this card belongs to)
err := card.Method() // card.Company({Short: "visa", Long: "Visa"})

// Display last four digits
lastFour, err := card.LastFour() // 4242

// Validate the card's number (without capturing)
err := card.Validate() // will return an error due to not allowing test cards

err := card.Validate(true) // this will work though

Main metrics

Overview
Name With Ownerdurango/go-credit-card
Primary LanguageGo
Program languageGo (Language Count: 2)
Platform
License:Other
所有者活动
Created At2014-09-12 19:23:52
Pushed At2022-07-15 16:03:04
Last Commit At2022-04-04 09:12:59
Release Count0
用户参与
Stargazers Count138
Watchers Count3
Fork Count40
Commits Count49
Has Issues Enabled
Issues Count6
Issue Open Count2
Pull Requests Count4
Pull Requests Open Count3
Pull Requests Close Count1
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private