Documentation
¶
Index ¶
- Variables
- func MerchantCertificate(cert tls.Certificate) func(*Merchant) error
- func MerchantCertificateLocation(certLocation, keyLocation string) func(*Merchant) error
- func MerchantDisplayName(displayName string) func(*Merchant) error
- func MerchantDomainName(domainName string) func(*Merchant) error
- func MerchantSessionDefaultPaymentSessionRequest(defaultPaymentSessionRequest PaymentSessionRequest) func(*Merchant) error
- func MerchantSessionSandbox(sandbox bool) func(*Merchant) error
- func ProcessingCertificate(cert tls.Certificate) func(*Merchant) error
- func ProcessingCertificateLocation(certLocation, keyLocation string) func(*Merchant) error
- type Contact
- type Header
- type Merchant
- func (m Merchant) DecryptResponse(r *Response) (*Token, error)
- func (m Merchant) DecryptToken(t *PKPaymentToken) (*Token, error)
- func (m *Merchant) IsSandbox() bool
- func (m *Merchant) LoadMerchantCertificate(certEncoded, keyEncoded string) error
- func (m *Merchant) LoadProcessingCertificate(certEncoded, keyEncoded string) error
- func (m *Merchant) PaymentSession(validationURL string, req PaymentSessionRequest) (session []byte, err error)
- func (m Merchant) Session(url string) (sessionPayload []byte, err error)
- type PKPaymentToken
- type PaymentData
- type PaymentMethod
- type PaymentSessionRequest
- type Response
- type Token
Constants ¶
This section is empty.
Variables ¶
var ( // AppleRootCertificatePath is the relative path to Apple's root certificate AppleRootCertificatePath = "AppleRootCA-G3.cer" // TransactionTimeWindow is the window of time, in minutes, where // transactions can fit to limit replay attacks TransactionTimeWindow = 5 * time.Minute )
Functions ¶
func MerchantCertificate ¶
func MerchantCertificate(cert tls.Certificate) func(*Merchant) error
func MerchantDisplayName ¶
func MerchantDomainName ¶
func MerchantSessionDefaultPaymentSessionRequest ¶
func MerchantSessionDefaultPaymentSessionRequest(defaultPaymentSessionRequest PaymentSessionRequest) func(*Merchant) error
func MerchantSessionSandbox ¶
func ProcessingCertificate ¶
func ProcessingCertificate(cert tls.Certificate) func(*Merchant) error
Types ¶
type Contact ¶
type Contact struct { GivenName string FamilyName string EmailAddress string AddressLines []string AdministrativeArea string Locality string PostalCode string Country string CountryCode string }
Contact is the struct that contains billing/shipping information from an Apple Pay response
type Header ¶
type Header struct { ApplicationData string `json:"applicationData,omitempty"` EphemeralPublicKey []byte `json:"ephemeralPublicKey,omitempty"` WrappedKey []byte `json:"wrappedKey,omitempty"` PublicKeyHash []byte `json:"publicKeyHash,omitempty"` TransactionID string `json:"transactionId,omitempty"` }
type Merchant ¶
type Merchant struct {
// contains filtered or unexported fields
}
func (Merchant) DecryptResponse ¶
DecryptResponse calls DecryptToken(r.Token)
func (Merchant) DecryptToken ¶
func (m Merchant) DecryptToken(t *PKPaymentToken) (*Token, error)
DecryptToken decrypts an Apple Pay token
func (*Merchant) IsSandbox ¶
IsSandbox check if the merchant configuration is for sandbox or prod env
func (*Merchant) LoadMerchantCertificate ¶
func (*Merchant) LoadProcessingCertificate ¶
func (*Merchant) PaymentSession ¶
func (m *Merchant) PaymentSession(validationURL string, req PaymentSessionRequest) (session []byte, err error)
type PKPaymentToken ¶
type PKPaymentToken struct { TransactionIdentifier string `json:"transactionIdentifier,omitempty"` PaymentMethod PaymentMethod `json:"paymentMethod,omitempty"` PaymentData PaymentData `json:"paymentData,omitempty"` // contains filtered or unexported fields }
PKPaymentToken is the payment information returned by Apple Pay with all data, and an encrypted token See https://developer.apple.com/library/content/documentation/PassKit/Reference/PaymentTokenJSON/PaymentTokenJSON.html
func (PKPaymentToken) PublicKeyHash ¶
func (t PKPaymentToken) PublicKeyHash() ([]byte, error)
PublicKeyHash returns the hash of the public key used in the token after checking the message's signature. This is useful for selecting the appropriate processing key for merchants/PSPs that may have many.
func (*PKPaymentToken) SetTransactionTime ¶
func (t *PKPaymentToken) SetTransactionTime(transactionTime time.Time) error
SetTransactionTime sets the time the merchant received the token. This is useful to protect against replay attacks. By default this value is set to time.Now(), when the token is decrypted. It may be useful to change the transaction time window (see the global variable TransactionTimeWindow)
type PaymentData ¶
type PaymentMethod ¶
type PaymentSessionRequest ¶
type Response ¶
type Response struct { ShippingContact Contact BillingContact Contact Token PKPaymentToken }
Response is the full response from the user's device after an Apple Pay request
type Token ¶
type Token struct { // ApplicationPrimaryAccountNumber is the device-specific account number of the card that funds this // transaction ApplicationPrimaryAccountNumber string `json:"applicationPrimaryAccountNumber,omitempty"` // ApplicationExpirationDate is the card expiration date in the format YYMMDD ApplicationExpirationDate string `json:"applicationExpirationDate,omitempty"` // CurrencyCode is the ISO 4217 numeric currency code, as a string to preserve leading zeros CurrencyCode string `json:"currencyCode,omitempty"` // TransactionAmount is the value of the transaction TransactionAmount float64 `json:"transactionAmount,omitempty"` // CardholderName is the name on the card CardholderName string `json:"cardholderName,omitempty"` // DeviceManufacturerIdentifier is a hex-encoded device manufacturer identifier DeviceManufacturerIdentifier string `json:"deviceManufacturerIdentifier,omitempty"` // PaymentDataType is either 3DSecure or, if using Apple Pay in China, EMV PaymentDataType string `json:"paymentDataType,omitempty"` // PaymentData contains detailed payment data PaymentData struct { // OnlinePaymentCryptogram is the 3-D Secure cryptogram OnlinePaymentCryptogram string `json:"onlinePaymentCryptogram,omitempty"` // ECIIndicator is the Electronic Commerce Indicator for the status of 3-D Secure ECIIndicator string `json:"eciIndicator,omitempty"` // EMVData is the output from the Secure Element EMVData []byte `json:"emvData,omitempty"` // EncryptedPINData is the PIN encrypted with the bank's key EncryptedPINData string `json:"encryptedPINData,omitempty"` } `json:"paymentData,omitempty"` }
Token is the decrypted form of Response.Token.PaymentData.Data https://developer.apple.com/library/archive/documentation/PassKit/Reference/PaymentTokenJSON/PaymentTokenJSON.html#//apple_ref/doc/uid/TP40014929