authorizenet

package
v1.0.325 Latest Latest
Warning

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

Go to latest
Published: May 18, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ResponseCodeApproved indicates the successful response from authnet requests
	ResponseCodeApproved = "1"
)

Variables

This section is empty.

Functions

This section is empty.

Types

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) *AuthorizeNetClient

NewClient uses authentication above with a default http client

func NewWithHttpClient

func NewWithHttpClient(merchantName string, transactionKey string, 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"`
}

BillingAddress is used in TransactionRequest for making an auth call

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

CreditCard is raw cc info

type Error

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

Error specifies a code and text explaining what happened

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 Messages

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

Messages is used to augment responses with codes and readable messages

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 TransactionRequest

type TransactionRequest struct {
	TransactionType  string          `json:"transactionType"`
	Amount           *string         `json:"amount,omitempty"`
	Payment          *Payment        `json:"payment,omitempty"`
	BillingAddress   *BillingAddress `json:"billTo,omitempty"`
	RefTransactionID *string         `json:"refTransId,omitempty"`
}

TransactionRequest has the raw credit card info as Payment and amount to authorize

type TransactionResponse

type TransactionResponse struct {
	ResponseCode   string                       `json:"responseCode"`
	AuthCode       string                       `json:"authCode"`
	AVSResultCode  string                       `json:"avsResultCode"`
	CVVResultCode  string                       `json:"cvvResultCode"`
	CAVVResultCode string                       `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        string `json:"code"`
	Description string `json:"description"`
}

TransactionResponseMessage contains additional information about transaction result from processor

Jump to

Keyboard shortcuts

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