Browse Source

WIP of DrctDbtTxInf

master
Gerdriaan Mulder 6 years ago
parent
commit
4bbde4c542
  1. 2
      pain/pain_regexp.go
  2. 36
      pain/payment_information_transactions.go

2
pain/pain_regexp.go

@ -27,8 +27,10 @@ var (
"BIC": BICIdentifier,
"CreDtTm": ISODateTime,
"CtrlSum": RestrictedDecimalNumber,
"EndToEndId": RestrictionIdentificationSEPA1,
"IBAN": IBAN2007Identifier,
"Id": RestrictedPersonIdentifierSEPA,
"InstrId": RestrictionIdentificationSEPA1,
"MsgId": RestrictedIdentificationSEPA1,
"NbOfTxs": Max15NumericText,
"Nm": Max70Text,

36
pain/payment_information_transactions.go

@ -0,0 +1,36 @@
package pain
import (
"fmt"
"strings"
)
type DrctDbtTxInf struct {
Id PaymentId `xml:"PmtId"`
Amount CurrencyWithAmount `xml:"InstdAmt"`
}
type CurrencyWithAmount struct {
Currency string `xml:"Ccy,attr"`
Value string `xml:",innerxml"`
}
type PaymentId struct {
InstrumentId string `xml:"InstrId"`
EndToEndId string `xml:"EndToEndId"`
}
func (p *PaymentId) Valid() error {
var err []string
if !SEPARegexps["InstrId"].MatchString(p.InstrumentId) {
err = append(err, "instrument id does not match format")
}
if !SEPARegexps["EndToEndId"].MatchString(p.EndToEndId) {
err = append(err, "end-to-end id does not match format")
}
if len(err) > 0 {
return fmt.Errorf("payment id not valid: %v", strings.Join(err, ", "))
}
return nil
}
Loading…
Cancel
Save