Giter VIP home page Giter VIP logo

java-sepa-xml's Introduction

License: MIT

Simple Java SEPA XML Generator

The Single Euro Payments Area (SEPA) is a payment-integration initiative of the European Union for simplification of bank transfers denominated in euro. As of 2018, SEPA consists of the 28 member states of the European Union, the four member states of the European Free Trade Association (Iceland, Liechtenstein, Norway and Switzerland), Andorra, Monaco and San Marino.

This Java library proviedes SEPA XML files to automate direct debit and credit transfer payment processes. For direct debit transactions you need a creaditor identifier the central bank of your countty is providing to you. The following standarts are supported: pain.001.002.03.xsd pain.008.002.02.xsd

How to use?

SEPA Direct Debit

import org.simple.sepa.*;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class ExampleDirectDebit {
    public static void main(String[] args) {
        final String creditorID = "DE98ZZZ09999999999";

        final SEPABankAccount reciver = new SEPABankAccount(
                "DE89370400440532013000",
                "DEUTDEBBXXX",
                "Joe Doe"
        );

        final List<SEPATransaction> transactions = new ArrayList<SEPATransaction>() {{
            add(new SEPATransaction(
                            new SEPABankAccount(
                                    "DE05500105173195282731",
                                    "VBRSDE33347",
                                    "Peter Parker"
                            ),
                            10.20d,
                            "Invoice 4711564",
                            new Date(),
                            "MYCOMP11111111",
                            new Date(),
                            SEPATransaction.Currency.EUR
                    )
            );

            add(new SEPATransaction(
                            new SEPABankAccount(
                                    "DK5250511963137134",
                                    "UINVDEFFXXX",
                                    "Carl White"
                            ),
                            1000.00d,
                            "Invoice 789765",
                            new Date(),
                            "MYCOMP22222222",
                            new Date(),
                            SEPATransaction.Currency.EUR
                    )
            );

            add(new SEPATransaction(
                            new SEPABankAccount(
                                    "CZ7627005991764514418145",
                                    "SWBSDESSXXX",
                                    "Frank Black"
                            ),
                            50.00d,
                            "Invoice 7856",
                            new Date(),
                            "MYCOMP11111111",
                            new Date(),
                            SEPATransaction.Currency.EUR
                    )
            );
        }};

        final SEPA sepa = new SEPADirectDebit(reciver, transactions, creditorID);
        System.out.println(sepa.toString());
    }
}

SEPA Credit Transfer

import org.simple.sepa.SEPA;
import org.simple.sepa.SEPABankAccount;
import org.simple.sepa.SEPACreditTransfer;
import org.simple.sepa.SEPATransaction;

import java.util.ArrayList;
import java.util.List;

public class ExampleCreditTransfer {
    public static void main(String[] args) {
        final SEPABankAccount sender = new SEPABankAccount(
                "DE89370400440532013000",
                "DEUTDEBBXXX",
                "Joe Doe"
        );

        final List<SEPATransaction> transactions = new ArrayList<SEPATransaction>() {{
            add(new SEPATransaction(
                            new SEPABankAccount(
                                    "DE05500105173195282731",
                                    "VBRSDE33347",
                                    "Peter Parker"
                            ),
                            2000.20d,
                            "Salary PP 2018-07",
                            SEPATransaction.Currency.EUR
                    )
            );

            add(new SEPATransaction(
                            new SEPABankAccount(
                                    "DK5250511963137134",
                                    "UINVDEFFXXX",
                                    "Carl White"
                            ),
                            1000.00d,
                            "Salary CW 2015-12",
                            SEPATransaction.Currency.EUR
                    )
            );

            add(new SEPATransaction(
                            new SEPABankAccount(
                                    "CZ7627005991764514418145",
                                    "SWBSDESSXXX",
                                    "Frank Black"
                            ),
                            5000.00d,
                            "Salary FB 2017-05",
                            SEPATransaction.Currency.EUR
                    )
            );
        }};

        final SEPA sepa = new SEPACreditTransfer(sender, transactions);
        sepa.write(System.out);
    }
}

