-
-
Notifications
You must be signed in to change notification settings - Fork 61
/
payment.go
39 lines (31 loc) · 1004 Bytes
/
payment.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
package faker
import (
"strconv"
)
var (
cardVendors = []string{
"Visa", "Visa", "Visa", "Visa", "Visa",
"MasterCard", "MasterCard", "MasterCard", "MasterCard", "MasterCard",
"American Express", "Discover Card", "Visa Retired"}
)
// Payment is a faker struct for Payment
type Payment struct {
Faker *Faker
}
// CreditCardType returns a fake credit card type for Payment
func (p Payment) CreditCardType() string {
return p.Faker.RandomStringElement(cardVendors)
}
// CreditCardNumber returns a fake credit card number for Payment
func (p Payment) CreditCardNumber() string {
return strconv.Itoa(p.Faker.IntBetween(1000000000000000, 9999999999999999))
}
// CreditCardExpirationDateString returns a fake credit card expiration date in string format for Payment
func (p Payment) CreditCardExpirationDateString() string {
day := strconv.Itoa(p.Faker.IntBetween(0, 30))
if len(day) == 1 {
day = "0" + day
}
month := strconv.Itoa(p.Faker.IntBetween(12, 30))
return day + "/" + month
}