sdk

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AdditionalDataField

type AdditionalDataField struct {
	AdditionalDataTag   string
	StoreLabelTag       string
	MobileNumberTag     string
	BillNumberTag       string
	TerminalLabelTag    string
	StoreLabelLength    int
	MobileNumberLength  int
	BillNumberLength    int
	TerminalLabelLength int
}

AdditionalDataField holds the configuration for additional data fields based on the EMV configuration.

func NewAdditionalDataField

func NewAdditionalDataField(emv *EMV) *AdditionalDataField

NewAdditionalDataField initializes and returns an AdditionalDataField instance with EMV configurations.

func (*AdditionalDataField) BillNumberValue

func (a *AdditionalDataField) BillNumberValue(billNumber string) (string, error)

BillNumberValue formats and validates the bill number value.

func (*AdditionalDataField) PhoneNumberValue

func (a *AdditionalDataField) PhoneNumberValue(phoneNumber string) (string, error)

PhoneNumberValue formats and validates the phone number value.

func (*AdditionalDataField) StoreLabelValue

func (a *AdditionalDataField) StoreLabelValue(storeLabel string) (string, error)

StoreLabelValue formats and validates the store label value.

func (*AdditionalDataField) TerminalLabelValue

func (a *AdditionalDataField) TerminalLabelValue(terminalLabel string) (string, error)

TerminalLabelValue formats and validates the terminal label value.

func (*AdditionalDataField) Value

func (a *AdditionalDataField) Value(storeLabel, phoneNumber, billNumber, terminalLabel string) (string, error)

Value combines all formatted values into a single string with a length prefix.

type Amount

type Amount struct {
	TransactionAmount string
	MaxLength         int
}

Amount holds the transaction amount tag and its maximum length.

func NewAmount

func NewAmount(emv *EMV) *Amount

NewAmount initializes and returns an Amount instance.

func (*Amount) Value

func (a *Amount) Value(amount interface{}) (string, error)

Value formats the amount according to the required structure.

type CRC

type CRC struct {
	CRC           string
	DefaultCRCTag string
}

CRC holds the CRC tag and default CRC tag values.

func NewCRC

func NewCRC(emv *EMV) *CRC

NewCRC initializes and returns a CRC instance.

func (*CRC) CRC16Hex

func (c *CRC) CRC16Hex(data string) string

CRC16Hex returns the CRC-16 value in hexadecimal format.

func (*CRC) CalculateCRC16

func (c *CRC) CalculateCRC16(data string) int

CalculateCRC16 calculates the CRC-16 using the CRC-CCITT polynomial.

func (*CRC) Value

func (c *CRC) Value(data string) string

Value computes the CRC-16 value and formats it including the CRC tag.

type CountryCode

type CountryCode struct {
	CountryCodeTag     string
	DefaultCountryCode string
}

CountryCode holds the country code tag and default country code.

func NewCountryCode

func NewCountryCode(emv *EMV) *CountryCode

NewCountryCode initializes and returns a CountryCode instance.

func (*CountryCode) Value

func (c *CountryCode) Value(countryCode string) string

Value formats the country code according to the required structure.

type EMV

type EMV struct {
	// Default QR Code Types
	DefaultDynamicQR string
	DefaultStaticQR  string

	// Currency Codes
	TransactionCurrencyUSD string
	TransactionCurrencyKHR string
	TransactionCurrency    string

	// Payload and Point of Initiation
	PayloadFormatIndicator        string
	DefaultPayloadFormatIndicator string
	PointOfInitiationMethod       string

	// Merchant Information
	MerchantName                string
	MerchantCity                string
	DefaultMerchantCity         string
	MerchantCategoryCode        string
	DefaultMerchantCategoryCode string

	// QR Code Identifiers
	StaticQR                             string
	DynamicQR                            string
	MerchantAccountInformationIndividual string
	MerchantAccountInformationMerchant   string

	// Transaction Details
	TransactionAmount        string
	DefaultTransactionAmount string
	CountryCode              string
	DefaultCountryCode       string

	// Additional Data Tags
	AdditionalDataTag                   string
	BillNumberTag                       string
	AdditionDataFieldMobileNumber       string
	StoreLabel                          string
	TerminalLabel                       string
	PurposeOfTransaction                string
	TimestampTag                        string
	MerchantInformationLanguageTemplate string

	// Language Preferences
	LanguagePreference              string
	MerchantNameAlternativeLanguage string
	MerchantCityAlternativeLanguage string

	// UnionPay Specific
	UnionPayMerchantAccount string

	// CRC Tag
	CRC           string
	CRCLength     string
	DefaultCRCTag string

	// Invalid Length Constraints
	InvalidLengthKHQR                            int
	InvalidLengthMerchantName                    int
	InvalidLengthBakongAccount                   int
	InvalidLengthAmount                          int
	InvalidLengthCountryCode                     int
	InvalidLengthMerchantCategoryCode            int
	InvalidLengthMerchantCity                    int
	InvalidLengthTimestamp                       int
	InvalidLengthTransactionAmount               int
	InvalidLengthTransactionCurrency             int
	InvalidLengthBillNumber                      int
	InvalidLengthStoreLabel                      int
	InvalidLengthTerminalLabel                   int
	InvalidLengthPurposeOfTransaction            int
	InvalidLengthMerchantID                      int
	InvalidLengthAcquiringBank                   int
	InvalidLengthMobileNumber                    int
	InvalidLengthAccountInformation              int
	InvalidLengthMerchantNameLanguageTemplate    int
	InvalidLengthUPIMerchant                     int
	InvalidLengthLanguagePreference              int
	InvalidLengthMerchantNameAlternativeLanguage int
	InvalidLengthMerchantCityAlternativeLanguage int
}

