use of net.petafuel.jsepa.model.CreditTransferTransactionInformation in project styx by petafuel.
the class PaymentXMLSerializer method serialize.
public PAIN00100303Document serialize(String messageId, SinglePayment payment) {
// Necessary variables for creating a PAIN00100303Document
Date creationTime = new Date();
double controlSum = 0d;
String paymentMethod = "TRF";
String debtorName = payment.getDebtorAccount().getName();
String chargeBearer = "SLEV";
// Setting values for each instance
groupHeader.setMessageId(messageId.substring(0, Math.min(messageId.length(), 35)));
groupHeader.setCreationTime(creationTimeFormat.format(creationTime));
groupHeader.setNoOfTransactions(1);
groupHeader.setInitiatingPartyName(debtorName);
ArrayList<CreditTransferTransactionInformation> list = new ArrayList<>();
CreditTransferTransactionInformation cdtTrfTxInf = new CreditTransferTransactionInformation();
controlSum += Double.parseDouble(payment.getInstructedAmount().getAmount());
cdtTrfTxInf.setEndToEndID(payment.getEndToEndIdentification() != null ? payment.getEndToEndIdentification() : UUID.randomUUID().toString());
cdtTrfTxInf.setAmount(Double.parseDouble(payment.getInstructedAmount().getAmount()));
cdtTrfTxInf.setCreditorName(payment.getCreditorName());
cdtTrfTxInf.setCreditorIBAN(payment.getCreditorAccount().getIban());
cdtTrfTxInf.setVwz(payment.getRemittanceInformationUnstructured());
list.add(cdtTrfTxInf);
groupHeader.setControlSum(controlSum);
pii.setPmtInfId(NOT_PROVIDED);
pii.setPaymentMethod(paymentMethod);
pii.setNoTxns(1);
pii.setCtrlSum(controlSum);
pii.setDebtorName(debtorName);
pii.setDebtorAccountIBAN(payment.getDebtorAccount().getIban());
pii.setChargeBearer(chargeBearer);
pii.setCreditTransferTransactionInformationVector(list);
if (payment.getRequestedExecutionDate() == null) {
pii.setRequestedExecutionDate(requestedExecutionDateFormat.format(creationTime));
} else {
pii.setRequestedExecutionDate(requestedExecutionDateFormat.format(payment.getRequestedExecutionDate()));
}
pmtInfos.add(pii);
ccInitation.setGrpHeader(groupHeader);
ccInitation.setPmtInfos(pmtInfos);
document.setCctInitiation(ccInitation);
return document;
}
use of net.petafuel.jsepa.model.CreditTransferTransactionInformation in project styx by petafuel.
the class PaymentXMLSerializer method serialize.
public PAIN00100303Document serialize(String messageId, BulkPayment bulkPayment) {
// Necessary variables for creating a PAIN00100303Document
Date creationTime = new Date();
double controlSum = 0d;
String paymentMethod = "TRF";
String chargeBearer = "SLEV";
// Setting values for each instance
groupHeader.setMessageId(messageId.substring(0, Math.min(messageId.length(), 35)));
groupHeader.setCreationTime(creationTimeFormat.format(creationTime));
groupHeader.setNoOfTransactions(bulkPayment.getPayments().size());
groupHeader.setInitiatingPartyName(NOT_PROVIDED);
ArrayList<CreditTransferTransactionInformation> list = new ArrayList<>();
for (SinglePayment payment : bulkPayment.getPayments()) {
CreditTransferTransactionInformation cdtTrfTxInf = new CreditTransferTransactionInformation();
controlSum += Double.parseDouble(payment.getInstructedAmount().getAmount());
cdtTrfTxInf.setEndToEndID(payment.getEndToEndIdentification() != null ? payment.getEndToEndIdentification() : UUID.randomUUID().toString());
cdtTrfTxInf.setAmount(Double.parseDouble(payment.getInstructedAmount().getAmount()));
cdtTrfTxInf.setCreditorName(payment.getCreditorName());
cdtTrfTxInf.setCreditorIBAN(payment.getCreditorAccount().getIban());
cdtTrfTxInf.setVwz(payment.getRemittanceInformationUnstructured());
cdtTrfTxInf.setCreditorAgent(payment.getCreditorName());
list.add(cdtTrfTxInf);
}
groupHeader.setControlSum(controlSum);
pii.setPmtInfId(NOT_PROVIDED);
pii.setPaymentMethod(paymentMethod);
pii.setNoTxns(bulkPayment.getPayments().size());
pii.setCtrlSum(controlSum);
pii.setDebtorName(NOT_PROVIDED);
pii.setDebtorAccountIBAN(bulkPayment.getDebtorAccount().getIban());
pii.setChargeBearer(chargeBearer);
pii.setBatchBooking(bulkPayment.getBatchBookingPreferred());
pii.setCreditTransferTransactionInformationVector(list);
if (bulkPayment.getRequestedExecutionDate() == null) {
pii.setRequestedExecutionDate(requestedExecutionDateFormat.format(creationTime));
} else {
pii.setRequestedExecutionDate(requestedExecutionDateFormat.format(bulkPayment.getRequestedExecutionDate()));
}
pmtInfos.add(pii);
ccInitation.setGrpHeader(groupHeader);
ccInitation.setPmtInfos(pmtInfos);
document.setCctInitiation(ccInitation);
return document;
}
use of net.petafuel.jsepa.model.CreditTransferTransactionInformation in project styx by petafuel.
the class PaymentSerializer method xmlDeserialize.
public static InitializablePayment xmlDeserialize(Document sepaDocument, PaymentService paymentService) throws ParseException {
ArrayList<SinglePayment> payments = new ArrayList<>();
AccountReference debtorAccount = new AccountReference();
debtorAccount.setName(sepaDocument.getCctInitiation().getPmtInfos().get(0).getDebtorName());
debtorAccount.setIban(sepaDocument.getCctInitiation().getPmtInfos().get(0).getDebtorAccountIBAN());
debtorAccount.setCurrency(Currency.EUR);
Date requestedExecutionDate = new SimpleDateFormat(XS2AJsonKeys.DATE_FORMAT.value()).parse(sepaDocument.getCctInitiation().getPmtInfos().get(0).getRequestedExecutionDate());
for (CreditTransferTransactionInformation ctti : sepaDocument.getCctInitiation().getPmtInfos().get(0).getCreditTransferTransactionInformationVector()) {
String creditorAccountName = ctti.getCreditorName();
String creditorAccountIdentifier = ctti.getCreditorIBAN();
AccountReference creditorAccount = new AccountReference(creditorAccountIdentifier, AccountReference.Type.IBAN);
creditorAccount.setName(creditorAccountName);
creditorAccount.setCurrency(Currency.EUR);
String amount = Double.toString(ctti.getAmount());
String remittanceInformationUnstructured = ctti.getVwz();
String endToEndIdentification = ctti.getEndToEndID();
SinglePayment payment = new SinglePayment();
payment.setInstructedAmount(new Amount(amount, Currency.EUR));
payment.setCreditorAccount(creditorAccount);
payment.setDebtorAccount(debtorAccount);
payment.setRemittanceInformationUnstructured(remittanceInformationUnstructured);
payment.setEndToEndIdentification(endToEndIdentification);
payment.setRequestedExecutionDate(requestedExecutionDate);
payments.add(payment);
}
if (paymentService.equals(PaymentService.BULK_PAYMENTS)) {
BulkPayment bulkPayment = new BulkPayment();
bulkPayment.setPayments(payments);
bulkPayment.setDebtorAccount(debtorAccount);
bulkPayment.setRequestedExecutionDate(requestedExecutionDate);
return bulkPayment;
}
return payments.get(0);
}
Aggregations