raphaelm / python-sepaxml

SEPA Direct Debit XML generation in python
MIT License
110 stars 41 forks source link

How to use the structured reference field for a SEPA payment? #52

Open haimat opened 1 year ago

haimat commented 1 year ago

In SEPA PAIN.001 standard there are two fields for payment references - structured (<Strd>) and unstructured (<Ustrd>). Here in python-sepaxml one can use the description field in the payment information for the latter. But how can I fill the structured reference?

raphaelm commented 1 year ago

Might be not implemented, at least I haven't used it yet.

haimat commented 1 year ago

Seems so, I haven't found anything like <Strd> in the code. Just wondering - isn't that something, which is used very often?

raphaelm commented 1 year ago

🤷‍♂️ I have not noticed it in the wild yet, but I haven't specifically looked either

haimat commented 1 year ago

Interesting, at least here in Austria we use it a lot :-)

raphaelm commented 1 year ago

Did you close this on purpose? it might be a valid addition to the library (even though I unlikely have time for it)

haimat commented 1 year ago

I am not very good with XML, so I might not be of much help here. But after talking to our bank and testing it with various examples, I can at least describe how it should be. So with an unstructured reference, using the description field for a payment in python-sepaxml, we end up with this:

        <RmtInf>
          <Ustrd>This is an unstructured reference</Ustrd>
        </RmtInf>

And for a structured reference we instead need this:

        <RmtInf>
          <Strd>
            <CdtrRefInf>
              <Tp>
                <CdOrPrtry>
                  <Cd>SCOR</Cd>
                </CdOrPrtry>
              </Tp>
              <Ref>617094556122022</Ref>
            </CdtrRefInf>
          </Strd>
        </RmtInf>

The <Cd> is always this value of "SCOR", and the reference number should be in the <Ref> element. If you just replace the former with the latter, everything works fine. Note, however, that you are not allowed to use both structured and unstructured references for the same payment by SEPA standard.

Hope this helps!

raphaelm commented 1 year ago

closed by accident

BenjoNX commented 10 months ago

I developed a little soft based on your code that could generate a xml sepa file with the fields payment references sepaxml.com available in multi-language