Documentation ¶
Index ¶
- Constants
- type AmountDetails
- type AuthorizationOptions
- type BillingInformation
- type CaptureOptions
- type CardInformation
- type CardType
- type ClientReferenceInformation
- type CommerceIndicatorType
- type ConsumerAuthenticationInformation
- type Customer
- type CybersourceClient
- func (client *CybersourceClient) Authorize(request *sleet.AuthorizationRequest) (*sleet.AuthorizationResponse, error)
- func (client *CybersourceClient) AuthorizeWithContext(ctx context.Context, request *sleet.AuthorizationRequest) (*sleet.AuthorizationResponse, error)
- func (client *CybersourceClient) Capture(request *sleet.CaptureRequest) (*sleet.CaptureResponse, error)
- func (client *CybersourceClient) CaptureWithContext(ctx context.Context, request *sleet.CaptureRequest) (*sleet.CaptureResponse, error)
- func (client *CybersourceClient) Refund(request *sleet.RefundRequest) (*sleet.RefundResponse, error)
- func (client *CybersourceClient) RefundWithContext(ctx context.Context, request *sleet.RefundRequest) (*sleet.RefundResponse, error)
- func (client *CybersourceClient) Void(request *sleet.VoidRequest) (*sleet.VoidResponse, error)
- func (client *CybersourceClient) VoidWithContext(ctx context.Context, request *sleet.VoidRequest) (*sleet.VoidResponse, error)
- type Detail
- type ErrorInformation
- type Initiator
- type InstrumentIdentifier
- type LineItem
- type Link
- type Links
- type MerchantDefinedInformation
- type OrderInformation
- type Partner
- type PaymentInformation
- type PaymentInstrument
- type ProcessingAction
- type ProcessingActionTokenType
- type ProcessingInformation
- type ProcessorInformation
- type Request
- type Response
- type ShippingAddress
- type ShippingDetails
- type TokenInformation
- type TokenizedCard
Constants ¶
const ( InitiatorTypeMerchant = "merchant" InitiatorTypeConsumer = "consumer" )
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 CaptureOptions ¶ added in v1.1.1153
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 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 Customer ¶ added in v1.1.1365
type Customer struct {
ID string `json:"id"`
}
Customer stores tokenized customer information
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 ¶
func (client *CybersourceClient) Authorize(request *sleet.AuthorizationRequest) (*sleet.AuthorizationResponse, error)
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) AuthorizeWithContext ¶ added in v1.1.1297
func (client *CybersourceClient) AuthorizeWithContext(ctx context.Context, request *sleet.AuthorizationRequest) (*sleet.AuthorizationResponse, error)
AuthorizeWithContext 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) CaptureWithContext ¶ added in v1.1.1297
func (client *CybersourceClient) CaptureWithContext(ctx context.Context, request *sleet.CaptureRequest) (*sleet.CaptureResponse, error)
CaptureWithContext 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) RefundWithContext ¶ added in v1.1.1297
func (client *CybersourceClient) RefundWithContext(ctx context.Context, request *sleet.RefundRequest) (*sleet.RefundResponse, error)
RefundWithContext 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.
func (*CybersourceClient) VoidWithContext ¶ added in v1.1.1297
func (client *CybersourceClient) VoidWithContext(ctx context.Context, request *sleet.VoidRequest) (*sleet.VoidResponse, error)
VoidWithContext 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 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 InstrumentIdentifier ¶ added in v1.1.1365
type InstrumentIdentifier struct {
ID string `json:"id"`
}
InstrumentIdentifier stores tokenized payment method identifier information
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 Links ¶
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
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 PaymentInstrument ¶ added in v1.1.1365
type PaymentInstrument struct {
ID string `json:"id"`
}
PaymentInstrument stores tokenized payment method information
type ProcessingAction ¶ added in v1.1.1365
type ProcessingAction string
ProcessingAction defines actions to be included in the payment to invoke bundled services along with payment.
const (
ProcessingActionTokenCreate ProcessingAction = "TOKEN_CREATE"
)
type ProcessingActionTokenType ¶ added in v1.1.1365
type ProcessingActionTokenType string
ProcessingActionTokenType defines token types that can be created when using ProcessingActionTokenCreate.
const ( ProcessingActionTokenTypeCustomer ProcessingActionTokenType = "customer" ProcessingActionTokenTypePaymentInstrument ProcessingActionTokenType = "paymentInstrument" ProcessingActionTokenTypeInstrumentIdentifier ProcessingActionTokenType = "instrumentIdentifier" ProcessingActionTokenTypeShippingAddress ProcessingActionTokenType = "shippingAddress" )
type ProcessingInformation ¶
type ProcessingInformation struct { Capture bool `json:"capture,omitempty"` CaptureOptions *CaptureOptions `json:"captureOptions,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"` ActionList []ProcessingAction `json:"actionList,omitempty"` ActionTokenTypes []ProcessingActionTokenType `json:"actionTokenTypes,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"` TokenInformation *TokenInformation `json:"tokenInformation,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 ShippingAddress ¶ added in v1.1.1365
type ShippingAddress struct {
ID string `json:"id"`
}
ShippingAddress stores tokenized shipping address information.
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 TokenInformation ¶ added in v1.1.1366
type TokenInformation struct { Customer *Customer `json:"customer,omitempty"` PaymentInstrument *PaymentInstrument `json:"paymentInstrument,omitempty"` InstrumentIdentifier *InstrumentIdentifier `json:"instrumentIdentifier,omitempty"` ShippingAddress *ShippingAddress `json:"shippingAddress,omitempty"` }
TokenInformation stores tokens that were created as a side-effect of a transaction
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