Created
November 4, 2023 13:27
-
-
Save gantoniadispc14/fd3e6f26451d3f4edb54f354355f7cbe to your computer and use it in GitHub Desktop.
Pacs007SepaSibsDdMessageAutoReplies
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package gr.datamation.iso20022.sepa.sibs.dd; | |
import gr.datamation.iso20022.sepa.sibs.dd.pacs.FIToFIPaymentReversal09SepaSibsDd; | |
import gr.datamation.iso20022.sepa.sibs.dd.pacs.PaymentReturn09SepaSibsDd; | |
import gr.datamation.iso20022.sepa.sibs.dd.replies.FIToFIPaymentReversalSepaSibsDdAutoReplies; | |
import gr.datamation.replies.common.ChargesInformation; | |
import gr.datamation.replies.common.MsgReplyInfo; | |
import gr.datamation.replies.common.ReasonInformation; | |
import gr.datamation.validation.error.ValidationError; | |
import gr.datamation.validation.error.ValidationErrorList; | |
import java.math.BigDecimal; | |
import java.time.LocalDate; | |
import java.util.Collections; | |
public class Pacs007SepaSibsDdMessageAutoReplies { | |
public static void main(String... args) { | |
execute(); | |
} | |
public static void execute() { | |
paymentReturnAutoReply(); | |
} | |
public static void paymentReturnAutoReply() { | |
try { | |
//Initialize the message object | |
FIToFIPaymentReversal09SepaSibsDd pacs007 = new FIToFIPaymentReversal09SepaSibsDd(); | |
//Optionally use an existing message if we do not want to create the object from scratch | |
pacs007.parseXML(validPacs007SepaSibsDdIncomingString); | |
//Perform validation | |
ValidationErrorList validationErrorList = pacs007.validate(); | |
if (!validationErrorList.isEmpty()) | |
throw new Exception("Invalid pacs.007 message to return"); | |
FIToFIPaymentReversalSepaSibsDdAutoReplies<FIToFIPaymentReversal09SepaSibsDd, PaymentReturn09SepaSibsDd> pacs007AutoReplies = | |
new FIToFIPaymentReversalSepaSibsDdAutoReplies<>(pacs007); | |
MsgReplyInfo msgReplyInfo = new MsgReplyInfo(); | |
ReasonInformation reasonInformation = new ReasonInformation(); | |
reasonInformation.setType(ReasonInformation.Type.CD); //mandatory | |
reasonInformation.setValue("AM05"); //mandatory | |
reasonInformation.setAddtlInf(Collections.singletonList("Additional info")); //optional | |
msgReplyInfo.setRsnInf(reasonInformation); | |
msgReplyInfo.setReplyId("pacs003Reply"); //optional | |
msgReplyInfo.setOrgnlMsgId("1234"); //optional | |
msgReplyInfo.setIntrBkSttlmDt(LocalDate.now()); //optional, if empty, current date will be used | |
ChargesInformation chargesInformation = new ChargesInformation(); | |
chargesInformation.setAmount(new BigDecimal("2.00")); | |
chargesInformation.setAgentBic("AAAAGB2L"); //optional | |
msgReplyInfo.setChargesInformation(Collections.singletonList(chargesInformation)); //optional | |
msgReplyInfo.setChargeBearer("SLEV"); //optional | |
PaymentReturn09SepaSibsDd pacs004 = pacs007AutoReplies.autoReply(new PaymentReturn09SepaSibsDd(), Collections.singletonList(msgReplyInfo)); | |
validationErrorList = pacs004.validate(); | |
if (validationErrorList.isEmpty()) { | |
System.out.println("Return Message is valid"); | |
System.out.println(pacs004.convertToXML()); //Get the generated xml | |
} else { | |
handleValidationError(validationErrorList); | |
} | |
} catch (Exception e) { | |
e.printStackTrace(); | |
System.err.println(e.getMessage()); | |
} | |
} | |
private static void handleValidationError(ValidationErrorList validationErrorList) { | |
System.err.println("Message is invalid, and the errors are the following:"); | |
for (ValidationError error : validationErrorList) { | |
System.err.println(error.toString()); | |
System.err.println( | |
"Error Code: " + error.getErrorCode() + "\n" + | |
"Error Description: " + error.getDescription() + "\n" + | |
"Line number in error inside the tag: " + error.getLine() + "\n" | |
); | |
} | |
} | |
private static final String validPacs007SepaSibsDdIncomingString = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + | |
"<Document xmlns=\"urn:iso:std:iso:20022:tech:xsd:pacs.007.001.09\">\n" + | |
" <FIToFIPmtRvsl>\n" + | |
" <GrpHdr>\n" + | |
" <MsgId>AAAAUS29-REVERSAL/0012</MsgId>\n" + | |
" <CreDtTm>2015-07-06T10:35:00</CreDtTm>\n" + | |
" <NbOfTxs>1</NbOfTxs>\n" + | |
" <GrpRvsl>false</GrpRvsl>\n" + | |
" <TtlRvsdIntrBkSttlmAmt Ccy=\"EUR\">100.00</TtlRvsdIntrBkSttlmAmt>\n" + | |
" <IntrBkSttlmDt>2015-07-06</IntrBkSttlmDt>\n" + | |
" <SttlmInf>\n" + | |
" <SttlmMtd>CLRG</SttlmMtd>\n" + | |
" <ClrSys>\n" + | |
" <Prtry>SBS</Prtry>\n" + | |
" </ClrSys>\n" + | |
" </SttlmInf>\n" + | |
" <InstgAgt>\n" + | |
" <FinInstnId>\n" + | |
" <BICFI>AAAAUS29</BICFI>\n" + | |
" </FinInstnId>\n" + | |
" </InstgAgt>\n" + | |
" <InstdAgt>\n" + | |
" <FinInstnId>\n" + | |
" <BICFI>ABABUS23</BICFI>\n" + | |
" </FinInstnId>\n" + | |
" </InstdAgt>\n" + | |
" </GrpHdr>\n" + | |
" <OrgnlGrpInf>\n" + | |
" <OrgnlMsgId>AAAA120628-123v</OrgnlMsgId>\n" + | |
" <OrgnlMsgNmId>pacs.003.001.08</OrgnlMsgNmId>\n" + | |
" </OrgnlGrpInf>\n" + | |
" <TxInf>\n" + | |
" <RvslId>RIT5467</RvslId>\n" + | |
" <OrgnlEndToEndId>VA060327/0123</OrgnlEndToEndId>\n" + | |
" <OrgnlTxId>AAAAUS29/150628/ad458</OrgnlTxId>\n" + | |
" <OrgnlIntrBkSttlmAmt Ccy=\"EUR\">10.0</OrgnlIntrBkSttlmAmt>\n" + | |
" <RvsdIntrBkSttlmAmt Ccy=\"EUR\">100.00</RvsdIntrBkSttlmAmt>\n" + | |
" <RvsdInstdAmt Ccy=\"EUR\">1025</RvsdInstdAmt>\n" + | |
" <ChrgsInf>\n" + | |
" <Amt Ccy=\"EUR\">100</Amt>\n" + | |
" <Agt>\n" + | |
" <FinInstnId>\n" + | |
" <BICFI>TESTBICA</BICFI>\n" + | |
" </FinInstnId>\n" + | |
" </Agt>\n" + | |
" </ChrgsInf>\n" + | |
" <RvslRsnInf>\n" + | |
" <Orgtr>\n" + | |
" <Id>\n" + | |
" <OrgId>\n" + | |
" <AnyBIC>AAAAUS29</AnyBIC>\n" + | |
" </OrgId>\n" + | |
" </Id>\n" + | |
" </Orgtr>\n" + | |
" <Rsn>\n" + | |
" <Cd>AM05</Cd>\n" + | |
" </Rsn>\n" + | |
" </RvslRsnInf>\n" + | |
" <OrgnlTxRef>\n" + | |
" <IntrBkSttlmDt>2015-06-28</IntrBkSttlmDt>\n" + | |
" <ReqdColltnDt>2015-07-13</ReqdColltnDt>\n" + | |
" <CdtrSchmeId>\n" + | |
" <Id>\n" + | |
" <PrvtId>\n" + | |
" <Othr>\n" + | |
" <Id>string</Id>\n" + | |
" <SchmeNm>\n" + | |
" <Prtry>SEPA</Prtry>\n" + | |
" </SchmeNm>\n" + | |
" </Othr>\n" + | |
" </PrvtId>\n" + | |
" </Id>\n" + | |
" </CdtrSchmeId>\n" + | |
" <SttlmInf>\n" + | |
" <SttlmMtd>CLRG</SttlmMtd>\n" + | |
" <ClrSys>\n" + | |
" <Prtry>SBS</Prtry>\n" + | |
" </ClrSys>\n" + | |
" </SttlmInf>\n" + | |
" <PmtTpInf>\n" + | |
" <SvcLvl>\n" + | |
" <Cd>SEPA</Cd>\n" + | |
" </SvcLvl>\n" + | |
" <LclInstrm>\n" + | |
" <Cd>CORE</Cd>\n" + | |
" </LclInstrm>\n" + | |
" <SeqTp>RCUR</SeqTp>\n" + | |
" </PmtTpInf>\n" + | |
" <MndtRltdInf>\n" + | |
" <MndtId>string</MndtId>\n" + | |
" <DtOfSgntr>2016-02-20</DtOfSgntr>\n" + | |
" <ElctrncSgntr>string</ElctrncSgntr>\n" + | |
" </MndtRltdInf>\n" + | |
" <RmtInf>\n" + | |
" <Strd>\n" + | |
" <CdtrRefInf>\n" + | |
" <Tp>\n" + | |
" <CdOrPrtry>\n" + | |
" <Cd>SCOR</Cd>\n" + | |
" </CdOrPrtry>\n" + | |
" <Issr>ISO</Issr>\n" + | |
" </Tp>\n" + | |
" <Ref>RF3620210917084619IQF0838</Ref>\n" + | |
" </CdtrRefInf>\n" + | |
" </Strd>\n" + | |
" </RmtInf>\n" + | |
" <UltmtDbtr>\n" + | |
" <Pty>\n" + | |
" <Nm>Ultimate Debtor Test 1</Nm>\n" + | |
" <Id>\n" + | |
" <PrvtId>\n" + | |
" <Othr>\n" + | |
" <Id>AX035662</Id>\n" + | |
" <SchmeNm>\n" + | |
" <Cd>NIDN</Cd>\n" + | |
" </SchmeNm>\n" + | |
" </Othr>\n" + | |
" </PrvtId>\n" + | |
" </Id>\n" + | |
" </Pty>\n" + | |
"\n" + | |
" </UltmtDbtr>\n" + | |
" <Dbtr>\n" + | |
" <Pty>\n" + | |
" <Nm>Jones</Nm>\n" + | |
" <PstlAdr>\n" + | |
" <StrtNm>Hudson Street</StrtNm>\n" + | |
" <BldgNb>19</BldgNb>\n" + | |
" <PstCd>NJ 07302</PstCd>\n" + | |
" <TwnNm>Jersey City</TwnNm>\n" + | |
" <Ctry>US</Ctry>\n" + | |
" </PstlAdr>\n" + | |
" </Pty>\n" + | |
" </Dbtr>\n" + | |
" <DbtrAcct>\n" + | |
" <Id>\n" + | |
" <IBAN>GR4999999990000000123456789</IBAN>\n" + | |
" </Id>\n" + | |
" </DbtrAcct>\n" + | |
" <DbtrAgt>\n" + | |
" <FinInstnId>\n" + | |
" <BICFI>BBBBUS39</BICFI>\n" + | |
" </FinInstnId>\n" + | |
" </DbtrAgt>\n" + | |
" <CdtrAgt>\n" + | |
" <FinInstnId>\n" + | |
" <BICFI>BBBBUS39</BICFI>\n" + | |
" </FinInstnId>\n" + | |
" </CdtrAgt>\n" + | |
" <Cdtr>\n" + | |
" <Pty>\n" + | |
" <Nm>Virgay</Nm>\n" + | |
" <PstlAdr>\n" + | |
" <StrtNm>Virginia Lane</StrtNm>\n" + | |
" <BldgNb>36</BldgNb>\n" + | |
" <PstCd>NJ 07311</PstCd>\n" + | |
" <TwnNm>Jersey City</TwnNm>\n" + | |
" <Ctry>US</Ctry>\n" + | |
" </PstlAdr>\n" + | |
" </Pty>\n" + | |
" </Cdtr>\n" + | |
" <CdtrAcct>\n" + | |
" <Id>\n" + | |
" <IBAN>GR4999999990000000123456789</IBAN>\n" + | |
" </Id>\n" + | |
" </CdtrAcct>\n" + | |
" </OrgnlTxRef>\n" + | |
" </TxInf>\n" + | |
" </FIToFIPmtRvsl>\n" + | |
"</Document>\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment