cybersource

package
v1.0.227 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2019 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"`
}

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

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.

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

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

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

Jump to

Keyboard shortcuts

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