libeufin

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

commit 113a5265519b5c2c8873cd1f86fef7c751780fb1
parent 06cba3669ba42feecc655b31e799e6a654b8f638
Author: MS <ms@taler.net>
Date:   Mon, 18 May 2020 11:19:34 +0200

Untie Ebics from the payments' book.

Diffstat:
Msandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt | 3---
Msandbox/src/main/kotlin/tech/libeufin/sandbox/EbicsProtocolBackend.kt | 12++++++------
Msandbox/src/main/kotlin/tech/libeufin/sandbox/Helpers.kt | 1-
Msandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt | 12++++++++++++
Mutil/src/main/kotlin/JSON.kt | 2+-
5 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt b/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt @@ -233,7 +233,6 @@ object PaymentsTable : IntIdTable() { val subject = text("subject") val amount = text("amount") val date = long("date") - val ebicsSubscriber = reference("ebicsSubscriber", EbicsSubscribersTable) } class PaymentEntity(id: EntityID<Int>) : IntEntity(id) { companion object : IntEntityClass<PaymentEntity>(PaymentsTable) @@ -242,8 +241,6 @@ class PaymentEntity(id: EntityID<Int>) : IntEntity(id) { var subject by PaymentsTable.subject var amount by PaymentsTable.amount var date by PaymentsTable.date /** Date when the payment was persisted in this system. */ - /* Subscirber involved in the payment */ - var ebicsSubscriber by EbicsSubscriberEntity referencedOn PaymentsTable.ebicsSubscriber } /** diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/EbicsProtocolBackend.kt b/sandbox/src/main/kotlin/tech/libeufin/sandbox/EbicsProtocolBackend.kt @@ -413,9 +413,12 @@ private fun constructCamtResponse( Pair(DateTime(dateRange.start.toGregorianCalendar().time), DateTime(dateRange.end.toGregorianCalendar().time)) } else Pair(DateTime(0), DateTime.now()) val history = mutableListOf<RawPayment>() + val bankAccount = getBankAccountFromSubscriber(subscriber) transaction { PaymentEntity.find { - PaymentsTable.ebicsSubscriber eq subscriber.id.value + PaymentsTable.creditorIban eq bankAccount.iban or + (PaymentsTable.debitorIban eq bankAccount.iban) and + (PaymentsTable.date.between(start.millis, end.millis)) }.forEach { history.add( RawPayment( @@ -443,7 +446,7 @@ private fun handleEbicsPTK(requestContext: RequestContext): ByteArray { /** * Process a payment request in the pain.001 format. */ -private fun handleCct(paymentRequest: String, ebicsSubscriber: EbicsSubscriberEntity) { +private fun handleCct(paymentRequest: String) { /** * NOTE: this function is ONLY required to store some details * to put then in the camt report. IBANs / amount / subject / names? @@ -460,7 +463,6 @@ private fun handleCct(paymentRequest: String, ebicsSubscriber: EbicsSubscriberEn this.debitorIban = debitorIban this.subject = subject this.amount = amount - this.ebicsSubscriber = ebicsSubscriber this.date = DateTime.now().millis } } @@ -701,7 +703,6 @@ private fun makePartnerInfo(subscriber: EbicsSubscriberEntity): EbicsTypes.Partn } private fun handleEbicsHtd(requestContext: RequestContext): ByteArray { - val bankAccount = getBankAccountFromSubscriber(requestContext.subscriber) val htd = HTDResponseOrderData().apply { this.partnerInfo = makePartnerInfo(requestContext.subscriber) this.userInfo = EbicsTypes.UserInfo().apply { @@ -717,7 +718,6 @@ private fun handleEbicsHtd(requestContext: RequestContext): ByteArray { ) } } - val str = XMLUtil.convertJaxbToString(htd) return str.toByteArray() } @@ -901,7 +901,7 @@ private fun handleEbicsUploadTransactionTransmission(requestContext: RequestCont if (getOrderTypeFromTransactionId(requestTransactionID) == "CCT") { logger.debug("Attempting a payment.") - handleCct(unzippedData.toString(Charsets.UTF_8), requestContext.subscriber) + handleCct(unzippedData.toString(Charsets.UTF_8)) } return EbicsResponse.createForUploadTransferPhase( requestTransactionID, diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Helpers.kt b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Helpers.kt @@ -5,7 +5,6 @@ import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq import org.jetbrains.exposed.sql.and import org.jetbrains.exposed.sql.transactions.transaction - fun getOrderTypeFromTransactionId(transactionID: String): String { val uploadTransaction = transaction { EbicsUploadTransactionEntity.findById(transactionID) diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt @@ -47,6 +47,7 @@ import org.slf4j.event.Level import org.w3c.dom.Document import tech.libeufin.util.Amount import tech.libeufin.util.CryptoUtil +import tech.libeufin.util.RawPayment import java.lang.ArithmeticException import java.math.BigDecimal import java.security.interfaces.RSAPublicKey @@ -146,6 +147,17 @@ fun main() { call.respondText("Hello Sandbox!\n", ContentType.Text.Plain) } /** + * Adds a new payment to the book. + */ + post("/admin/payments") { + val body = call.receive<RawPayment>() + transaction { + + } + call.respondText("Payment created") + return@post + } + /** * Associates a new bank account with an existing Ebics subscriber. */ post("/admin/ebics/bank-accounts") { diff --git a/util/src/main/kotlin/JSON.kt b/util/src/main/kotlin/JSON.kt @@ -10,5 +10,5 @@ data class RawPayment( val debitorIban: String, val amount: String, val subject: String, - val date: String + val date: String? ) \ No newline at end of file