-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexample.go
41 lines (35 loc) · 1.17 KB
/
example.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
// Copyright 2013 Doug Sparling. All rights reserved.
//
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package main
import (
"github.com/dsparling/go-business-creditcard"
"fmt"
)
func main() {
// true
fmt.Println(creditcard.Validate("4111111111111111"))
fmt.Println(creditcard.Validate("4111 1111 1111 1111"))
fmt.Println(creditcard.Validate("4111-1111-1111-1111"))
// false
fmt.Println(creditcard.Validate("1111111111111111"))
fmt.Println(creditcard.Validate("1111 1111 1111 1111"))
fmt.Println(creditcard.Validate("1111-1111-1111-1111"))
// Visa
fmt.Println(creditcard.Cardtype("4111111111111111"))
// MasterCard
fmt.Println(creditcard.Cardtype("5555555555554444"))
// AmericanExpress
fmt.Println(creditcard.Cardtype("378282246310005"))
// DinersClub/Carteblanche
fmt.Println(creditcard.Cardtype("30569309025904"))
// Discover
fmt.Println(creditcard.Cardtype("6011111111111117"))
// EnRoute
fmt.Println(creditcard.Cardtype("201400000000009"))
// JCB
fmt.Println(creditcard.Cardtype("3530111333300000"))
// Returns '9' - 5276440065421319
fmt.Println(creditcard.GenerateLastDigit("5276 4400 6542 131"))
}