Created
March 25, 2020 16:06
-
-
Save juliankoehn/7324ba90bfec6d03c59d002071465747 to your computer and use it in GitHub Desktop.
Credit Card structs for stripe.com
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Creditcard a creditcard holds information | |
// about a card from StripeJS | |
// card brand | |
type Creditcard struct { | |
ID string `json:"id" db:"id"` | |
// Can be amex, diners, discover, jcb, mastercard, unionpay, visa, or unknown | |
Brand string `json:"brand" db:"brand"` | |
Checks Checks `json:"checks" has_one:"checks" fk_id:"credit_card_id"` | |
Country string `json:"country" db:"country"` | |
// Two-digit number representing the card’s expiration month. | |
ExpMonth int64 `json:"exp_month" db:"exp_month"` | |
// Four-digit number representing the card’s expiration year. | |
ExpYear int64 `json:"exp_year" db:"exp_year"` | |
// Uniquely identifies this particular card number. | |
// You can use this attribute to check whether two customers who’ve signed | |
// up with you are using the same card number,for example. | |
// For payment methods that tokenize card information | |
// (Apple Pay, Google Pay), the tokenized number might be provided | |
// instead of the underlying card number. | |
Fingerprint string `json:"fingerprint" db:"fingerprint"` | |
// Card funding type. Can be credit, debit, prepaid, or unknown. | |
Funding string `json:"funding" db:"funding"` | |
// The last four digits of the card. | |
Last4 string `json:"last4" db:"last4"` | |
// Contains details on how this Card maybe be used for 3D Secure authentication. | |
ThreeDUsageSupported bool `json:"three_d_usage_supported" db:"3d_usage_supported"` | |
DeletedAt time.Time `json:"-" db:"deleted_at"` | |
CreatedAt time.Time `json:"createdAt" db:"created_at"` | |
UpdatedAt time.Time `json:"updatedAt" db:"updated_at"` | |
} | |
// TableName of the Credit Cards table | |
func (Creditcard) TableName() string { | |
tableName := "credit_cards" | |
if namespace.GetNamespace() != "" { | |
return namespace.GetNamespace() + "_" + tableName | |
} | |
return tableName | |
} | |
// Checks on card address and CVC if provided | |
type Checks struct { | |
ID int64 `db:"id"` | |
CreditCardID string `json:"-" db:"credit_card_id"` | |
// If a address line1 was provided, results of the check, one of pass, fail, unavailable, or unchecked | |
AddressLine1Check string `json:"address_line1_check" db:"address_line1_check"` | |
// If a address postal code was provided, results of the check, one of pass, fail, unavailable, or unchecked. | |
AdressPostalCodeCheck string `json:"address_postal_code_check" db:"address_postal_code_check"` | |
// If a CVC was provided, results of the check, one of pass, fail, unavailable, or unchecked | |
CvcCheck string `json:"cvc_check" db:"cvc_check"` | |
} | |
// TableName of the Checks table | |
func (Checks) TableName() string { | |
tableName := "credit_card_checks" | |
if namespace.GetNamespace() != "" { | |
return namespace.GetNamespace() + "_" + tableName | |
} | |
return tableName | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment