diff options
author | Marcello Stanisci <ms@taler.net> | 2020-04-30 17:32:33 +0200 |
---|---|---|
committer | Marcello Stanisci <ms@taler.net> | 2020-04-30 17:32:33 +0200 |
commit | d5ea867db958b7962c32d5713fb8190f8bca3094 (patch) | |
tree | 3e4b4ea5e63e55577554d27df78e3aa9a67c9997 | |
parent | d9547e525b226c9fa51c4ff9c8ca331077f36bbb (diff) | |
download | libeufin-d5ea867db958b7962c32d5713fb8190f8bca3094.tar.gz libeufin-d5ea867db958b7962c32d5713fb8190f8bca3094.tar.bz2 libeufin-d5ea867db958b7962c32d5713fb8190f8bca3094.zip |
Fix CCT handling.
5 files changed, 25 insertions, 10 deletions
diff --git a/integration-tests/test-ebics.py b/integration-tests/test-ebics.py index b8f2cd00..78187d7d 100755 --- a/integration-tests/test-ebics.py +++ b/integration-tests/test-ebics.py @@ -163,5 +163,8 @@ resp = post( ) assert(resp.status_code == 200) -#7 Execute such payment via EBICS -#8 Request history again via EBICS +#5.b +resp = post("http://localhost:5001/ebics/execute-payments") +assert(resp.status_code == 200) + +#6 diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt index 9344ed09..61ae1cc5 100644 --- a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt +++ b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt @@ -567,7 +567,7 @@ fun main() { /** STATE CHANGES VIA EBICS */ - post("/ebics/admin/execute-payments") { + post("/ebics/execute-payments") { val (paymentRowId, painDoc, subscriber) = transaction { val entity = Pain001Entity.find { (Pain001Table.submitted eq false) and (Pain001Table.invalid eq false) diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt b/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt index a53280fd..dff869c5 100644 --- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt +++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt @@ -241,7 +241,7 @@ class PaymentEntity(id: EntityID<Int>) : IntEntity(id) { var debitorIban by PaymentsTable.debitorIban var subject by PaymentsTable.subject var amount by PaymentsTable.amount - var date by PaymentsTable.date + var date by PaymentsTable.date /** Date when the payment was persisted in this system. */ 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 index 61d70b01..7123e9b7 100644 --- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/EbicsProtocolBackend.kt +++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/EbicsProtocolBackend.kt @@ -461,6 +461,7 @@ private fun handleCct(paymentRequest: String, ebicsSubscriber: EbicsSubscriberEn this.subject = subject this.amount = "${currency}:${amount}" this.ebicsSubscriber = ebicsSubscriber + this.date = DateTime.now().millis } } } @@ -832,7 +833,6 @@ private fun handleEbicsUploadTransactionInitialization(requestContext: RequestCo val plainSigData = InflaterInputStream(decryptedSignatureData.inputStream()).use { it.readAllBytes() } - println("creating upload transaction for transactionID $transactionID") EbicsUploadTransactionEntity.new(transactionID) { this.host = requestContext.ebicsHost @@ -856,7 +856,6 @@ private fun handleEbicsUploadTransactionInitialization(requestContext: RequestCo this.signatureValue = SerialBlob(sig.signatureValue) } } - return EbicsResponse.createForUploadInitializationPhase(transactionID, orderID) } @@ -882,11 +881,9 @@ private fun handleEbicsUploadTransactionTransmission(requestContext: RequestCont (EbicsOrderSignaturesTable.orderID eq uploadTransaction.orderID) and (EbicsOrderSignaturesTable.orderType eq uploadTransaction.orderType) } - if (sigs.count() == 0) { throw EbicsInvalidRequestError() } - for (sig in sigs) { if (sig.signatureAlgorithm == "A006") { @@ -902,8 +899,8 @@ private fun handleEbicsUploadTransactionTransmission(requestContext: RequestCont } } - /** Handling a payment request */ - if ("CCT" == requestContext.requestObject.header.static.orderDetails?.orderType) { + if (getOrderTypeFromTransactionId(requestTransactionID) == "CCT") { + logger.debug("Attempting a payment.") handleCct(unzippedData.toString(Charsets.UTF_8), requestContext.subscriber) } return EbicsResponse.createForUploadTransferPhase( diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Helpers.kt b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Helpers.kt index 5e7afa5b..5338b898 100644 --- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Helpers.kt +++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Helpers.kt @@ -5,6 +5,21 @@ 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) + } ?: throw SandboxError( + /** + * NOTE: at this point, it might even be the server's fault. + * For example, if it failed to store a ID earlier. + */ + HttpStatusCode.NotFound, + "Could not retrieve order type for transaction: $transactionID" + ) + return uploadTransaction.orderType +} + fun getBankAccountFromSubscriber(subscriber: EbicsSubscriberEntity): BankAccountEntity { return transaction { BankAccountEntity.find(BankAccountsTable.subscriber eq subscriber.id) |