Versions in this module Expand all Collapse all v0 v0.1.0 Oct 19, 2023 Changes in this version + const ApprovalRequired + const CashPaymentType + const ChequePaymentType + const ContentTypeXML + const CreditCardPaymentType + const ElectronicPaymentType + const ExemptedVATCODE + const ExemptedVATID + const ExemptedVATRATE + const FetchTokenAction + const FetchTokenProductionURL + const FetchTokenTestingURL + const InvalidCertificate + const InvalidClientHeader + const InvalidSerial + const InvalidSignatureCode + const InvalidTaxID + const InvoicePaymentType + const LicenceCustomerID + const MeterNumberCustomerID + const NIDACustomerID + const NonCustomerID + const NonTaxableItemCode + const NonTaxableItemId + const PassportCustomerID + const ReceiptVerificationAction + const RegisterClientAction + const RegisterProductionURL + const RegisterTestingURL + const RegistrationRequestClient + const SpecialReliefVATCODE + const SpecialReliefVATID + const SpecialReliefVATRATE + const SpecialVATCODE + const SpecialVATID + const SpecialVATRATE + const StandardVATCODE + const StandardVATID + const StandardVATRATE + const SubmitReceiptAction + const SubmitReceiptProductionURL + const SubmitReceiptRoutingKey + const SubmitReceiptTestingURL + const SubmitReportAction + const SubmitReportProductionURL + const SubmitReportRoutingKey + const SubmitReportTestingURL + const SuccessCode + const TINCustomerID + const TaxableItemCode + const TaxableItemId + const UnhandledException + const VerifyReceiptProductionURL + const VerifyReceiptTestingURL + const VoterIDCustomerID + const ZeroVATCODE + const ZeroVATID + const ZeroVATRATE + var ErrFetchToken = errors.New("fetch token failed") + var ErrReceiptUploadFailed = errors.New("receipt upload failed") + var ErrRegistrationFailed = errors.New("registration failed") + var ErrReportSubmitFailed = fmt.Errorf("report submit failed") + func IsNetworkError(err error) bool + func IsSuccess(code int64) bool + func LoadCert(path, password string) (*rsa.PrivateKey, *x509.Certificate, error) + func LoadCertChain(certPath string, certPassword string) (*rsa.PrivateKey, *x509.Certificate, []*x509.Certificate, error) + func NetAmount(taxCode int64, price float64) float64 + func ParseErrorCode(code int64) string + func ReceiptBytes(privateKey *rsa.PrivateKey, params ReceiptParams, customer Customer, ...) ([]byte, error) + func ReceiptLink(e env.Env, receiptCode string, gc int64, receiptTime string) string + func ReportBytes(privateKey *rsa.PrivateKey, params *ReportParams, address Address, ...) ([]byte, error) + func ReportTaxRateID(taxCode int64) string + func RequestURL(e env.Env, action Action) string + func Sign(privateKey *rsa.PrivateKey, payload []byte) ([]byte, error) + func SignPayload(privateKey *rsa.PrivateKey, payload []byte) ([]byte, error) + func ValueAddedTaxAmount(taxCode int64, price float64) float64 + func ValueAddedTaxID(taxCode int64) string + func ValueAddedTaxRate(taxCode int64) float64 + func VerifySignature(publicKey *rsa.PublicKey, payload []byte, signature string) error + type Action string + type Address struct + City string + Country string + Mobile string + Name string + Street string + func (lines *Address) AsList() []string + type CertLoader func(certPath string, certPassword string) (*rsa.PrivateKey, *x509.Certificate, error) + type Client struct + func NewClient(options ...Option) *Client + func (c *Client) FetchToken(ctx context.Context, url string, request *TokenRequest) (*TokenResponse, error) + func (c *Client) FetchTokenWithMw(ctx context.Context, url string, request *TokenRequest, ...) (*TokenResponse, error) + func (c *Client) Register(ctx context.Context, url string, privateKey *rsa.PrivateKey, ...) (*RegistrationResponse, error) + func (c *Client) SetHttpClient(http *http.Client) + func (c *Client) SubmitReceipt(ctx context.Context, url string, headers *RequestHeaders, ...) (*Response, error) + func (c *Client) SubmitReport(ctx context.Context, url string, headers *RequestHeaders, ...) (*Response, error) + type Customer struct + ID string + Mobile string + Name string + Type CustomerID + type CustomerID int + type Error struct + Code int64 + Message string + type FetchTokenFunc func(ctx context.Context, url string, request *TokenRequest) (*TokenResponse, error) + type Item struct + Description string + Discount float64 + ID string + Quantity float64 + TaxCode int64 + UnitPrice float64 + type ItemProcessResponse struct + ITEMS []*models.ITEM + TOTALS models.TOTALS + VATTOTALS []*models.VATTOTAL + func ProcessItems(items []Item) *ItemProcessResponse + type NetworkError struct + Err error + Message string + func (e *NetworkError) Error() string + func (e *NetworkError) Unwrap() error + type OnTokenResponse func(context.Context, *TokenResponse) error + func WrapTokenResponseMiddleware(next OnTokenResponse, middlewares ...TokenResponseMiddleware) OnTokenResponse + type Option func(*Client) + func WithHttpClient(http *http.Client) Option + type PayloadSigner func(privateKey *rsa.PrivateKey, payload []byte) ([]byte, error) + type Payment struct + Amount float64 + Type PaymentType + type PaymentType string + func ParsePayment(value any) PaymentType + type RawRequest struct + Action Action + Env env.Env + FilePath string + type ReceiptParams struct + DailyCounter int64 + Date string + EFDSerial string + GlobalCounter int64 + ReceiptNum string + ReceiptVNum string + RegistrationID string + TIN string + Time string + ZNum string + type ReceiptRequest struct + Customer Customer + Items []Item + Params ReceiptParams + Payments []Payment + type RegistrationRequest struct + CertKey string + CertSerial string + ContentType string + Tin string + type RegistrationResponse struct + ACKCODE string + ACKMSG string + ADDRESS string + CITY string + COUNTRY string + GC int64 + MOBILE string + NAME string + PASSWORD string + RECEIPTCODE string + REGID string + REGION string + ROUTINGKEY string + SERIAL string + STREET string + TAXCODES TAXCODES + TAXOFFICE string + TIN string + TOKENPATH string + UIN string + USERNAME string + VRN string + func Register(ctx context.Context, requestURL string, privateKey *rsa.PrivateKey, ...) (*RegistrationResponse, error) + type ReportParams struct + Date string + EFDSerial string + RegistrationDate string + RegistrationID string + TIN string + TaxOffice string + Time string + UIN string + VRN string + ZNumber string + type ReportRequest struct + Address *Address + Params *ReportParams + Payment []Payment + Totals *ReportTotals + VATS []VATTOTAL + type ReportTotals struct + Corrections float64 + DailyTotalAmount float64 + Discounts float64 + Gross float64 + Surcharges float64 + TicketsFiscal int64 + TicketsNonFiscal int64 + TicketsVoid int64 + TicketsVoidTotal float64 + type RequestHeaders struct + BearerToken string + CertSerial string + type Response struct + Code int64 + Date string + Message string + Number int64 + Time string + func SubmitRawRequest(ctx context.Context, headers *RequestHeaders, raw *RawRequest) (*Response, error) + func SubmitReceipt(ctx context.Context, requestURL string, headers *RequestHeaders, ...) (*Response, error) + func SubmitReport(ctx context.Context, url string, headers *RequestHeaders, ...) (*Response, error) + type Service interface + FetchToken func(ctx context.Context, url string, request *TokenRequest) (*TokenResponse, error) + Register func(ctx context.Context, url string, privateKey *rsa.PrivateKey, ...) (*RegistrationResponse, error) + SubmitReceipt func(ctx context.Context, url string, headers *RequestHeaders, ...) (*Response, error) + SubmitReport func(ctx context.Context, url string, headers *RequestHeaders, ...) (*Response, error) + type SignatureVerifier func(publicKey *rsa.PublicKey, payload []byte, signature string) error + type TAXCODES struct + CODEA string + CODEB string + CODEC string + CODED string + Text string + XMLName xml.Name + type TokenRequest struct + GrantType string + Password string + Username string + type TokenResponse struct + AccessToken string + Code string + Error string + ExpiresIn int64 + Message string + TokenType string + func FetchToken(ctx context.Context, url string, request *TokenRequest) (*TokenResponse, error) + func FetchTokenWithMw(ctx context.Context, url string, request *TokenRequest, ...) (*TokenResponse, error) + func (tr *TokenResponse) String() string + type TokenResponseMiddleware func(next OnTokenResponse) OnTokenResponse + type URL struct + FetchToken string + Registration string + SubmitReceipt string + SubmitReport string + VerifyReceipt string + type VATTOTAL struct + ID string + NetAmount float64 + Rate float64 + TaxAmount float64 + type ValueAddedTax struct + Code int64 + ID string + Name string + Percentage float64 + func ParseTaxCode(code int64) ValueAddedTax + func (v *ValueAddedTax) Amount(totalAmount float64) float64 + func (v *ValueAddedTax) NetAmount(totalAmount float64) float64