Documentation ¶
Overview ¶
Package requests contains the request structs for each of the commands available in the MAIB ECommerce.
Each request struct implements Request interface from the base package, and is accompanied by a result struct. E.g., CloseDay has CloseDayResult. Function DecodeResponse should be used to parse the response map into the result struct.
Additional fields in the payload are not supported.
Index ¶
- func DecodeResponse[ResultType resultTypes](maibResponse map[string]any) (result ResultType, err error)
- type CloseDay
- type CloseDayResult
- type DeleteRecurring
- type DeleteRecurringResult
- type ExecuteDMS
- type ExecuteDMSResult
- type ExecuteRecurring
- type ExecuteRecurringResult
- type RegisterRecurring
- type RegisterRecurringResult
- type RegisterRecurringType
- type RegisterTransaction
- type RegisterTransactionResult
- type RegisterTransactionType
- type ReverseTransaction
- type ReverseTransactionResult
- type TransactionStatus
- type TransactionStatusResult
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeResponse ¶
func DecodeResponse[ResultType resultTypes](maibResponse map[string]any) (result ResultType, err error)
DecodeResponse is a generic function that parses the map returned from the ECommerce system into any Result type. The generic type must be specified.
Example ¶
// Example of a response from the ECommerce system for a RegisterTransaction request ecommResponse := map[string]any{ "TRANSACTION_ID": "abcdefghijklmnopqrstuvwxyz1=", } result, err := DecodeResponse[RegisterTransactionResult](ecommResponse) if err != nil { panic(err) } fmt.Print(result.TransactionID)
Output: abcdefghijklmnopqrstuvwxyz1=
Types ¶
type CloseDay ¶
type CloseDay struct{}
CloseDay closes the business day (-b). This procedure must be initiated once a day. Recommended time is 23:59:00.
type CloseDayResult ¶
type CloseDayResult struct { // Transaction result status. Result types.ResultEnum `mapstructure:"RESULT"` // Transaction result code returned from Card Suite FO (3 digits). ResultCode int `mapstructure:"RESULT_CODE"` // Number of credit transactions (FLD_074, max 10 digits). // Available only if resultCode begins with 5. CreditTransactionNumber int `mapstructure:"FLD_074"` // Number of credit reversals (FLD_075, max 10 digits). // Available only if resultCode begins with 5. CreditReversalNumber int `mapstructure:"FLD_075"` // Number of debit transactions (FLD_076, max 10 digits). // Available only if resultCode begins with 5. DebitTransactionNumber int `mapstructure:"FLD_076"` // Number of debit reversals (FLD_077, max 10 digits). // Available only if resultCode begins with 5. DebitReversalNumber int `mapstructure:"FLD_077"` // Total amount of credit transactions (FLD_086, max 16 digits). // Available only if resultCode begins with 5. CreditTransactionAmount int `mapstructure:"FLD_086"` // Total amount of credit reversals (FLD_087, max 16 digits). // Available only if resultCode begins with 5. CreditReversalAmount int `mapstructure:"FLD_087"` // Total amount of debit transactions (FLD_088, max 16 digits). // Available only if resultCode begins with 5. DebitTransactionAmount int `mapstructure:"FLD_088"` // Total amount of debit reversals (FLD_089, max 16 digits). // Available only if resultCode begins with 5. DebitReversalAmount int `mapstructure:"FLD_089"` }
CloseDayResult contains the response to a CloseDay request.
type DeleteRecurring ¶
type DeleteRecurring struct { // Identifier of the recurring payment. BillerClientID string `url:"biller_client_id"` }
DeleteRecurring deletes a recurring transaction (-x).
func (DeleteRecurring) Validate ¶
func (payload DeleteRecurring) Validate() error
type DeleteRecurringResult ¶
type DeleteRecurringResult struct { // Transaction result status. Result types.ResultEnum `mapstructure:"RESULT"` }
DeleteRecurringResult contains the response to a DeleteRecurring request.
type ExecuteDMS ¶
type ExecuteDMS struct { // ID of the transaction. 28 symbols in base64. TransactionID string `url:"trans_id"` // Transaction payment amount. Positive integer with last 2 digits being the cents. // // Example: if Amount:199 and Currency:CurrencyUSD, $1.99 will be requested from the client's card. Amount uint `url:"amount"` // Transaction currency in ISO4217 3 digit format. Currency types.Currency `url:"currency"` // Client's IP address in quad-dotted notation, like "127.0.0.1". ClientIPAddress string `url:"client_ip_addr"` // Transaction details. Optional. Description string `url:"description,omitempty"` }
ExecuteDMS executes a DMS transaction (-t) after it was created with RegisterTransaction (-a), and checked with TransactionStatus (-c).
func (ExecuteDMS) Validate ¶
func (payload ExecuteDMS) Validate() error
type ExecuteDMSResult ¶
type ExecuteDMSResult struct { // Transaction result status. Result types.ResultEnum `mapstructure:"RESULT"` // Transaction result code returned from Card Suite FO (3 digits). ResultCode int `mapstructure:"RESULT_CODE"` // Retrieval reference number returned from Card Suite FO. RRN int `mapstructure:"RRN"` // Approval Code returned from Card Suite FO (max 6 characters). ApprovalCode string `mapstructure:"APPROVAL_CODE"` // Masked card number. CardNumber string `mapstructure:"CARD_NUMBER"` }
ExecuteDMSResult contains the response to a ExecuteDMS request.
type ExecuteRecurring ¶
type ExecuteRecurring struct { // Transaction payment amount. Positive integer with last 2 digits being the cents. // // Example: if Amount:199 and Currency:CurrencyUSD, $1.99 will be requested from the client's card. Amount uint `url:"amount"` // Transaction currency in ISO4217 3 digit format. Currency types.Currency `url:"currency"` // Client's IP address in quad-dotted notation, like "127.0.0.1". ClientIPAddress string `url:"client_ip_addr"` // Transaction details. Optional. Description string `url:"description,omitempty"` // Identifier of the recurring payment. BillerClientID string `url:"biller_client_id"` }
ExecuteRecurring executes a recurring transaction (-e) after it was created with RegisterRecurring (-z/-d/-p). It should not be finalized with TransactionStatus (-c) or ExecuteDMS (-t).
func (ExecuteRecurring) Validate ¶
func (payload ExecuteRecurring) Validate() error
type ExecuteRecurringResult ¶
type ExecuteRecurringResult struct { // ID of the executed transaction. 28 symbols in base64. TransactionID string `mapstructure:"TRANSACTION_ID"` // Transaction result status. Result types.ResultEnum `mapstructure:"RESULT"` // Transaction result code returned from Card Suite FO (3 digits). ResultCode int `mapstructure:"RESULT_CODE"` // Retrieval reference number returned from Card Suite FO. RRN int `mapstructure:"RRN"` // Approval Code returned from Card Suite FO (max 6 characters). ApprovalCode string `mapstructure:"APPROVAL_CODE"` }
ExecuteRecurringResult contains the response to a ExecuteRecurring request.
type RegisterRecurring ¶
type RegisterRecurring struct { // Transaction type used for registration. Can be SMS (-z), DMS (-d), or without first payment (-p). // Default is SMS. TransactionType RegisterRecurringType `url:"-"` // Transaction payment amount. Positive integer with last 2 digits being the cents. // Ignored for registration without first payment. // // Example: if Amount:199 and Currency:CurrencyUSD, $1.99 will be requested from the client's card. Amount uint `url:"amount"` // Transaction currency in ISO4217 3 digit format. Currency types.Currency `url:"currency"` // Client's IP address in quad-dotted notation, like "127.0.0.1". ClientIPAddress string `url:"client_ip_addr"` // Transaction details. Optional. Description string `url:"description,omitempty"` // Language in which the bank payment page will be displayed. Language types.Language `url:"language"` // Identifier of the recurring payment. If not specified, // resulting TRANSACTION_ID will be used as the recurring payment ID. BillerClientID string `url:"biller_client_id"` // Validity limit of the regular payment in the format "MMYY". PerspayeeExpiry string `url:"perspayee_expiry"` // Whether the recurring transaction with a given BillerClientID should be updated. // This way, same BillerClientID may be used when customer changes payment information. OverwriteExisting bool `url:"-"` }
RegisterRecurring creates a new recurring transaction.
func (RegisterRecurring) Validate ¶
func (payload RegisterRecurring) Validate() error
type RegisterRecurringResult ¶
type RegisterRecurringResult struct { // ID of the created transaction. 28 symbols in base64. TransactionID string `mapstructure:"TRANSACTION_ID"` }
RegisterRecurringResult contains the response to a RegisterRecurring request.
type RegisterRecurringType ¶
type RegisterRecurringType int
RegisterRecurringType holds possible types for recurring transaction.
const ( // RegisterRecurringSMS is a recurring transaction type which is initialized with an SMS transaction (-z). // The resulting transaction should be confirmed with TransactionStatus (-c). // // This is the default transaction type. RegisterRecurringSMS RegisterRecurringType = iota // RegisterRecurringDMS is a recurring transaction type which is initialized with a DMS transaction (-d). // The resulting transaction should be confirmed with TransactionStatus (-c), and executed with ExecuteDMS (-t). RegisterRecurringDMS // RegisterRecurringWithoutPayment is a recurring transaction type which is initialized without a transaction (-p). RegisterRecurringWithoutPayment )
func (RegisterRecurringType) String ¶
func (t RegisterRecurringType) String() string
String converts RegisterRecurringType into the ECommerce command. Returns an empty string for unknown values.
type RegisterTransaction ¶
type RegisterTransaction struct { // Transaction type. Can be SMS (-v) or DMS (-a). // Default is SMS. TransactionType RegisterTransactionType `url:"-"` // Transaction payment amount. Positive integer with last 2 digits being the cents. // // Example: if Amount:199 and Currency:CurrencyUSD, $1.99 will be requested from the client's card. Amount uint `url:"amount"` // Transaction currency in ISO4217 3 digit format. Currency types.Currency `url:"currency"` // Client's IP address in quad-dotted notation, like "127.0.0.1". ClientIPAddress string `url:"client_ip_addr"` // Transaction details. Optional. Description string `url:"description,omitempty"` // Language in which the bank payment page will be displayed. Language types.Language `url:"language"` }
RegisterTransaction creates a new SMS (-v) or DMS (-a) transaction.
func (RegisterTransaction) Validate ¶
func (payload RegisterTransaction) Validate() error
type RegisterTransactionResult ¶
type RegisterTransactionResult struct { // ID of the created transaction. 28 symbols in base64. TransactionID string `mapstructure:"TRANSACTION_ID"` }
RegisterTransactionResult contains the response to a RegisterTransaction request.
type RegisterTransactionType ¶
type RegisterTransactionType int
RegisterTransactionType holds possible types for recurring transaction.
const ( // RegisterTransactionSMS is the Single Messaging System transaction type (-v). // Such a transaction is executed immediately and should be confirmed with TransactionStatus (-c). // // This is the default transaction type. RegisterTransactionSMS RegisterTransactionType = iota // RegisterTransactionDMS is the Double Messaging System transaction type (-a). // This transaction should be confirmed with TransactionStatus (-c), // and executed with ExecuteDMS (-t). RegisterTransactionDMS )
func (RegisterTransactionType) String ¶
func (t RegisterTransactionType) String() string
String converts RegisterTransactionType into the ECommerce command. Returns an empty string for unknown values.
type ReverseTransaction ¶
type ReverseTransaction struct { // ID of the transaction. 28 symbols in base64. TransactionID string `url:"trans_id"` // Reversal amount. Positive integer with last 2 digits being the cents. // // For DMS authorizations only full amount can be reversed, i.e., the reversal and authorization // amounts have to match. In other cases, a partial reversal is also available. Amount uint `url:"amount"` // A flag indicating that a transaction is being reversed because of suspected fraud. // If this parameter is used, only full reversals are allowed. SuspectedFraud bool `url:"-"` }
ReverseTransaction reverses transaction and returns all or some funds to the client (-r).
func (ReverseTransaction) Validate ¶
func (payload ReverseTransaction) Validate() error
type ReverseTransactionResult ¶
type ReverseTransactionResult struct { // Transaction result status. Result types.ResultEnum `mapstructure:"RESULT"` // Transaction result code returned from Card Suite FO (3 digits). ResultCode int `mapstructure:"RESULT_CODE"` }
ReverseTransactionResult contains the response to a ReverseTransaction request.
type TransactionStatus ¶
type TransactionStatus struct { // ID of the transaction. 28 symbols in base64. TransactionID string `url:"trans_id"` // Client's IP address in quad-dotted notation, like "127.0.0.1". ClientIPAddress string `url:"client_ip_addr"` }
TransactionStatus returns the status of a transaction (-c).
func (TransactionStatus) Validate ¶
func (payload TransactionStatus) Validate() error
type TransactionStatusResult ¶
type TransactionStatusResult struct { // Transaction result status. Result types.ResultEnum `mapstructure:"RESULT"` // Transaction result, Payment Server interpretation. ResultPS types.ResultPSEnum `mapstructure:"RESULT_PS"` // Transaction resul code returned from Card Suite FO (3 digits). ResultCode int `mapstructure:"RESULT_CODE"` // 3D Secure status. ThreeDSecure string `mapstructure:"3DSECURE"` ThreeDSecureReason string `mapstructure:"3DSECURE_REASON"` // Retrieval reference number returned from Card Suite FO. RRN int `mapstructure:"RRN"` // Approval Code returned from Card Suite FO (max 6 characters). ApprovalCode string `mapstructure:"APPROVAL_CODE"` // Masked card number. CardNumber string `mapstructure:"CARD_NUMBER"` AAV string `mapstructure:"AAV"` // PAR value identifying an account. PaymentAccountReference string `mapstructure:"PAYMENT_ACCOUNT_REFERENCE"` // Recurring payment identification in Payment Server. // Available only if transaction is recurring. RecurringPaymentID string `mapstructure:"RECC_PMNT_ID"` // Recurring payment expiry date in Payment Server in the form "MMYY". // Available only if transaction is recurring. RecurringPaymentExpiry string `mapstructure:"RECC_PMNT_EXPIRY"` }
TransactionStatusResult contains the response to a TransactionStatus request.