EMV struct contains constants used for encoding and decoding QR codes for transactions supported by the Bakong app.

func NewEMV

func NewEMV() *EMV

EMV creates and initializes a new EMV instance with default values.

type GlobalUniqueIdentifier

type GlobalUniqueIdentifier struct {
	PayloadFormatIndicator               string
	MerchantAccountInformationIndividual string
	MaxLength                            int
}

GlobalUniqueIdentifier holds the values for payload format indicator, merchant account information, and max length.

func NewGlobalUniqueIdentifier

func NewGlobalUniqueIdentifier(emv *EMV) *GlobalUniqueIdentifier

NewGlobalUniqueIdentifier initializes and returns a new GlobalUniqueIdentifier instance.

func (*GlobalUniqueIdentifier) Value

func (g *GlobalUniqueIdentifier) Value(bankAccount string) (string, error)

Value generates the global unique identifier based on the bank account number.

type HASH

type HASH struct{}

HASH struct is an empty struct to represent the hashing functionality.

func NewHASH

func NewHASH() *HASH

NewHASH initializes and returns a new HASH instance.

func (*HASH) Md5

func (h *HASH) Md5(data string) string

Md5 generates an MD5 hash for the given data.

type MCC

type MCC struct {
	MerchantCategoryCodeTag     string
	DefaultMerchantCategoryCode string
}

MCC struct contains the Merchant Category Code (MCC) logic

func NewMCC

func NewMCC(emv *EMV) *MCC

NewMCC initializes and returns a new MCC instance

func (*MCC) Value

func (m *MCC) Value(categoryCode string) (string, error)

Value generates and returns the formatted Merchant Category Code (MCC) value

type MerchantCity

type MerchantCity struct {
	MerchantCityTag string
	MaxLength       int
}

MerchantCity struct contains the merchant city logic

func NewMerchantCity

func NewMerchantCity(emv *EMV) *MerchantCity

NewMerchantCity initializes and returns a new MerchantCity instance

func (*MerchantCity) Value

func (m *MerchantCity) Value(merchantCity string) (string, error)

Value generates and returns the formatted merchant city value

type MerchantName

type MerchantName struct {
	MerchantNameTag string
	MaxLength       int
}

MerchantName struct contains the merchant name logic

func NewMerchantName

func NewMerchantName(emv *EMV) *MerchantName

NewMerchantName initializes and returns a new MerchantName instance

func (*MerchantName) Value

func (m *MerchantName) Value(merchantName string) (string, error)

Value generates and returns the formatted merchant name value

type PayloadFormatIndicator

type PayloadFormatIndicator struct {
	PayloadFormatIndicator        string
	DefaultPayloadFormatIndicator string
}

PayloadFormatIndicator struct contains the payload format indicator logic

func NewPayloadFormatIndicator

func NewPayloadFormatIndicator(emv *EMV) *PayloadFormatIndicator

NewPayloadFormatIndicator initializes and returns a new PayloadFormatIndicator instance

func (*PayloadFormatIndicator) Value

func (p *PayloadFormatIndicator) Value() string

Value generates and returns the formatted payload format indicator value

type PointOfInitiation

type PointOfInitiation struct {
	DynamicQR string
	StaticQR  string
}

PointOfInitiation struct contains the logic for dynamic and static QR code settings

func NewPointOfInitiation

func NewPointOfInitiation(emv *EMV) *PointOfInitiation

NewPointOfInitiation initializes and returns a new PointOfInitiation instance

func (*PointOfInitiation) Dynamic

func (p *PointOfInitiation) Dynamic() string

Dynamic retrieves the dynamic QR code setting

func (*PointOfInitiation) Static

func (p *PointOfInitiation) Static() string

Static retrieves the static QR code setting

type TimeStamp

type TimeStamp struct {
	LanguagePreference string
	TimestampTag       string
}

TimeStamp struct contains the logic for generating timestamp data

func NewTimeStamp

func NewTimeStamp(emv *EMV) *TimeStamp

NewTimeStamp initializes and returns a new TimeStamp instance

func (*TimeStamp) Value

func (t *TimeStamp) Value() string

Value generates the QR code data for the current timestamp

type TransactionCurrency

type TransactionCurrency struct {
	TransactionCurrency string
	CurrencyUSD         string
	CurrencyKHR         string
}

TransactionCurrency struct contains the logic for generating transaction currency data

func NewTransactionCurrency

func NewTransactionCurrency(emv *EMV) *TransactionCurrency

NewTransactionCurrency initializes and returns a new TransactionCurrency instance

func (*TransactionCurrency) Value

func (tc *TransactionCurrency) Value(currency string) (string, error)

Value generates the QR code data for the transaction currency

Jump to

Keyboard shortcuts

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