types

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2024 License: LGPL-3.0 Imports: 1 Imported by: 0

Documentation

Overview

Package types contains errors, types, constants, and enums used throughout the module.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Currency

type Currency int

Currency is an alias type for int. Valid values are 3 digit ISO4217 codes. The most common codes are exported by this package.

const (
	// CurrencyMDL is the ISO4217 code for Moldovan Lei.
	CurrencyMDL Currency = 498

	// CurrencyEUR is the ISO4217 code for Euro.
	CurrencyEUR Currency = 978

	// CurrencyUSD is the ISO4217 code for United States Dollar.
	CurrencyUSD Currency = 840
)

type ECommError added in v1.0.0

type ECommError struct {
	// HTTP status code
	Code int

	// Response body
	Body string
}

ECommError is returned when the ECommerce system responds with a non-200 status, or when the response body starts with "error:".

func (ECommError) Error added in v1.0.0

func (e ECommError) Error() string

type Language

type Language string

Language is an alias type for string. Valid values are language identifiers that the merchant has sent to MAIB. The default identifiers are exported by this package.

const (
	LanguageRomanian Language = "ro"
	LanguageRussian  Language = "ru"
	LanguageEnglish  Language = "en"
)

type ParseError added in v1.0.0

type ParseError struct {
	// Underlying error
	Err error

	// Response body that couldn't be parsed
	Body string
}

ParseError is returned when the response from the ECommerce system doesn't follow "KEY: value" format, or when a field has an unexpected type .

func (ParseError) Error added in v1.0.0

func (e ParseError) Error() string

func (ParseError) Unwrap added in v1.0.0

func (e ParseError) Unwrap() error

Unwrap returns the underlying error, for usage with errors.As.

type PayloadField

type PayloadField string

PayloadField contains the names of the payload fields. Used in ValidationError.

const (
	FieldTransactionID   PayloadField = "trans_id"
	FieldAmount          PayloadField = "amount"
	FieldCurrency        PayloadField = "currency"
	FieldClientIPAddress PayloadField = "client_ip_addr"
	FieldDescription     PayloadField = "description"
	FieldLanguage        PayloadField = "language"
	FieldBillerClientID  PayloadField = "biller_client_id"
	FieldPerspayeeExpiry PayloadField = "prespayee_expiry"
	FieldCommand         PayloadField = "command"
)

type ResultEnum

type ResultEnum string

ResultEnum holds the possible values of the RESULT field returned by the ECommerce system.

const (
	// ResultOk - the transaction has successfully completed.
	ResultOk ResultEnum = "OK"

	// ResultFailed - the transaction has failed.
	ResultFailed ResultEnum = "FAILED"

	// ResultCreated - the transaction is just registered in the system. Client didn't input their card information yet.
	ResultCreated ResultEnum = "CREATED"

	// ResultPending - the transaction is not complete yet.
	ResultPending ResultEnum = "PENDING"

	// ResultDeclined - the transaction was declined by EComm.
	ResultDeclined ResultEnum = "DECLINED"

	// ResultReversed - the transaction was reversed.
	ResultReversed ResultEnum = "REVERSED"

	// ResultAutoReversed - the transaction was reversed by autoreversal.
	ResultAutoReversed ResultEnum = "AUTOREVERSED"

	// ResultTimeout - the transaction has timed out.
	ResultTimeout ResultEnum = "TIMEOUT"
)

type ResultPSEnum

type ResultPSEnum string

ResultPSEnum holds the possible values for the RESULT_PS field returned by the ECommerce system.

const (
	// ResultPSActive - the transaction was registered and payment is not completed yet.
	ResultPSActive ResultPSEnum = "ACTIVE"

	// ResultPSFinished - payment was completed successfully.
	ResultPSFinished ResultPSEnum = "FINISHED"

	// ResultPSCancelled - payment was cancelled.
	ResultPSCancelled ResultPSEnum = "CANCELLED"

	// ResultPSReturned - payment was returned.
	ResultPSReturned ResultPSEnum = "RETURNED"
)

type ValidationError added in v1.0.0

type ValidationError struct {
	// Which field is malformed.
	Field PayloadField

	// Human-readable explanation of the requirements.
	Description string
}

ValidationError is triggered before sending the request to the ECommerce system, if the request has failed validation.

func (ValidationError) Error added in v1.0.0

func (e ValidationError) Error() string

Jump to

Keyboard shortcuts

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