Softinnov / gosepa

Go SEPA

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

gosepa

Go Report Card

gosepa is a sepa xml file generator written in Go compatible with pain.002.001.03 schema (Customer Credit Transfer Initiation V03).

This generator uses shortcuts to simplify the norm implementation : for example, there is only one id used for several differents references (I never have to deal with multiple references)

Install

$ go get github.com/softinnov/gosepa/sepa

Usage

    package main

    import (
        "fmt"
        "github.com/softinnov/gosepa/sepa"
        "log"
    )

    func main() {

        doc := &sepa.Document{}
        err := doc.InitDoc("MSGID", "2017-06-07T14:39:33", "2017-06-09", "Emiter Name", "FR1420041010050500013M02606", "BKAUATWWP")
        if err != nil {
            log.Fatal("can't create sepa document : ", err)
        }

        err = doc.AddTransaction("F201705", 70000, "EUR", "DEF Electronics", "GB29NWBK60161331926819")
        if err != nil {
            log.Fatal("can't add transaction in the sepa document : ", err)
        }

        res, err := doc.PrettySerialize()
        if err != nil {
            log.Fatal("can't get the xml doc : ", err)
        }

        fmt.Println(string(res))
    }

Tests

Unit test the go way :

$ go test -v

You can use any xsd validation tool. I use xmllint from libxml.

$ sudo apt install libxml2-utils

You have to generate a file so xmllint can check it. From the sample in the 'tests' folder :

$ go run usage.go > test.xml
$ xmllint --noout --schema pain.001.001.03.xsd test.xml

Ressources

About

Go SEPA

License:MIT License


Languages

Language:Go 100.0%