Documentation ¶
Index ¶
- Constants
- Variables
- func ValidateField(id, value string) error
- type Builder
- func (b Builder) Add(tlv TLV) Builder
- func (b Builder) AddAdditionalDataField(transactionId string)
- func (b Builder) AddCountryCode(code string)
- func (b Builder) AddMerchantAccountInformation(gui, chave string)
- func (b Builder) AddMerchantCategoryCode(code string)
- func (b Builder) AddMerchantCity(city string)
- func (b Builder) AddMerchantName(name string)
- func (b Builder) AddPayloadFormatIndicator(value string)
- func (b Builder) AddPostalCode(postalCode string)
- func (b Builder) AddTransactionAmount(amount int)
- func (b Builder) AddTransactionCurrency(code string)
- func (b Builder) Build() (string, error)
- func (b Builder) CheckCRC() error
- func (b *Builder) Clear()
- func (b Builder) GetCountryCode() (string, error)
- func (b Builder) GetMerchanName() (string, error)
- func (b Builder) GetMerchantAccountInformationChave() (string, error)
- func (b Builder) GetMerchantAccountInformationGui() (string, error)
- func (b Builder) GetMerchantCategoryCode() (string, error)
- func (b Builder) GetMerchantCity() (string, error)
- func (b Builder) GetPayloadFormatIndicator() (string, error)
- func (b Builder) GetPostalCode() (string, error)
- func (b Builder) GetPrimitiveField(id string) (string, error)
- func (b Builder) GetTemplateField(id string, fieldId string) (string, error)
- func (b Builder) GetTransactionAmount() (int, error)
- func (b Builder) GetTransactionCurrency() (string, error)
- func (b Builder) GetTransactionId() (string, error)
- func (b Builder) Sorted() []TLV
- type Metadata
- type Parser
- type Primitive
- type Static
- type StaticOptFn
- type TLV
- type Template
Constants ¶
View Source
const ( FieldPrimitive = "primitive" FieldTemplate = "template" )
View Source
const ( PIXGui = "br.gov.bcb.pix" PayloadFormatIndicator = "01" )
Variables ¶
View Source
var ( ErrInvalidCRC = errors.New("crc is not valid") ErrCRCNotPresent = errors.New("crc is not present") ErrRequiredFieldNotPresent = errors.New("required field not present") )
View Source
var ( ErrFieldIsRequired = errors.New("field is required") ErrFieldMetadataNotFound = errors.New("field metadata for provided id not found") )
View Source
var (
ErrEmptyCode = errors.New("cannot parse empty code")
)
View Source
var ( IDMetadata = map[string]Metadata{ "00": { Name: "Payload Format Indicator", MaxSize: 2, MinSize: 2, Type: FieldPrimitive, Required: true, }, "26": { Name: "Merchant Account Information", MinSize: 5, MaxSize: 99, Type: FieldTemplate, Required: true, }, "26-00": { Name: "GUI", MaxSize: 14, Required: true, Type: FieldPrimitive, }, "26-01": { Name: "Chave", MaxSize: 77, Required: true, Type: FieldPrimitive, }, "26-02": { Name: "Info Adicional", MaxSize: 72, Required: false, Type: FieldPrimitive, }, "26-03": { Name: "FSS", MaxSize: 8, Required: false, Type: FieldPrimitive, }, "52": { Name: "Merchant Category Code", MinSize: 4, MaxSize: 4, Required: true, Type: FieldPrimitive, }, "53": { Name: "Transaction Currency", MinSize: 3, MaxSize: 3, Required: true, Type: FieldPrimitive, }, "54": { Name: "Transaction Amount", MinSize: 1, MaxSize: 13, Required: false, Type: FieldPrimitive, }, "58": { Name: "Country Code", MaxSize: 2, MinSize: 2, Required: true, Type: FieldPrimitive, }, "59": { Name: "Merchant Name", MinSize: 1, MaxSize: 25, Required: true, Type: FieldPrimitive, }, "60": { Name: "Merchant City", MinSize: 1, MaxSize: 25, Required: true, Type: FieldPrimitive, }, "61": { Name: "Postal Code", MinSize: 1, MaxSize: 99, Type: FieldPrimitive, Required: false, }, "62": { Name: "Addional Data Field Template", MinSize: 5, MaxSize: 29, Type: FieldTemplate, Required: false, }, "62-05": { Name: "Reference Label", MinSize: 1, MaxSize: 25, Required: false, Type: FieldPrimitive, }, "63": { Name: "CRC16", MaxSize: 4, MinSize: 4, Required: true, Type: FieldPrimitive, }, } )
Functions ¶
func ValidateField ¶
Validates a field value based on the provided id metadata
Types ¶
type Builder ¶
Used to build the BRCode
func (Builder) AddAdditionalDataField ¶
func (Builder) AddCountryCode ¶
func (Builder) AddMerchantAccountInformation ¶
func (Builder) AddMerchantCategoryCode ¶
func (Builder) AddMerchantCity ¶
func (Builder) AddMerchantName ¶
func (Builder) AddPayloadFormatIndicator ¶
func (Builder) AddPostalCode ¶
func (Builder) AddTransactionAmount ¶
Adds the transaction amount in cents. Ex: 100 == 1 real
func (Builder) AddTransactionCurrency ¶
func (Builder) CheckCRC ¶ added in v0.2.0
Removes crc and then builds without adding it and checks if hashes matches
func (Builder) GetCountryCode ¶ added in v0.3.0
func (Builder) GetMerchanName ¶ added in v0.3.0
func (Builder) GetMerchantAccountInformationChave ¶ added in v0.3.0
func (Builder) GetMerchantAccountInformationGui ¶ added in v0.3.0
func (Builder) GetMerchantCategoryCode ¶ added in v0.3.0
func (Builder) GetMerchantCity ¶ added in v0.3.0
func (Builder) GetPayloadFormatIndicator ¶ added in v0.3.0
func (Builder) GetPostalCode ¶ added in v0.3.0
func (Builder) GetPrimitiveField ¶ added in v0.3.0
func (Builder) GetTemplateField ¶ added in v0.3.0
func (Builder) GetTransactionAmount ¶ added in v0.3.0
func (Builder) GetTransactionCurrency ¶ added in v0.3.0
func (Builder) GetTransactionId ¶ added in v0.3.0
type Metadata ¶
func GetFieldMetadata ¶ added in v0.2.0
type Parser ¶ added in v0.2.0
type Parser struct { Code string // contains filtered or unexported fields }
type Static ¶
type Static struct { Chave string `json:"chave"` MerchantCategoryCode string `json:"mechantCategoryCode"` TransactionCurrency string `json:"transactionCurrency"` CountryCode string `json:"countryCode"` MerchantName string `json:"merchantName"` MerchantCity string `json:"merchantCity"` PostalCode string `json:"postalCode"` TransactionId string `json:"transactionId"` // Transaction amount in cents TransactionAmount int `json:"transactionAmount"` // contains filtered or unexported fields }
func NewStatic ¶
func NewStatic(chave, merchantName, merchantCity, txId string, fns ...StaticOptFn) *Static
type StaticOptFn ¶
type StaticOptFn func(*Static)
func WithCountryCode ¶
func WithCountryCode(code string) StaticOptFn
func WithMerchantCategoryCode ¶
func WithMerchantCategoryCode(code string) StaticOptFn
func WithPostalCode ¶
func WithPostalCode(postalCode string) StaticOptFn
func WithTransactionAmount ¶
func WithTransactionAmount(value int) StaticOptFn
type TLV ¶
type TLV interface { // Returns the (id, length, value) of a given field TLV() (id string, length string, value string, err error) // Returns the field id FieldID() string // Return id + length + value Code() (string, error) Unwrap() map[string]Primitive }
Represents a Type, Value, Lenght (TLV) object. TODO: Add a struct representing the data
Click to show internal directories.
Click to hide internal directories.