cybersource

package
v1.0.281 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Sandbox is the CyberSource test environment for testing API requests.
	Sandbox = NewEnvironment("apitest.cybersource.com")
	// Production is the CyberSource live environment for executing real payments.
	Production = NewEnvironment("api.cybersource.com")
)

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
}

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"`
}

type CardInformation

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

type ClientReferenceInformation

type ClientReferenceInformation struct {
	Code          string `json:"code"`
	TransactionID string `json:"transactionID"`
}

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 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 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 Environment added in v1.0.206

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

func NewEnvironment added in v1.0.206

func NewEnvironment(host string) Environment

func (Environment) Host added in v1.0.206

func (e Environment) Host() string

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 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"`
}
type Link struct {
	Href   string `json:"href"`
	Method string `json:"method"`
}
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"`
}

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
}

type PaymentInformation

type PaymentInformation struct {
	Card CardInformation `json:"card"`
}

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
}

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"`
}

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"`
}

Should we just combine these to one Request and have pointers?

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"`
}

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"`
}

Jump to

Keyboard shortcuts

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