XML File Result for SEPA Direct Debit

      
<?xml version="1.0" encoding="UTF-8"?>
<Document xmlns="urn:iso:std:iso:20022:tech:xsd:pain.008.002.02" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:iso:std:iso:20022:tech:xsd:pain.008.002.02 pain.008.002.02.xsd">
   <CstmrDrctDbtInitn>
      <GrpHdr>
         <MsgId>DEUTDEBBXXX0020181403121442</MsgId>
         <CreDtTm>2018-07-03T12:14:42.000Z</CreDtTm>
         <NbOfTxs>3</NbOfTxs>
         <InitgPty>
            <Nm>Joe Doe</Nm>
         </InitgPty>
      </GrpHdr>
      <PmtInf>
         <PmtInfId>PMT-ID0-20181403121442</PmtInfId>
         <PmtMtd>DD</PmtMtd>
         <BtchBookg>true</BtchBookg>
         <NbOfTxs>3</NbOfTxs>
         <CtrlSum>1060.2</CtrlSum>
         <PmtTpInf>
            <SvcLvl>
               <Cd>SEPA</Cd>
            </SvcLvl>
            <LclInstrm>
               <Cd>CORE</Cd>
            </LclInstrm>
            <SeqTp>
               <Cd>FRST</Cd>
            </SeqTp>
         </PmtTpInf>
         <ReqdColltnDt>2018-07-03</ReqdColltnDt>
         <Cdtr>
            <Nm>Joe Doe</Nm>
         </Cdtr>
         <CdtrAcct>
            <Id>
               <IBAN>DE89370400440532013000</IBAN>
            </Id>
         </CdtrAcct>
         <CdtrAgt>
            <FinInstnId>
               <BIC>DEUTDEBBXXX</BIC>
            </FinInstnId>
         </CdtrAgt>
         <ChrgBr>SLEV</ChrgBr>
         <CdtrSchmeId>
            <Id>
               <PrvtId>
                  <Othr>
                     <Id>DE98ZZZ09999999999</Id>
                     <SchmeNm>
                        <Prtry>SEPA</Prtry>
                     </SchmeNm>
                  </Othr>
               </PrvtId>
            </Id>
         </CdtrSchmeId>
         <DrctDbtTxInf>
            <PmtId>
               <EndToEndId>NOTPROVIDED</EndToEndId>
            </PmtId>
            <Amt>
               <InstdAmt Ccy="EUR">10.2</InstdAmt>
            </Amt>
            <DrctDbtTx>
               <MndtRltdInf>
                  <MndtId>MYCOMP11111111</MndtId>
                  <DtOfSgntr>2018-07-03</DtOfSgntr>
                  <AmdmntInd>false</AmdmntInd>
               </MndtRltdInf>
            </DrctDbtTx>
            <DbtrAgt>
               <FinInstnId>
                  <BIC>VBRSDE33347</BIC>
               </FinInstnId>
            </DbtrAgt>
            <Dbtr>
               <Nm>Peter Parker</Nm>
            </Dbtr>
            <DbtrAcct>
               <Id>
                  <IBAN>DE05500105173195282731</IBAN>
               </Id>
            </DbtrAcct>
            <UltmtDbtr>
               <Nm>Peter Parker</Nm>
            </UltmtDbtr>
            <RmtInf>
               <Ustrd>Invoice 4711564</Ustrd>
            </RmtInf>
         </DrctDbtTxInf>
         <DrctDbtTxInf>
            <PmtId>
               <EndToEndId>NOTPROVIDED</EndToEndId>
            </PmtId>
            <Amt>
               <InstdAmt Ccy="EUR">1000.0</InstdAmt>
            </Amt>
            <DrctDbtTx>
               <MndtRltdInf>
                  <MndtId>MYCOMP22222222</MndtId>
                  <DtOfSgntr>2018-07-03</DtOfSgntr>
                  <AmdmntInd>false</AmdmntInd>
               </MndtRltdInf>
            </DrctDbtTx>
            <DbtrAgt>
               <FinInstnId>
                  <BIC>UINVDEFFXXX</BIC>
               </FinInstnId>
            </DbtrAgt>
            <Dbtr>
               <Nm>Carl White</Nm>
            </Dbtr>
            <DbtrAcct>
               <Id>
                  <IBAN>DK5250511963137134</IBAN>
               </Id>
            </DbtrAcct>
            <UltmtDbtr>
               <Nm>Carl White</Nm>
            </UltmtDbtr>
            <RmtInf>
               <Ustrd>Invoice 789765</Ustrd>
            </RmtInf>
         </DrctDbtTxInf>
         <DrctDbtTxInf>
            <PmtId>
               <EndToEndId>NOTPROVIDED</EndToEndId>
            </PmtId>
            <Amt>
               <InstdAmt Ccy="EUR">50.0</InstdAmt>
            </Amt>
            <DrctDbtTx>
               <MndtRltdInf>
                  <MndtId>MYCOMP11111111</MndtId>
                  <DtOfSgntr>2018-07-03</DtOfSgntr>
                  <AmdmntInd>false</AmdmntInd>
               </MndtRltdInf>
            </DrctDbtTx>
            <DbtrAgt>
               <FinInstnId>
                  <BIC>SWBSDESSXXX</BIC>
               </FinInstnId>
            </DbtrAgt>
            <Dbtr>
               <Nm>Frank Black</Nm>
            </Dbtr>
            <DbtrAcct>
               <Id>
                  <IBAN>CZ7627005991764514418145</IBAN>
               </Id>
            </DbtrAcct>
            <UltmtDbtr>
               <Nm>Frank Black</Nm>
            </UltmtDbtr>
            <RmtInf>
               <Ustrd>Invoice 7856</Ustrd>
            </RmtInf>
         </DrctDbtTxInf>
      </PmtInf>
   </CstmrDrctDbtInitn>
