processing

package
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 1, 2024 License: GPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// TransactionTimeWindow is the window of time, in minutes, where
	// transactions can fit to limit replay attacks
	TransactionTimeWindow = 5 * time.Minute
)

Functions

func LoadProcessingKeyPair

func LoadProcessingKeyPair(processingKeyPem, processingCertPem []byte) (tls.Certificate, error)

Types

type ApplePayPayment

type ApplePayPayment struct {
	ShippingContact *ApplePayPaymentContact `json:"shippingContact,omitempty"`
	BillingContact  *ApplePayPaymentContact `json:"billingContact,omitempty"`
	Token           ApplePayPaymentToken    `json:"token"`
}

ApplePayPayment is the full response from the user's device after an Apple Pay request https://developer.apple.com/documentation/apple_pay_on_the_web/applepaypayment

type ApplePayPaymentContact

type ApplePayPaymentContact struct {
	PhoneNumber           string   `json:"phoneNumber"`
	EmailAddress          string   `json:"emailAddress"`
	GivenName             string   `json:"givenName"`
	FamilyName            string   `json:"familyName"`
	PhoneticGivenName     string   `json:"phoneticGivenName"`
	PhoneticFamilyName    string   `json:"phoneticFamilyName"`
	AddressLines          []string `json:"addressLines"`
	Locality              string   `json:"locality"`
	SubLocality           string   `json:"subLocality"`
	PostalCode            string   `json:"postalCode"`
	AdministrativeArea    string   `json:"administrativeArea"`
	SubAdministrativeArea string   `json:"subAdministrativeArea"`
	Country               string   `json:"country"`
	CountryCode           string   `json:"countryCode"`
}

ApplePayPaymentContact is the struct that contains billing/shipping information from an Apple Pay response https://developer.apple.com/documentation/apple_pay_on_the_web/applepaypaymentcontact

type ApplePayPaymentMethod

type ApplePayPaymentMethod struct {
	Type           string                 `json:"type"`
	Network        string                 `json:"network"`
	DisplayName    string                 `json:"displayName"`
	BillingContact ApplePayPaymentContact `json:"billingContact,omitempty"`
}

ApplePayPaymentMethod https://developer.apple.com/documentation/apple_pay_on_the_web/applepaypaymentmethod

type ApplePayPaymentToken

type ApplePayPaymentToken struct {
	TransactionIdentifier string                `json:"transactionIdentifier"`
	PaymentMethod         ApplePayPaymentMethod `json:"paymentMethod"`
	PaymentData           PaymentData           `json:"paymentData"`
	// contains filtered or unexported fields
}

ApplePayPaymentToken https://developer.apple.com/documentation/apple_pay_on_the_web/applepaypaymenttoken

type Header struct {
	ApplicationData    string
	EphemeralPublicKey []byte
	WrappedKey         []byte
	PublicKeyHash      []byte
	TransactionID      string
}

Header header for PaymentData

type Processing

type Processing struct {
	// contains filtered or unexported fields
}

Processing usage struct

func New

func New(merchantId string, processingKeyPem, processingCertPem []byte, rootCaPem []byte) (*Processing, error)

New construct Apple Pay processing struct instance

  • processingKeyPem your Apple Pay processing private key pem format byte stream
  • processingCertPem your Apple Pay processing certificate pem format byte stream
  • rootCaPem Apple Pay Root CA pem byte stream

about pem format rootCaPem DER format file at: https://www.apple.com/certificateauthority/AppleRootCA-G3.cer use openssl transfer to pem format as: openssl x509 -inform der -in AppleRootCA-G3.cer -out AppleRootCA-G3-converted.pem

func (*Processing) DecryptApplePayPayment

func (p *Processing) DecryptApplePayPayment(r *ApplePayPayment) (*Token, error)

DecryptApplePayPayment calls DecryptApplePayPaymentToken(r.Token)

func (*Processing) DecryptApplePayPaymentToken

func (p *Processing) DecryptApplePayPaymentToken(t *ApplePayPaymentToken) (*Token, error)

DecryptApplePayPaymentToken decrypts an Apple Pay token

type Token

type Token struct {
	// ApplicationPrimaryAccountNumber is the device-specific account number of the card that funds this
	// transaction
	ApplicationPrimaryAccountNumber string
	// ApplicationExpirationDate is the card expiration date in the format YYMMDD
	ApplicationExpirationDate string
	// CurrencyCode is the ISO 4217 numeric currency code, as a string to preserve leading zeros
	CurrencyCode string
	// TransactionAmount is the value of the transaction
	TransactionAmount float64
	// CardholderName is the name on the card
	CardholderName string
	// DeviceManufacturerIdentifier is a hex-encoded device manufacturer identifier
	DeviceManufacturerIdentifier string
	// PaymentDataType is either 3DSecure or, if using Apple Pay in China, EMV
	PaymentDataType string
	// PaymentData contains detailed payment data
	PaymentData struct {

		// OnlinePaymentCryptogram is the 3-D Secure cryptogram
		OnlinePaymentCryptogram []byte
		// ECIIndicator is the Electronic Commerce Indicator for the status of 3-D Secure
		ECIIndicator string

		// EMVData is the output from the Secure Element
		EMVData []byte
		// EncryptedPINData is the PIN encrypted with the bank's key
		EncryptedPINData string
	}
}

Token is the decrypted form of ApplePayPayment.Token.PaymentData.Data

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL