-
Notifications
You must be signed in to change notification settings - Fork 0
/
credit_card.go
58 lines (40 loc) · 2.12 KB
/
credit_card.go
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
package gobilling
import ccutils "github.com/bliof/gobilling/credit_card_utils"
type CreditCard struct {
FirstName, LastName, Number, Brand, VerificationValue string
Month, Year int
StartMonth, StartYear int
IssueNumber string
OptionalVerficationValue bool
}
func (cc *CreditCard) GetFirstName() string { return cc.FirstName }
func (cc *CreditCard) SetFirstName(name string) { cc.FirstName = name }
func (cc *CreditCard) GetLastName() string { return cc.LastName }
func (cc *CreditCard) SetLastName(name string) { cc.LastName = name }
func (cc *CreditCard) GetNumber() string { return cc.Number }
func (cc *CreditCard) SetNumber(number string) { cc.Number = number }
func (cc *CreditCard) GetBrand() string { return cc.Brand }
func (cc *CreditCard) SetBrand(brand string) { cc.Brand = brand }
func (cc *CreditCard) GetVerificationValue() string { return cc.VerificationValue }
func (cc *CreditCard) SetVerificationValue(value string) { cc.VerificationValue = value }
func (cc *CreditCard) GetMonth() int { return cc.Month }
func (cc *CreditCard) SetMonth(month int) { cc.Month = month }
func (cc *CreditCard) GetYear() int { return cc.Year }
func (cc *CreditCard) SetYear(year int) { cc.Year = year }
func (cc *CreditCard) GetStartMonth() int { return cc.StartMonth }
func (cc *CreditCard) SetStartMonth(month int) { cc.StartMonth = month }
func (cc *CreditCard) GetStartYear() int { return cc.StartYear }
func (cc *CreditCard) SetStartYear(year int) { cc.StartYear = year }
func (cc *CreditCard) GetIssueNumber() string { return cc.IssueNumber }
func (cc *CreditCard) SetIssueNumber(issueNumber string) { cc.IssueNumber = issueNumber }
func (cc *CreditCard) RequiresVerificationValue() bool { return !cc.OptionalVerficationValue }
func (cc *CreditCard) SetRequiresVerificationValue(required bool) {
cc.OptionalVerficationValue = !required
}
func (cc *CreditCard) Validate() error {
ccutils.SetupCreditCard(cc)
return ccutils.ValidateCreditCard(cc)
}
func (cc *CreditCard) DisplayNumber() string {
return ccutils.MaskNumber(cc.Number)
}