Create a SEPA Direct Debit (Lastschrift) with Obantoo

That is a short manual how to use OBanToo to create xml files for direct debit using SEPA. OBanToo is Java library which contians a collection of banking tools. It provides implementations for the creation of SEPA-XML-files as well as the conversion from old bank identifier codes to IBAN. The usage of SEPA is mandatory as the old file exchange method "DTAUS" is deprecated. 

Disclaimer

The handling of bank accounts and transactions is a very sensitive topic. This is only a rough introduction how to use the OBanToo library. Follow the guidelines at your own risk! Make yourself familiar with the current state of regulations and laws in this particular field.

Step 1: Set the Meta Information 

Basislastschrift bl = new Basislastschrift();
// Set the name of your organisation
bl.setName("");
// Set the BIC of your bank account
bl.setBIC("");
// Set the IBAN for your bank account
bl.setIBAN("");
// You have to request for a Creditor Identifier (German: GläubigerID) for your Organisation/Bank Account
// in order to be allowed to debit money
bl.setGlaeubigerID("");
// What's the purpose of this debits? Examples: Annual rent, membership fee
bl.setMessageID("");

Step 2: Add a Direct Debit (Per Transaction)

// Payor (German: Zahler) 
Zahler zahler A= new Zahler();
// Set the amount of money you want to debit
zahler.setBetrag(new BigDecimal(sAmount));

// the name of payor
zahler.setName(sName);
// bank account of the payor
zahler.setBic(sBIC);
zahler.setIban(sIban);
// set the purpose of payment (The payor will see this in the statement of account)
zahler.setVerwendungszweck(sText);

MandatSequence sew = null;
// If it is the first debit performed on this bank account, the MandatSequence has to be set accordingly
if(bFirstLastschrift)
sew = MandatSequence.FRST;
else
sew = MandatSequence.RCUR;
zahler.setMandatsequence(sew);

// The due date of this transaction will be calculated from today + 10 days
// The execution date is somehow limited (e.g. not earlier than 6 days after publishing the order and not later than 45 days)
GregorianCalendar dueDate = new GregorianCalendar();
dueDate.roll(GregorianCalendar.DATE, 10);
zahler.setFaelligkeit(new Date(dueDate.getTimeInMillis()));

// You should have a proof that the payor allowed you to debit his account
// And by this, you should specify the date when this happended
zahler.setMandatdatum(new Date(114, 0, 1)); 
// Also set an unique (!) ID for your payor (Could be for example the ID in the database)
zahler.setMandatid("");
bl.add()

Step 3: Write to disk

File file = new File("/users/max/Desktop/sepa.xml");
bl.write(file);

Leave a Comment

comments powered by Disqus