cybersource

package
v1.1.1002 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	InitiatorTypeMerchant = "merchant"
	InitiatorTypeConsumer = "consumer"
)
View Source
const (
	AmexCryptogramMaxLength   = 40
	AmexCryptogramSplitLength = 20
	TransactionTypeInApp      = "1"
	PaymentSolutionApplepay   = "001"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AmountDetails added in v1.0.206

type AmountDetails struct {
	AuthorizedAmount string `json:"authorizedAmount,omitempty"`
	Amount           string `json:"totalAmount,omitempty"`
	Currency         string `json:"currency"`
	DiscountAmount   string `json:"discountAmount,omitempty"` // Level 3 field
	TaxAmount        string `json:"taxAmount,omitempty"`      // Level 3 field
	FreightAmount    string `json:"freightAmount,omitempty"`  // Level 3 field - If set, "totalAmount" must also be included
	DutyAmount       string `json:"dutyAmount,omitempty"`     // Level 3 field
}

AmountDetails specifies various amount, currency information for auth calls

type AuthorizationOptions added in v1.1.824

type AuthorizationOptions struct {
	Initiator *Initiator `json:"initiator,omitempty"`
}

type BillingInformation

type BillingInformation struct {
	FirstName  string `json:"firstName"`
	LastName   string `json:"lastName"`
	Address1   string `json:"address1"`
	Address2   string `json:"address2,omitempty"`
	PostalCode string `json:"postalCode"`
	Locality   string `json:"locality"`
	AdminArea  string `json:"administrativeArea"`
	Country    string `json:"country"`
	Phone      string `json:"phoneNumber"`
	Company    string `json:"company,omitempty"`
	Email      string `json:"email,omitempty"`
}

BillingInformation contains billing address for auth call

type CardInformation

type CardInformation struct {
	ExpYear  string `json:"expirationYear"`
	ExpMonth string `json:"expirationMonth"`
	Number   string `json:"number"`
	CVV      string `json:"securityCode"`
}

CardInformation stores raw credit card details

type CardType added in v1.1.968

type CardType string
const (
	CardTypeVisa       CardType = "001"
	CardTypeMastercard CardType = "002"
	CardTypeAmex       CardType = "003"
	CardTypeDiscover   CardType = "004"
)

type ClientReferenceInformation

type ClientReferenceInformation struct {
	Code          string  `json:"code"`
	TransactionID string  `json:"transactionID"`
	Partner       Partner `json:"partner,omitempty"`
}

ClientReferenceInformation is used by the client to identify transactions on their side to tie with Cybersource transactions

type CommerceIndicatorType added in v1.1.968

type CommerceIndicatorType string
const (
	CommerceIndicatorInternet   CommerceIndicatorType = "internet"
	CommerceIndicatorMastercard CommerceIndicatorType = "spa"
	CommerceIndicatorAmex       CommerceIndicatorType = "aesk"
	CommerceIndicatorDiscover   CommerceIndicatorType = "dipb"
)

type ConsumerAuthenticationInformation added in v1.1.968

type ConsumerAuthenticationInformation struct {
	UcafAuthenticationData  string `json:"ucafAuthenticationData,omitempty"`
	UcafCollectionIndicator string `json:"ucafCollectionIndicator,omitempty"`
	Xid                     string `json:"xid,omitempty"`
	Cavv                    string `json:"cavv,omitempty"`
}

type CybersourceClient

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

CybersourceClient represents an HTTP client and the associated authentication information required for making an API request.

func NewClient

func NewClient(env common.Environment, merchantID string, sharedSecretKeyID string, sharedSecretKey string) *CybersourceClient

NewClient returns a new client for making CyberSource API requests for a given merchant using a specified authentication key.

func NewWithHttpClient

func NewWithHttpClient(env common.Environment, merchantID string, sharedSecretKeyID string, sharedSecretKey string, httpClient *http.Client) *CybersourceClient

NewWithHttpClient returns a client for making CyberSource API requests for a given merchant using a specified authentication key. The given HTTP client will be used to make the requests.

func (*CybersourceClient) Authorize

Authorize make a payment authorization request to CyberSource for the given payment details. If successful, the authorization response will be returned. If level 3 data is present in the authorization request and contains a CustomerReference, the ClientReferenceInformation of this request will be overridden in order to to match the level 3 data's CustomerReference.

func (*CybersourceClient) Capture

func (client *CybersourceClient) Capture(request *sleet.CaptureRequest) (*sleet.CaptureResponse, error)

Capture captures an authorized payment through CyberSource. If successful, the capture response will be returned. Multiple captures can be made on the same authorization, but the total amount captured should not exceed the total authorized amount.

func (*CybersourceClient) Refund

func (client *CybersourceClient) Refund(request *sleet.RefundRequest) (*sleet.RefundResponse, error)

Refund refunds a CyberSource payment. If successful, the refund response will be returned. Multiple refunds can be made on the same payment, but the total amount refunded should not exceed the payment total.

func (*CybersourceClient) Void

func (client *CybersourceClient) Void(request *sleet.VoidRequest) (*sleet.VoidResponse, error)

Void cancels a CyberSource payment. If successful, the void response will be returned. A previously voided payment or one that has already been settled cannot be voided.

type Detail added in v1.0.206

type Detail struct {
	Field  string `json:"field"`
	Reason string `json:"reason"`
}

Detail holds information about an error.

type ErrorInformation added in v1.0.206

type ErrorInformation struct {
	Reason  string    `json:"reason"`
	Message string    `json:"message"`
	Details *[]Detail `json:"details,omitempty"`
}

ErrorInformation holds error information from an otherwise successful authorization request.

type Initiator added in v1.1.824

type Initiator struct {
	InitiatorType          string `json:"type"`
	CredentialStoredOnFile bool   `json:"credentialStoredOnFile"`
	StoredCredentialUsed   bool   `json:"storedCredentialUsed"`
}

type LineItem added in v1.0.246

type LineItem struct {
	ProductCode    string `json:"productCode"`
	ProductName    string `json:"productName"`
	Quantity       string `json:"quantity"`
	UnitPrice      string `json:"unitPrice"`
	TotalAmount    string `json:"totalAmount"`
	DiscountAmount string `json:"discountAmount"`
	UnitOfMeasure  string `json:"unitOfMeasure"`
	CommodityCode  string `json:"commodityCode"`
	TaxAmount      string `json:"taxAmount"`
}

LineItem is a Level3 data field to specify additional info per item for lower processing rates. This is not a default

type Link struct {
	Href   string `json:"href"`
	Method string `json:"method"`
}

Link specifies the REST Method (POST, GET) and string URL to hit

type Links struct {
	Self         *Link `json:"self,omitempty"`
	AuthReversal *Link `json:"authReversal,omitempty"`
	Capture      *Link `json:"capture,omitempty"`
	Refund       *Link `json:"refund,omitempty"`
	Void         *Link `json:"void,omitempty"`
}

Links are part of the response which specify URLs to hit via REST to take follow-up actions (capture, void, etc)

type MerchantDefinedInformation added in v1.1.884

type MerchantDefinedInformation struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

MerchantDefinedInformation stores the custom data that the merchant defines.

type OrderInformation

type OrderInformation struct {
	BillTo        BillingInformation `json:"billTo"`
	AmountDetails AmountDetails      `json:"amountDetails"`
	LineItems     []LineItem         `json:"lineItems,omitempty"` // Level 3 field
	ShipTo        ShippingDetails    `json:"shipTo,omitempty"`    // Level 3 field
}

OrderInformation is also used for authorize mainly to specify billing details and other Level3 items

type Partner added in v1.1.359

type Partner struct {
	SolutionID string `json:"solutionID,omitempty"`
}

type PaymentInformation

type PaymentInformation struct {
	Card          *CardInformation `json:"card,omitempty"`
	TokenizedCard *TokenizedCard   `json:"tokenizedCard,omitempty"`
}

PaymentInformation stores Card or TokenizedCard information (but can be extended to other payment types)

type ProcessingInformation

type ProcessingInformation struct {
	Capture              bool                  `json:"capture,omitempty"`
	CommerceIndicator    string                `json:"commerceIndicator"` // typically internet
	PaymentSolution      string                `json:"paymentSolution"`
	PurchaseLevel        string                `json:"purchaseLevel,omitempty"` // Specifies if level 3 data is being sent
	AuthorizationOptions *AuthorizationOptions `json:"authorizationOptions,omitempty"`
}

ProcessingInformation specifies various fields for authorize for options (auto-capture, Level3 Data, etc)

type ProcessorInformation

type ProcessorInformation struct {
	ApprovalCode     string `json:"approvalCode"`
	CardVerification struct {
		ResultCode string `json:"resultCode"`
	} `json:"cardVerification"`
	ResponseCode string `json:"responseCode"`
	AVS          struct {
		Code    string `json:"code"`
		CodeRaw string `json:"codeRaw"`
	} `json:"avs"`
	TransactionID string `json:"transactionId"`
}

ProcessorInformation contains processor specific responses sent back primarily through authorize call

type Request

type Request struct {
	ClientReferenceInformation        *ClientReferenceInformation        `json:"clientReferenceInformation,omitempty"`
	ProcessingInformation             *ProcessingInformation             `json:"processingInformation,omitempty"`
	OrderInformation                  *OrderInformation                  `json:"orderInformation,omitempty"`
	PaymentInformation                *PaymentInformation                `json:"paymentInformation,omitempty"`
	MerchantDefinedInformation        []MerchantDefinedInformation       `json:"merchantDefinedInformation,omitempty"`
	ConsumerAuthenticationInformation *ConsumerAuthenticationInformation `json:"consumerAuthenticationInformation,omitempty"`
}

Request contains the information needed for all request types (Auth, Capture, Void, Refund)

type Response

type Response struct {
	Links                      *Links                      `json:"_links,omitempty"`
	ID                         *string                     `json:"id,omitempty"`
	SubmitTimeUTC              string                      `json:"submitTimeUtc"`
	Status                     string                      `json:"status"` // TODO: Make into enum
	ReconciliationID           *string                     `json:"reconciliationId,omitempty"`
	ErrorInformation           *ErrorInformation           `json:"errorInformation,omitempty"`
	ClientReferenceInformation *ClientReferenceInformation `json:"clientReferenceInformation,omitempty"`
	ProcessorInformation       *ProcessorInformation       `json:"processorInformation,omitempty"`
	OrderInformation           *OrderInformation           `json:"orderInformation,omitempty"`
	ErrorReason                *string                     `json:"reason,omitempty"`
	ErrorMessage               *string                     `json:"message,omitempty"`
	Details                    *[]Detail                   `json:"details,omitempty"`
}

Response contains all of the fields for all Cybersource API call responses

type ShippingDetails added in v1.0.246

type ShippingDetails struct {
	FirstName      string `json:"firstName,omitempty"`
	LastName       string `json:"lastName,omitempty"`
	Address1       string `json:"address1,omitempty"`
	Address2       string `json:"address2,omitempty"`
	Locality       string `json:"locality,omitempty"`
	AdminArea      string `json:"administrativeArea,omitempty"`
	PostalCode     string `json:"postalCode,omitempty"`
	Country        string `json:"country,omitempty"`
	District       string `json:"district,omitempty"`
	BuildingNumber string `json:"buildingNumber,omitempty"`
	Phone          string `json:"phoneNumber,omitempty"`
	Company        string `json:"company,omitempty"`
}

ShippingDetails contains shipping information that can be used for Authorization signals

type TokenizedCard added in v1.1.968

type TokenizedCard struct {
	Number          string `json:"number"`
	ExpirationMonth string `json:"expirationMonth"`
	ExpirationYear  string `json:"expirationYear"`
	Type            string `json:"type,omitempty"`
	TransactionType string `json:"transactionType"`
	Cryptogram      string `json:"cryptogram"`
}

TokenizedCard stores tokenized card details

Jump to

Keyboard shortcuts

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