Documentation
¶
Index ¶
- Variables
- type Address
- type AuthorizeParams
- type AuthorizeResponse
- type CaptureParams
- type CaptureResponse
- type CompleteAuthorizeParams
- type CompleteAuthorizeResponse
- type CreateCreditCardParams
- type CreditCard
- type CreditCardManager
- type CreditCardResponse
- type CustomerCreditCard
- type DeleteCreditCardParams
- type DeleteCreditCardResponse
- type GetCreditCardParams
- type GetCreditCardResponse
- type IntegrationGateway
- type ListCreditCardsParams
- type ListCreditCardsResponse
- type Params
- type PaymentGateway
- type PaymentMethod
- type RefundParams
- type RefundResponse
- type SavedCreditCard
- type Transaction
- type VoidParams
- type VoidResponse
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // Mostly copied from Stripe, might need to be modified when integrating other payment gateways. ErrInvalidNumber = errors.New("gomerchant: the card number is not a valid credit card number.") ErrInvalidExpiryMonth = errors.New("gomerchant: the card's expiration month is invalid.") ErrInvalidExpiryYear = errors.New("gomerchant: the card's expiration year is invalid.") ErrInvalidCVC = errors.New("gomerchant: the card's security code is invalid.") ErrIncorrectNumber = errors.New("gomerchant: the card number is incorrect.") ErrExpiredCard = errors.New("gomerchant: the card has expired.") ErrIncorrectCVC = errors.New("gomerchant: the card's security code is incorrect.") ErrIncorrectZip = errors.New("gomerchant: the card's zip code failed validation.") ErrCardDeclined = errors.New("gomerchant: the card was declined.") ErrMissing = errors.New("gomerchant: there is no card on a customer that is being charged.") ErrProcessingError = errors.New("gomerchant: an error occurred while processing the card.") )
View Source
var Brands = map[string]*regexp.Regexp{ `visa`: regexp.MustCompile(`^4\d{12}(\d{3})?$`), `master`: regexp.MustCompile(`^(5[1-5]\d{4}|677189)\d{10}$`), `discover`: regexp.MustCompile(`^(6011|65\d{2}|64[4-9]\d)\d{12}|(62\d{14})$`), `american_express`: regexp.MustCompile(`^3[47]\d{13}$`), `diners_club`: regexp.MustCompile(`^3(0[0-5]|[68]\d)\d{11}$`), `jcb`: regexp.MustCompile(`^35(27|28|29|[3-8]\d)\d{12}$`), `switch`: regexp.MustCompile(`^6759\d{12}(\d{2,3})?$`), `solo`: regexp.MustCompile(`^6767\d{12}(\d{2,3})?$`), `dankort`: regexp.MustCompile(`^5019\d{12}$`), `maestro`: regexp.MustCompile(`^(5[06-8]|6\d)\d{10,17}$`), `forbrugsforeningen`: regexp.MustCompile(`^600722\d{10}$`), `laser`: regexp.MustCompile(`^(6304|6706|6771|6709)\d{8}(\d{4}|\d{6,7})?$`), }
View Source
var ErrNotSupportedPaymentMethod = errors.New("not supported payment method")
Functions ¶
This section is empty.
Types ¶
type AuthorizeParams ¶
type AuthorizeParams struct {
Amount uint64
Currency string
Customer string
Description string
OrderID string
BillingAddress *Address
ShippingAddress *Address
PaymentMethod *PaymentMethod
Params
}
AuthorizeParams authorize params
type AuthorizeResponse ¶
type AuthorizeResponse struct {
TransactionID string
HandleRequest bool // need process request after authorize or not
RequestHandler func(http.ResponseWriter, *http.Request, Params) error // process request
Params
}
AuthorizeResponse authorize response
type CaptureResponse ¶
CaptureResponse capture response
type CompleteAuthorizeParams ¶
type CompleteAuthorizeParams struct {
Params
}
CompleteAuthorizeParams complete authorize params
type CompleteAuthorizeResponse ¶
type CompleteAuthorizeResponse struct {
Params
}
CompleteAuthorizeResponse complete authorize response
type CreateCreditCardParams ¶
type CreateCreditCardParams struct {
CustomerID string
CreditCard *CreditCard
}
CreateCreditCard Params
type CreditCard ¶
func (CreditCard) Brand ¶
func (creditCard CreditCard) Brand() string
func (CreditCard) ValidNumber ¶
func (creditCard CreditCard) ValidNumber() bool
type CreditCardManager ¶
type CreditCardManager interface {
CreateCreditCard(creditCardParams CreateCreditCardParams) (CreditCardResponse, error)
GetCreditCard(creditCardParams GetCreditCardParams) (GetCreditCardResponse, error)
ListCreditCards(listCreditCardsParams ListCreditCardsParams) (ListCreditCardsResponse, error)
DeleteCreditCard(deleteCreditCardParams DeleteCreditCardParams) (DeleteCreditCardResponse, error)
}
CreditCardManager interface
type CreditCardResponse ¶
type CustomerCreditCard ¶
type CustomerCreditCard struct {
CustomerID string
CustomerName string
CreditCardID string
MaskedNumber string
ExpMonth uint
ExpYear uint
Brand string
Params
}
CustomerCreditCard CustomerCard defination
type DeleteCreditCardParams ¶
Delete Credit Cards Params
type DeleteCreditCardResponse ¶
type DeleteCreditCardResponse struct {
Params
}
type GetCreditCardParams ¶
Get Credit Cards Params
type GetCreditCardResponse ¶
type GetCreditCardResponse struct {
CreditCard *CustomerCreditCard
Params
}
type IntegrationGateway ¶
type IntegrationGateway interface {
}
IntegrationGateway integration gateway
type ListCreditCardsParams ¶
type ListCreditCardsParams struct {
CustomerID string
}
List Credit Cards Params
type ListCreditCardsResponse ¶
type ListCreditCardsResponse struct {
CreditCards []*CustomerCreditCard
Params
}
type PaymentGateway ¶
type PaymentGateway interface {
Authorize(amount uint64, params AuthorizeParams) (AuthorizeResponse, error)
CompleteAuthorize(paymentID string, params CompleteAuthorizeParams) (CompleteAuthorizeResponse, error)
Capture(transactionID string, params CaptureParams) (CaptureResponse, error)
Refund(transactionID string, amount uint, params RefundParams) (RefundResponse, error)
Void(transactionID string, params VoidParams) (VoidResponse, error)
Query(transactionID string) (Transaction, error)
}
PaymentGateway interface
type PaymentMethod ¶
type PaymentMethod struct {
SavedCreditCard *SavedCreditCard
CreditCard *CreditCard
}
type RefundResponse ¶
RefundResponse refund response
type SavedCreditCard ¶
type Transaction ¶
type VoidResponse ¶
VoidResponse void response
Source Files
¶
Click to show internal directories.
Click to hide internal directories.