libeufin

Integration and sandbox testing for FinTech APIs and data formats
Log | Files | Refs | Submodules | README | LICENSE

commit d48d5c51730dc7fe4fd957a8e72e89e378741a71
parent 39e51101a579c434f5ade883b025ca328d19cb0f
Author: MS <ms@taler.net>
Date:   Tue, 19 Jan 2021 00:09:59 +0100

Finding outgoing payments in Camt ONLY based on PmtInfId.

Diffstat:
Mnexus/src/main/kotlin/tech/libeufin/nexus/DB.kt | 4++--
Mnexus/src/main/kotlin/tech/libeufin/nexus/bankaccount/BankAccount.kt | 12+++++-------
Mnexus/src/main/kotlin/tech/libeufin/nexus/ebics/EbicsNexus.kt | 4++--
Mnexus/src/main/kotlin/tech/libeufin/nexus/iso20022/Iso20022.kt | 3---
4 files changed, 9 insertions(+), 14 deletions(-)

diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt @@ -172,7 +172,6 @@ object PaymentInitiationsTable : LongIdTable() { val sum = amount("sum") val currency = varchar("currency", length = 3).default("EUR") val endToEndId = text("endToEndId") - val messageId = text("messageId") val paymentInformationId = text("paymentInformationId") val instructionId = text("instructionId") val subject = text("subject") @@ -180,6 +179,7 @@ object PaymentInitiationsTable : LongIdTable() { val creditorBic = text("creditorBic").nullable() val creditorName = text("creditorName") val submitted = bool("submitted").default(false) + val messageId = text("messageId") /** * Points at the raw transaction witnessing that this @@ -203,8 +203,8 @@ class PaymentInitiationEntity(id: EntityID<Long>) : LongEntity(id) { var creditorName by PaymentInitiationsTable.creditorName var submitted by PaymentInitiationsTable.submitted var paymentInformationId by PaymentInitiationsTable.paymentInformationId - var messageId by PaymentInitiationsTable.messageId var instructionId by PaymentInitiationsTable.instructionId + var messageId by PaymentInitiationsTable.messageId var confirmationTransaction by NexusBankTransactionEntity optionalReferencedOn PaymentInitiationsTable.confirmationTransaction } diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/bankaccount/BankAccount.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/bankaccount/BankAccount.kt @@ -182,17 +182,15 @@ fun processCamtMessage(bankAccountId: String, camtDoc: Document, code: String): // This block tries to acknowledge a former outgoing payment as booked. if (singletonBatchedTransaction.creditDebitIndicator == CreditDebitIndicator.DBIT) { val t0 = singletonBatchedTransaction.details - val msgId = t0.messageId val pmtInfId = t0.paymentInformationId - if (msgId != null && pmtInfId != null) { + if (pmtInfId != null) { val paymentInitiation = PaymentInitiationEntity.find { - (PaymentInitiationsTable.messageId eq msgId) and - (PaymentInitiationsTable.bankAccount eq acct.id) and - (PaymentInitiationsTable.paymentInformationId eq pmtInfId) + PaymentInitiationsTable.bankAccount eq acct.id and ( + PaymentInitiationsTable.paymentInformationId eq pmtInfId) }.firstOrNull() if (paymentInitiation != null) { - logger.info("Could confirm one initiated payment: $msgId") + logger.info("Could confirm one initiated payment: $pmtInfId") paymentInitiation.confirmationTransaction = rawEntity } } @@ -271,8 +269,8 @@ fun addPaymentInitiation(paymentData: Pain001Data, debitorAccount: NexusBankAcco creditorBic = paymentData.creditorBic creditorIban = paymentData.creditorIban preparationDate = now - messageId = "leuf-mp1-$nowHex-$painHex-$acctHex" endToEndId = "leuf-e-$nowHex-$painHex-$acctHex" + messageId = "leuf-mp1-$nowHex-$painHex-$acctHex" paymentInformationId = "leuf-p-$nowHex-$painHex-$acctHex" instructionId = "leuf-i-$nowHex-$painHex-$acctHex" } diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/ebics/EbicsNexus.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/ebics/EbicsNexus.kt @@ -765,12 +765,12 @@ suspend fun submitEbicsPaymentInitiation(httpClient: HttpClient, paymentInitiati creditorIban = paymentInitiation.creditorIban, creditorName = paymentInitiation.creditorName, creditorBic = paymentInitiation.creditorBic, - messageId = paymentInitiation.messageId, paymentInformationId = paymentInitiation.paymentInformationId, preparationTimestamp = paymentInitiation.preparationDate, subject = paymentInitiation.subject, instructionId = paymentInitiation.instructionId, - endToEndId = paymentInitiation.endToEndId + endToEndId = paymentInitiation.endToEndId, + messageId = paymentInitiation.messageId ) ) if (!XMLUtil.validateFromString(painMessage)) throw NexusError( diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/iso20022/Iso20022.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/iso20022/Iso20022.kt @@ -712,9 +712,6 @@ private fun XmlElementDestructor.extractTransactionDetails( endToEndId = maybeUniqueChildNamed("Refs") { maybeUniqueChildNamed("EndToEndId") { focusElement.textContent } }, - messageId = maybeUniqueChildNamed("Refs") { - maybeUniqueChildNamed("MsgId") { focusElement.textContent } - }, paymentInformationId = maybeUniqueChildNamed("Refs") { maybeUniqueChildNamed("PmtInfId") { focusElement.textContent } },