authorizenet

package
v1.1.1123 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	InvoiceNumberMaxLength = 20
)
View Source
const (
	MessageResponseCodeAlreadyCaptured = "311"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AVSResultCode added in v1.1.500

type AVSResultCode string

AVSResultCode result of AVS check

const (
	AVSResultNotPresent                AVSResultCode = "B"
	AVSResultError                     AVSResultCode = "E"
	AVSResultNotApplicable             AVSResultCode = "P" // AVS is not applicable for this transaction.
	AVSResultRetry                     AVSResultCode = "R" // AVS was unavailable or timed out.
	AVSResultNotSupportedIssuer        AVSResultCode = "S"
	AVSResultInfoUnavailable           AVSResultCode = "U" // Address information is unavailable.
	AVSResultPostMatchAddressMatch     AVSResultCode = "Y" // The street address and postal code matched.
	AVSResultNoMatch                   AVSResultCode = "N"
	AVSResultPostNoMatchAddressMatch   AVSResultCode = "A"
	AVSResultZipMatchAddressNoMatch    AVSResultCode = "W"
	AVSResultZipMatchAddressMatch      AVSResultCode = "X" // Both the street address and the US ZIP+4 code matched.
	AVSResultPostMatchAddressNoMatch   AVSResultCode = "Z"
	AVSResultNotSupportedInternational AVSResultCode = "G" // The card was issued by a bank outside the U.S. and does not support AVS.
)

type AuthorizeNetClient

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

AuthorizeNetClient uses merchant name and transaction key to process requests. Optionally can provide custom http clients

func NewClient

func NewClient(merchantName string, transactionKey string, environment common.Environment) *AuthorizeNetClient

NewClient uses authentication above with a default http client

func NewWithHttpClient

func NewWithHttpClient(merchantName string, transactionKey string, environment common.Environment, httpClient *http.Client) *AuthorizeNetClient

NewWithHttpClient uses authentication with custom http client

func (*AuthorizeNetClient) Authorize

Authorize a transaction for specified amount using Auth.net REST APIs

func (*AuthorizeNetClient) Capture

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

Capture an authorized transaction by transaction reference using the transactionTypePriorAuthCapture flag

func (*AuthorizeNetClient) Refund

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

Refund a captured transaction with amount and captured transaction reference

func (*AuthorizeNetClient) Void

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

Void an existing authorized transaction

type BillingAddress

type BillingAddress struct {
	FirstName   string  `json:"firstName"`
	LastName    string  `json:"lastName"`
	Company     string  `json:"company"`
	Address     *string `json:"address"`
	City        *string `json:"city"`
	State       *string `json:"state"`
	Zip         *string `json:"zip"`
	Country     *string `json:"country"`
	PhoneNumber *string `json:"phoneNumber"`
}

BillingAddress is used in TransactionRequest for making an auth call

type CAVVResultCode added in v1.1.500

type CAVVResultCode string

CAVVResultCode The cardholder authentication verification value (CAVV) result code from the issuer.

const (
	CAVVResultBadRequest        CAVVResultCode = "0"
	CAVVResultFailed            CAVVResultCode = "1"
	CAVVResultPassed            CAVVResultCode = "2"
	CAVVResultAttemptIncomplete CAVVResultCode = "3"
	CAVVResultSytemError        CAVVResultCode = "4"
)

type CVVResultCode added in v1.1.500

type CVVResultCode string

CVVResultCode result of cvv check

const (
	CVVResultMatched         CVVResultCode = "M"
	CVVResultNoMatch         CVVResultCode = "N"
	CVVResultNotProcessed    CVVResultCode = "P"
	CVVResultNotPresent      CVVResultCode = "S"
	CVVResultUnableToProcess CVVResultCode = "U"
)

type CreateTransactionRequest

type CreateTransactionRequest struct {
	MerchantAuthentication MerchantAuthentication `json:"merchantAuthentication"`
	RefID                  *string                `json:"refId,omitempty"`
	TransactionRequest     TransactionRequest     `json:"transactionRequest"`
}

CreateTransactionRequest specifies the merchant authentication to be used for request as well as transaction details specified in transactionRequest

type CreditCard

type CreditCard struct {
	CardNumber     string `json:"cardNumber"`
	ExpirationDate string `json:"expirationDate"`
	CardCode       string `json:"cardCode,omitempty"`
	IsPaymentToken *bool  `json:"isPaymentToken,omitempty"`
	Cryptogram     string `json:"cryptogram,omitempty"`
}

CreditCard is raw cc info

type Customer added in v1.1.900

type Customer struct {
	Type  string `json:"type,omitempty"`
	Id    string `json:"id,omitempty"`
	Email string `json:"email,omitempty"`
}

type Error

type Error struct {
	ErrorCode string `json:"errorCode"`
	ErrorText string `json:"errorText"`
}

Error specifies a code and text explaining what happened

type LineItem added in v1.1.900

type LineItem struct {
	ItemId      string `json:"itemId,omitempty"`
	Name        string `json:"name,omitempty"`
	Description string `json:"description,omitempty"`
	Quantity    string `json:"quantity,omitempty"`
	UnitPrice   string `json:"unitPrice,omitempty"`
}

type MerchantAuthentication

type MerchantAuthentication struct {
	Name           string `json:"name"`
	TransactionKey string `json:"transactionKey"`
}

MerchantAuthentication is the name/key pair to authenticate Auth.net calls

type Message

type Message struct {
	Code string `json:"code"`
	Text string `json:"text"`
}

Message is similar to Error with code that maps to Auth.net internals and text for human readability

type MessageResponseCode added in v1.1.1035

type MessageResponseCode string

MessageResponseCode message API response codes specific to AuthorizeNet

type Messages

type Messages struct {
	ResultCode ResultCode `json:"resultCode"`
	Message    []Message  `json:"message"`
}

Messages is used to augment responses with codes and readable messages

type Order added in v1.1.780

type Order struct {
	InvoiceNumber string `json:"invoiceNumber"`
}

Order is used in TransactionRequest for passing information about the order

type Payment

type Payment struct {
	CreditCard CreditCard `json:"creditCard"`
}

Payment specifies the credit card to be authorized (only payment option for now)

type Request

type Request struct {
	CreateTransactionRequest CreateTransactionRequest `json:"createTransactionRequest"`
}

Request contains a createTransactionRequest for authorizations

type Response

type Response struct {
	TransactionResponse TransactionResponse `json:"transactionResponse"`
	RefID               string              `json:"refId"`
	Messsages           Messages            `json:"messages"`
}

Response is a generic Auth.net response

type ResponseCode added in v1.1.500

type ResponseCode string

ResponseCode response code representing information about the status of the payment request.

const (
	ResponseCodeApproved ResponseCode = "1"
	ResponseCodeDeclined ResponseCode = "2"
	ResponseCodeError    ResponseCode = "3"
	ResponseCodeHeld     ResponseCode = "4"
)

type ResultCode added in v1.1.500

type ResultCode string

ResultCode result of request (ok/error)

const (
	ResultCodeOK    ResultCode = "Ok"
	ResultCodeError ResultCode = "Error"
)

type ShippingAddress added in v1.1.1048

type ShippingAddress struct {
	FirstName string  `json:"firstName"`
	LastName  string  `json:"lastName"`
	Company   string  `json:"company"`
	Address   *string `json:"address"`
	City      *string `json:"city"`
	State     *string `json:"state"`
	Zip       *string `json:"zip"`
	Country   *string `json:"country"`
}

ShippingAddress is used in TransactionRequest for making an auth call

type Tax added in v1.1.900

type Tax struct {
	Amount      string `json:"amount,omitempty"`
	Name        string `json:"name,omitempty"`
	Description string `json:"description,omitempty"`
}

type TransactionRequest

type TransactionRequest struct {
	TransactionType  TransactionType `json:"transactionType"`
	Amount           *string         `json:"amount,omitempty"`
	Payment          *Payment        `json:"payment,omitempty"`
	RefTransactionID *string         `json:"refTransId,omitempty"`
	Order            *Order          `json:"order,omitempty"`
	LineItem         json.RawMessage `json:"lineItems,omitempty"` // this is really a repeating LineItem, but authorize.net expects it in object not array
	// since not valid json, just going to represent as JSON string
	Tax             *Tax             `json:"tax,omitempty"`
	Duty            *Tax             `json:"duty,omitempty"`
	Shipping        *Tax             `json:"shipping,omitempty"`
	Customer        *Customer        `json:"customer,omitempty"`
	BillingAddress  *BillingAddress  `json:"billTo,omitempty"`
	ShippingAddress *ShippingAddress `json:"shipTo,omitempty"`
}

TransactionRequest has the raw credit card info as Payment and amount to authorize ************************************************************************* ************************************************************************* ***** AUTHORIZE NET HAS STRICT JSON ORDERING DUE TO XML TRANSLATION ***** ***** YOU MUST FOLLOW FIELD ORDER AS SPECIFIED IN THEIR API DOCS ***** ***** https://developer.authorize.net/api/reference/index.html ***** ************************************************************************* *************************************************************************

type TransactionResponse

type TransactionResponse struct {
	ResponseCode   ResponseCode                 `json:"responseCode"`
	AuthCode       string                       `json:"authCode"`
	AVSResultCode  AVSResultCode                `json:"avsResultCode"`
	CVVResultCode  CVVResultCode                `json:"cvvResultCode"`
	CAVVResultCode CAVVResultCode               `json:"cavvResultCode"`
	TransID        string                       `json:"transId"`
	RefTransID     string                       `json:"refTransID"`
	TransHash      string                       `json:"transHash"`
	AccountNumber  string                       `json:"accountNumber"`
	AccountType    string                       `json:"accountType"`
	Messages       []TransactionResponseMessage `json:"messages"`
	Errors         []Error                      `json:"errors"`
}

TransactionResponse contains the information from issuer about AVS, CVV and whether or not authorization was successful

type TransactionResponseMessage

type TransactionResponseMessage struct {
	Code        MessageResponseCode `json:"code"`
	Description string              `json:"description"`
}

TransactionResponseMessage contains additional information about transaction result from processor

type TransactionType added in v1.1.500

type TransactionType string
const (
	TransactionTypeAuthOnly         TransactionType = "authOnlyTransaction"
	TransactionTypeVoid             TransactionType = "voidTransaction"
	TransactionTypePriorAuthCapture TransactionType = "priorAuthCaptureTransaction"
	TransactionTypeRefund           TransactionType = "refundTransaction"
)

Jump to

Keyboard shortcuts

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