eet

package module
v0.0.0-...-cc57b81 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2019 License: BSD-2-Clause Imports: 20 Imported by: 0

README

Go EET Client

Implementation of EET client in Go

Installation

$ go get github/prochac/eet

Example

package main

import (
	"fmt"
	"log"
	"time"
	
	"github.com/prochac/eet"
)

func main(){
    d, _ := eet.NewDispatcher(eet.PlaygroundService,
		"EET_CA1_Playground-CZ00000019.p12",
		"eet",
    )
    r := eet.Receipt{
		UuidZpravy: "49ee3022-de4e-447c-b07f-a550b2378410",
		DicPopl:    "CZ00000019",
		IdProvoz:   273,
		IdPokl:     "/5546/RO24",
		PoradCis:   "0/6460/ZQ42",
		DatTrzby:   time.Now(),
		CelkTrzba:  0,
		Rezim:      eet.RegularRegime,
    }
    response, err := d.SendPayment(r)
    if err != nil {
    	log.Fatal(err)
    }
    fmt.Println("Fik: ", response.Fik)
}

Thanks

Thanks for help and inspiration

Documentation

Index

Constants

View Source
const (
	NsSoapUrl    = "http://schemas.xmlsoap.org/soap/envelope/"
	NsSoapEnvUrl = "http://schemas.xmlsoap.org/soap/envelope/"
	NsWsseUrl    = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
	NsWsuUrl     = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
	NsDsUrl      = "http://www.w3.org/2000/09/xmldsig#"
	NsEcUrl      = "http://www.w3.org/2001/10/xml-exc-c14n#"
	NsEetUrl     = "http://fs.mfcr.cz/eet/schema/v3"

	NsSoap    = "soap"
	NsSoapEnv = "SOAP-ENV"
	NsWsse    = "wsse"
	NsWsu     = "wsu"
	NsDs      = "ds"
	NsEc      = "ec"

	EncodingBase64Url     = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary"
	ValueX509Url          = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3"
	AlgorithmC14N         = "http://www.w3.org/2001/10/xml-exc-c14n#"
	AlgorithmSHA256       = "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"
	AlgorithmDigestSHA256 = "http://www.w3.org/2001/04/xmlenc#sha256"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Bkp

type Bkp struct {
	XMLName  xml.Name        `xml:"bkp"`
	Digest   BkpDigestType   `xml:"digest,attr"`
	Encoding BkpEncodingType `xml:"encoding,attr"`
	Value    string          `xml:",chardata"`
}

func NewBkp

func NewBkp(pkp Pkp) (Bkp, error)

type BkpDigestType

type BkpDigestType string
const (
	BkpDigestTypeSHA1 BkpDigestType = "SHA1"
)

type BkpEncodingType

type BkpEncodingType string
const (
	BkpEncodingTypeBase16 BkpEncodingType = "base16"
)

type CZDICType

type CZDICType string

func NewCZDICType

func NewCZDICType(dic string) (CZDICType, error)

type CastkaType

type CastkaType string

func NewCastkaType

func NewCastkaType(castka float64) (CastkaType, error)

type Chyba

type Chyba struct {
	XMLName xml.Name `xml:"Chyba"`
	Kod     int      `xml:"kod,attr"`
	Test    bool     `xml:"test,attr"`
	Chyba   string   `xml:",chardata"`
}

func (Chyba) Error

func (ch Chyba) Error() string

type Data

type Data struct {
	XMLName         xml.Name     `xml:"Data"`
	CelkTrzba       CastkaType   `xml:"celk_trzba,attr"`
	CerpZuct        CastkaType   `xml:"cerp_zuct,attr,omitempty"`
	CestSluz        CastkaType   `xml:"cest_sluz,attr,omitempty"`
	Dan1            CastkaType   `xml:"dan1,attr,omitempty"`
	Dan2            CastkaType   `xml:"dan2,attr,omitempty"`
	Dan3            CastkaType   `xml:"dan3,attr,omitempty"`
	DatTrzby        DateTimeType `xml:"dat_trzby,attr"`
	DicPopl         CZDICType    `xml:"dic_popl,attr"`
	DicPoverujiciho CZDICType    `xml:"dic_poverujiciho,attr,omitempty"`
	IdPokl          String20     `xml:"id_pokl,attr"`
	IdProvoz        IdProvozType `xml:"id_provoz,attr"`
	PoradCis        String25     `xml:"porad_cis,attr"`
	PouzitZboz1     CastkaType   `xml:"pouzit_zboz1,attr,omitempty"`
	PouzitZboz2     CastkaType   `xml:"pouzit_zboz2,attr,omitempty"`
	PouzitZboz3     CastkaType   `xml:"pouzit_zboz3,attr,omitempty"`
	Rezim           RezimType    `xml:"rezim,attr"`
	UrcenoCerpZuct  CastkaType   `xml:"urceno_cerp_zuct,attr,omitempty"`
	ZaklDan1        CastkaType   `xml:"zakl_dan1,attr,omitempty"`
	ZaklDan2        CastkaType   `xml:"zakl_dan2,attr,omitempty"`
	ZaklDan3        CastkaType   `xml:"zakl_dan3,attr,omitempty"`
	ZaklNepodlDph   CastkaType   `xml:"zakl_nepodl_dph,attr,omitempty"`
}

type DateTimeType

type DateTimeType string

func NewDateTimeType

func NewDateTimeType(dateTime time.Time) DateTimeType

type Dispatcher

type Dispatcher struct {
	// contains filtered or unexported fields
}

func NewDispatcher

func NewDispatcher(service Service, certPath, password string) (*Dispatcher, error)

func (*Dispatcher) SendPayment

func (d *Dispatcher) SendPayment(receipt Receipt) (*Response, error)

type DsCanonicalizationMethod

type DsCanonicalizationMethod struct {
	XMLName             xml.Name              `xml:"ds:CanonicalizationMethod"`
	Algorithm           string                `xml:"Algorithm,attr"`
	InclusiveNamespaces EcInclusiveNamespaces `xml:"ec:InclusiveNamespaces"`
}

type DsDigestMethod

type DsDigestMethod struct {
	XMLName   xml.Name `xml:"ds:DigestMethod"`
	Algorithm string   `xml:"Algorithm,attr"`
}

type DsDigestValue

type DsDigestValue struct {
	XMLName xml.Name `xml:"ds:DigestValue"`
	Value   string   `xml:",chardata"`
}

type DsKeyInfo

type DsKeyInfo struct {
	XMLName                xml.Name                   `xml:"ds:KeyInfo"`
	Id                     string                     `xml:"Id,attr"`
	SecurityTokenReference WsseSecurityTokenReference `xml:"wsse:SecurityTokenReference"`
}

type DsReference

type DsReference struct {
	XMLName      xml.Name       `xml:"ds:Reference"`
	URI          string         `xml:"URI,attr"`
	Transforms   DsTransforms   `xml:"ds:Transforms"`
	DigestMethod DsDigestMethod `xml:"ds:DigestMethod"`
	DigestValue  DsDigestValue  `xml:"ds:DigestValue"`
}

type DsSignature

type DsSignature struct {
	XMLName        xml.Name         `xml:"ds:Signature"`
	XmlnsDs        string           `xml:"xmlns:ds,attr"`
	Id             string           `xml:"Id,attr"`
	SignedInfo     DsSignedInfo     `xml:"ds:SignedInfo"`
	SignatureValue DsSignatureValue `xml:"ds:SignatureValue"`
	KeyInfo        DsKeyInfo        `xml:"ds:KeyInfo"`
}

type DsSignatureMethod

type DsSignatureMethod struct {
	XMLName   xml.Name `xml:"ds:SignatureMethod"`
	Algorithm string   `xml:"Algorithm,attr"`
}

type DsSignatureValue

type DsSignatureValue struct {
	XMLName xml.Name `xml:"ds:SignatureValue"`
	Value   string   `xml:",chardata"`
}

type DsSignedInfo

type DsSignedInfo struct {
	XMLName                xml.Name                 `xml:"ds:SignedInfo"`
	XmlnsDs                string                   `xml:"xmlns:ds,attr"`
	XmlnsSoap              string                   `xml:"xmlns:soap,attr"`
	CanonicalizationMethod DsCanonicalizationMethod `xml:"ds:CanonicalizationMethod"`
	SignatureMethod        DsSignatureMethod        `xml:"ds:SignatureMethod"`
	Reference              DsReference              `xml:"ds:Reference"`
}

type DsTransform

type DsTransform struct {
	XMLName             xml.Name              `xml:"ds:Transform"`
	Algorithm           string                `xml:"Algorithm,attr"`
	InclusiveNamespaces EcInclusiveNamespaces `xml:"ec:InclusiveNamespaces"`
}

type DsTransforms

type DsTransforms struct {
	XMLName   xml.Name    `xml:"ds:Transforms"`
	Transform DsTransform `xml:"ds:Transform"`
}

type EcInclusiveNamespaces

type EcInclusiveNamespaces struct {
	XMLName    xml.Name `xml:"ec:InclusiveNamespaces"`
	XmlnsEc    string   `xml:"xmlns:ec,attr"`
	PrefixList string   `xml:"PrefixList,attr"`
}

type Hlavicka

type Hlavicka struct {
	XMLName      xml.Name     `xml:"Hlavicka"`
	DatOdesl     DateTimeType `xml:"dat_odesl,attr"`
	Overeni      bool         `xml:"overeni,attr,omitempty"`
	PrvniZaslani bool         `xml:"prvni_zaslani,attr"`
	UuidZpravy   UUIDType     `xml:"uuid_zpravy,attr"`
}

type IdProvozType

type IdProvozType int32

func NewIdProvozType

func NewIdProvozType(idProvozType int) (IdProvozType, error)

func (IdProvozType) String

func (i IdProvozType) String() string

type KontrolniKody

type KontrolniKody struct {
	XMLName xml.Name `xml:"KontrolniKody"`
	Pkp     Pkp      `xml:"pkp"`
	Bkp     Bkp      `xml:"bkp"`
}

type Odpoved

type Odpoved struct {
	XMLName   xml.Name        `xml:"Odpoved"`
	Hlavicka  OdpovedHlavicka `xml:"Hlavicka"`
	Potvrzeni *Potvrzeni      `xml:"Potvrzeni"`
	Chyba     *Chyba          `xml:"Chyba"`
	Varovani  []Varovani      `xml:"Varovani"`
}

type OdpovedHlavicka

type OdpovedHlavicka struct {
	XMLName    xml.Name  `xml:"Hlavicka"`
	UuidZpravy string    `xml:"uuid_zpravy,attr"`
	DatPrij    time.Time `xml:"dat_prij,attr"`
	DatOdmit   time.Time `xml:"dat_odmit,attr"`
	Bkp        string    `xml:"bkp,attr"`
}

type Pkp

type Pkp struct {
	XMLName  xml.Name        `xml:"pkp"`
	Cipher   PkpCipherType   `xml:"cipher,attr"`
	Digest   PkpDigestType   `xml:"digest,attr"`
	Encoding PkpEncodingType `xml:"encoding,attr"`
	Value    string          `xml:",chardata"`
}

func NewPkp

func NewPkp(t Trzba, signer *Signer) (Pkp, error)

type PkpCipherType

type PkpCipherType string
const (
	PkpCipherTypeRSA2048 PkpCipherType = "RSA2048"
)

type PkpDigestType

type PkpDigestType string
const (
	PkpDigestTypeSHA256 PkpDigestType = "SHA256"
)

type PkpEncodingType

type PkpEncodingType string
const (
	PkpEncodingTypeBase64 PkpEncodingType = "base64"
)

type Potvrzeni

type Potvrzeni struct {
	XMLName xml.Name `xml:"Potvrzeni"`
	Fik     string   `xml:"fik,attr"`
	Test    bool     `xml:"test,attr"`
}

type Receipt

type Receipt struct {
	UuidZpravy      string
	PrvniZaslani    bool
	DicPopl         string
	DicPoverujiciho string
	IdProvoz        int
	IdPokl          string
	PoradCis        string
	DatTrzby        time.Time
	CelkTrzba       float64
	ZaklNepodlDph   float64
	ZaklDan1        float64
	Dan1            float64
	ZaklDan2        float64
	Dan2            float64
	ZaklDan3        float64
	Dan3            float64
	CestSluz        float64
	PouzitZboz1     float64
	PouzitZboz2     float64
	PouzitZboz3     float64
	UrcenoCerpZuct  float64
	CerpZuct        float64
	Rezim           Regime
}

func (Receipt) Trzba

func (r Receipt) Trzba(signer *Signer) (Trzba, error)

type Regime

type Regime int
const (
	RegularRegime Regime = iota
	SimplifiedRegime
)

type Response

type Response struct {
	DatPrij time.Time
	Fik     string
	Bkp     string
	// contains filtered or unexported fields
}

func (Response) Warnings

func (r Response) Warnings() []string

type RezimType

type RezimType int
const (
	BeznyRezim RezimType = iota
	ZjednodusenyRezim
)

type SOAPBody

type SOAPBody struct {
	XMLName   xml.Name    `xml:"soap:Body"`
	XmlnsSoap string      `xml:"xmlns:soap,attr"`
	XmlnsWsu  string      `xml:"xmlns:wsu,attr"`
	WsuId     string      `xml:"wsu:Id,attr"`
	Content   interface{} `xml:",omitempty"`
}

type SOAPEnvelopeRequest

type SOAPEnvelopeRequest struct {
	XMLName   xml.Name   `xml:"soap:Envelope"`
	XmlnsSoap string     `xml:"xmlns:soap,attr"`
	Header    SOAPHeader `xml:"SOAP-ENV:Header"`
	Body      SOAPBody   `xml:"soap:Body"`
}

func NewSOAPEnvelopeRequest

func NewSOAPEnvelopeRequest(content interface{}, signer *Signer) (SOAPEnvelopeRequest, error)

type SOAPEnvelopeResponse

type SOAPEnvelopeResponse struct {
	XMLName xml.Name `xml:"Envelope"`
	Body    struct {
		XMLName xml.Name `xml:"Body"`
		Odpoved Odpoved
	}
}

type SOAPHeader

type SOAPHeader struct {
	XMLName      xml.Name     `xml:"SOAP-ENV:Header"`
	XmlnsSoapEnv string       `xml:"xmlns:SOAP-ENV,attr"`
	Security     WsseSecurity `xml:"wsse:Security"`
}

type Service

type Service string
const (
	PlaygroundService Service = "https://pg.eet.cz:443/eet/services/EETServiceSOAP/v3"
	ProductionService Service = "https://prod.eet.cz:443/eet/services/EETServiceSOAP/v3"
)

type Signer

type Signer struct {
	// contains filtered or unexported fields
}

func NewSigner

func NewSigner(certPath string, password string) (*Signer, error)

func (*Signer) Base64Cert

func (s *Signer) Base64Cert() string

func (*Signer) Sign

func (s *Signer) Sign(data []byte) ([]byte, error)

Sign signs data with rsa-sha256

type String20

type String20 string

func NewString20

func NewString20(string20 string) (String20, error)

type String25

type String25 string

func NewString25

func NewString25(string25 string) (String25, error)

type Trzba

type Trzba struct {
	XMLName       xml.Name      `xml:"http://fs.mfcr.cz/eet/schema/v3 Trzba"`
	Hlavicka      Hlavicka      `xml:"Hlavicka"`
	Data          Data          `xml:"Data"`
	KontrolniKody KontrolniKody `xml:"KontrolniKody"`
}

type UUIDType

type UUIDType string

func NewUUIDType

func NewUUIDType(uuid string) (UUIDType, error)

type Varovani

type Varovani struct {
	XMLName  xml.Name `xml:"Varovani"`
	KodVarov int      `xml:"kod_varov,attr"`
	Varovani string   `xml:",chardata"`
}

type WsseBinarySecurityToken

type WsseBinarySecurityToken struct {
	XMLName      xml.Name `xml:"wsse:BinarySecurityToken"`
	EncodingType string   `xml:"EncodingType,attr"`
	ValueType    string   `xml:"ValueType,attr"`
	WsuId        string   `xml:"wsu:Id,attr"`
	Value        string   `xml:",chardata"`
}

type WsseReference

type WsseReference struct {
	XMLName   xml.Name `xml:"wsse:Reference"`
	URI       string   `xml:"URI,attr"`
	ValueType string   `xml:"ValueType,attr"`
}

type WsseSecurity

type WsseSecurity struct {
	XMLName             xml.Name                `xml:"wsse:Security"`
	XmlnsWsse           string                  `xml:"xmlns:wsse,attr"`
	XmlnsWsu            string                  `xml:"xmlns:wsu,attr"`
	MustUnderstand      string                  `xml:"soap:mustUnderstand,attr"`
	BinarySecurityToken WsseBinarySecurityToken `xml:"wsse:BinarySecurityToken"`
	Signature           DsSignature             `xml:"ds:Signature"`
}

type WsseSecurityTokenReference

type WsseSecurityTokenReference struct {
	XMLName   xml.Name      `xml:"wsse:SecurityTokenReference"`
	XmlnsWsse string        `xml:"xmlns:wsse,attr"`
	XmlnsWsu  string        `xml:"xmlns:wsu,attr"`
	WsuId     string        `xml:"wsu:Id,attr"`
	Reference WsseReference `xml:"wsse:Reference"`
}

Jump to

Keyboard shortcuts

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