Documentation ¶
Index ¶
- Constants
- func Bool(value bool) *bool
- func DetectCardType(formattedCardNumber string) string
- func FormatCardNumber(number string) string
- func FormatMonthYear[T time.Month | int](month T, year int) (string, string)
- func PubKeyFromBytes(b []byte, publicExponent ...int) *rsa.PublicKey
- type BrowserInfo
- type Encrypter
- func (enc *Encrypter) Encrypt(number, securityCode string, month, year int) (string, error)
- func (enc *Encrypter) EncryptField(key, value string) (string, error)
- func (enc *Encrypter) EncryptFields(fields map[string]string) (string, error)
- func (enc *Encrypter) EncryptPlaintext(plaintext []byte) (string, error)
- func (enc *Encrypter) Reset() (err error)
- type GenerationTimeFunc
Constants ¶
const ( // GenerationTimeKey is the JSON key for the generated time. GenerationTimeKey = "generationtime" // GenerationTimeFormat is the time format. // This is identical to time.RFC3339Nano except there is only three trailing zeros. GenerationTimeFormat = "2006-01-02T15:04:05.000Z07:00" // KeyNumber is the card number field key. KeyNumber = "number" // KeyExpiryMonth is the expiry month field key. KeyExpiryMonth = "expiryMonth" // KeyExpiryYear is the expiry year field key. KeyExpiryYear = "expiryYear" // KeySecurityCode is the security code field key. KeySecurityCode = "cvc" )
Variables ¶
This section is empty.
Functions ¶
func DetectCardType ¶ added in v1.3.2
DetectCardType detects the type of the given card number. The card number must have no whitespace characters.
If the card's type cannot be detected, then "noBrand" is returned which is also what Adyen uses if it cannot detect the card type.
func FormatCardNumber ¶ added in v1.3.0
FormatCardNumber formats the given card number into the Adyen format. Numbers less than 15 digits (excluding white space) are ignored.
Examples:
0123456789012345 -> 0123 4567 8901 2345
0123 4567 8901 2345 -> (no change)
0123 456789012345 -> 0123 4567 8901 2345
func FormatMonthYear ¶ added in v1.3.0
FormatMonthYear formats a card expiry month and year into the Adyen format. It is assumed that the given year is the fully-qualified year, like "2020" (instead of "20".)
Examples:
5, 2024 -> "05", "2024"
12, 2024 -> "12", "2024"
Types ¶
type BrowserInfo ¶ added in v1.3.3
type BrowserInfo struct { // AcceptHeader is the value of the browser's Accept header. AcceptHeader string `json:"acceptHeader"` // ColorDepth is the browser's color depth in bits per pixel. // This is the "screen.colorDepth" value. ColorDepth int `json:"colorDepth"` // JavaEnabled is if the browser is capable of executing Java. JavaEnabled bool `json:"javaEnabled"` // JavaScriptEnabled is an optional field indicating if the browser // is capable of executing JavaScript. If not specified, the Adyen // API assumes this value is true. // // To use a boolean value, use Bool. JavaScriptEnabled *bool `json:"javaScriptEnabled,omitempty"` // Language is the name of the language used by the browser. // This is the value of "navigator.language". Language string `json:"language"` // ScreenHeight is the browser's screen height. ScreenHeight int `json:"screenHeight"` // ScreenWidth is the browser's screen width. ScreenWidth int `json:"screenWidth"` // TimeZoneOffset is the time difference between UTC time and the browser's // local time in minutes. TimeZoneOffset int `json:"timeZoneOffset"` // UserAgent is the browser's user agent. UserAgent string `json:"userAgent"` }
BrowserInfo represents the "browserInfo" object as defined in the Adyen documentation.
Read more: https://docs.adyen.com/online-payments/3d-secure/api-reference#browserinfo
type Encrypter ¶ added in v1.3.0
type Encrypter struct { // Version is the Adyen version that this Encrypter will // seal plaintext for. Version string // GetGenerationTime gets the time.Time to use for the // required "generationtime" JSON field. The default is // time.Now. // // This may be modified by the caller to return custom times // that differ from the default. GetGenerationTime GenerationTimeFunc // contains filtered or unexported fields }
An Encrypter encrypts content into the Adyen format using an RSA public key and AES-256.
func NewEncrypter ¶ added in v1.3.0
NewEncrypter creates a new Encrypter with the given version and RSA public key.
Calls to Encrypter.EncryptPlaintext will panic if pubKey == nil.
func (*Encrypter) Encrypt ¶ added in v1.3.0
Encrypt encrypts a card number, security code (CVV/CVC), expiry month and year into a map and correctly formats all values using FormatCardNumber and FormatMonthYear.
func (*Encrypter) EncryptField ¶ added in v1.3.0
EncryptField encrypts a single key and value.
func (*Encrypter) EncryptFields ¶ added in v1.3.0
EncryptFields encrypts a map.
func (*Encrypter) EncryptPlaintext ¶ added in v1.3.0
EncryptPlaintext seals the given plaintext and returns the sealed content in the Adyen format.
Most callers should use Encrypt, EncryptField or EncryptFields instead.
type GenerationTimeFunc ¶ added in v1.1.4
GenerationTimeFunc is a function responsible for returning the time that a payload was generated at.