</Document>

  

XML File Result for SEPA Credit Transfer

<?xml version="1.0" encoding="UTF-8"?>
<Document xmlns="urn:iso:std:iso:20022:tech:xsd:pain.008.002.02" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:iso:std:iso:20022:tech:xsd:pain.008.002.02 pain.008.002.02.xsd">
   <CstmrDrctDbtInitn>
      <GrpHdr>
         <MsgId>DEUTDEBBXXX0020183502113507</MsgId>
         <CreDtTm>2018-07-02T11:35:07.000Z</CreDtTm>
         <NbOfTxs>3</NbOfTxs>
         <InitgPty>
            <Nm>Joe Doe</Nm>
         </InitgPty>
      </GrpHdr>
      <PmtInf>
         <PmtInfId>PMT-ID0-20183502113507</PmtInfId>
         <PmtMtd>DD</PmtMtd>
         <BtchBookg>true</BtchBookg>
         <NbOfTxs>3</NbOfTxs>
         <CtrlSum>8000.2</CtrlSum>
         <PmtTpInf>
            <SvcLvl>
               <Cd>SEPA</Cd>
            </SvcLvl>
            <LclInstrm>
               <Cd>CORE</Cd>
            </LclInstrm>
            <SeqTp>
               <Cd>FRST</Cd>
            </SeqTp>
         </PmtTpInf>
         <ReqdColltnDt>2018-07-02</ReqdColltnDt>
         <Dbtr>
            <Nm>Joe Doe</Nm>
         </Dbtr>
         <DbtrAcct>
            <Id>
               <IBAN>DE89370400440532013000</IBAN>
            </Id>
         </DbtrAcct>
         <DbtrAgt>
            <FinInstnId>
               <BIC>DEUTDEBBXXX</BIC>
            </FinInstnId>
         </DbtrAgt>
         <ChrgBr>SLEV</ChrgBr>
         <CdtTrfTxInf>
            <PmtId>
               <EndToEndId>NOTPROVIDED</EndToEndId>
            </PmtId>
            <Amt>
               <InstdAmt Ccy="EUR">2000.2</InstdAmt>
            </Amt>
            <CdtrAgt>
               <FinInstnId>
                  <BIC>VBRSDE33347</BIC>
               </FinInstnId>
            </CdtrAgt>
            <Cdtr>
               <Nm>Peter Parker</Nm>
            </Cdtr>
            <CdtrAcct>
               <Id>
                  <IBAN>DE05500105173195282731</IBAN>
               </Id>
            </CdtrAcct>
         </CdtTrfTxInf>
         <CdtTrfTxInf>
            <PmtId>
               <EndToEndId>NOTPROVIDED</EndToEndId>
            </PmtId>
            <Amt>
               <InstdAmt Ccy="EUR">1000.0</InstdAmt>
            </Amt>
            <CdtrAgt>
               <FinInstnId>
                  <BIC>UINVDEFFXXX</BIC>
               </FinInstnId>
            </CdtrAgt>
            <Cdtr>
               <Nm>Carl White</Nm>
            </Cdtr>
            <CdtrAcct>
               <Id>
                  <IBAN>DK5250511963137134</IBAN>
               </Id>
            </CdtrAcct>
         </CdtTrfTxInf>
         <CdtTrfTxInf>
            <PmtId>
               <EndToEndId>NOTPROVIDED</EndToEndId>
            </PmtId>
            <Amt>
               <InstdAmt Ccy="EUR">5000.0</InstdAmt>
            </Amt>
            <CdtrAgt>
               <FinInstnId>
                  <BIC>SWBSDESSXXX</BIC>
               </FinInstnId>
            </CdtrAgt>
            <Cdtr>
               <Nm>Frank Black</Nm>
            </Cdtr>
            <CdtrAcct>
               <Id>
                  <IBAN>CZ7627005991764514418145</IBAN>
               </Id>
            </CdtrAcct>
         </CdtTrfTxInf>
      </PmtInf>
   </CstmrDrctDbtInitn>
</Document>

License

The MIT License (MIT)

Copyright (c) 2016 JohannesLaier

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

java-sepa-xml's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

java-sepa-xml's Issues

BIC is optional in CreditTransfer

In PAIN 001.001.03, BIC is optional as the account is fully specified with the IBAN. So I provide a pull request to account for BIC being null in BankAccount object when using the two-arguments constructor.

As a second thing, I updated pom.xml to depend from a newer version of the surefire plugin to mitigate compiler errors.

Please check and apply.

Best regards
Alexander

PmtMtd and subject with creditransfers

Hi, thanks for work. Really helped me get things going.

I faced two minor issues:

  1. According to this document (https://www.nordea.com/Images/36-262430/MIG-CAP_pain%20001.001.03_Payments_v_1.5.pdf) valid codes in the used standard (pain.001.001.03) are CHK and TRF. So I altered SEPA.Java and with TRF everything works fine.

  2. When I created a credit transfer file the subject was left out. I altered the last lines in SEPACreditTransfer.java to nodeCdtTrfTxInf.append("RmtInf").append("Ustrd").value(transaction.getSubject());

From my understanding Remittance can't be set at all while using credit transfers.

Have a nice weekend

Not supporting credit transfer AND direct debit?

from the wiki:
https://wiki.xmldation.com/General_Information/ISO20022/pain.008
Pain.008 is a payments initation message by ISO 20022. It depicts a Direct Debit message in XML format.

https://wiki.xmldation.com/General_Information/ISO_20022/pain.001
Pain.001 is a payments initiation message by ISO 20022. It depicts a Credit Transfer message in XML format.

Question:
Since the SepaDirectDebit constructor calls the super build, how would it be possibe to create a pain 008 file?
THe build(0 is hard coded on pain.001.001.03.

Alos, how did you generate the example in the readme -> XML File Result for SEPA Direct Debit

And 'XML File Result for SEPA Credit Transfer' has the wrong document xmlns reference (pain 8 instead of 1)

Regards,
Daniel

Release

How to import the library in my project?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.