card

package module
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 1, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

README

go-card

Basic credit card structure with validation using the Luhn algorithm

Installation

go get github.com/anaximen/go-card

Quick Start

// Initialize a new card:
card,err := card.NewCard("4716339239466898", "334", 2023, 12, "Ivanov Ivan")

if err!= nil {
    fmt.Print(err)
}
...

expired := card.Expired()

maskedNumber := card.MaskedNumber()

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Card

type Card struct {
	// contains filtered or unexported fields
}

Card - credit card structure

func NewCard

func NewCard(number string, cvv string, month int, year int, cardHolder string) (*Card, error)

NewCard - create a new credit card object

func (*Card) CardHolder

func (c *Card) CardHolder() string

CardHolder - return cardholder of credit card

func (*Card) Cvv

func (c *Card) Cvv() string

Cvv - return a cvv of credit card

func (*Card) Expired

func (c *Card) Expired() bool

Expired - return true if card is expired and false if not

func (*Card) MaskedNumber

func (c *Card) MaskedNumber(headlen int, taillen int) string

MaskedNumber - return a masked credit card number like 427615xxxxxx1234 @headlen - length of first series @taillen - length of last series

func (*Card) Month

func (c *Card) Month() int

Month - return expiration month of credit card

func (*Card) Number

func (c *Card) Number() string

Number - return a number of credit card

func (*Card) Year

func (c *Card) Year() int

Year - return expiration year of credit card

type Number added in v0.1.2

type Number struct {
	// contains filtered or unexported fields
}

Number - holds a credit card number

func NewCardNumber added in v0.1.1

func NewCardNumber(number string) (*Number, error)

NewCardNumber - return a new Number object

func (*Number) String added in v0.1.2

func (c *Number) String() string

type PaymentSystem

type PaymentSystem struct {
	Short, Full string
}

PaymentSystem holds a short and long names of who has issued the credit card

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL