libeufin

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

commit 9eebaf45dea4c460bc4ec2c94b3252f76a6df5e7
parent eccde3743ec7232a88a306a29be7820f940d0e72
Author: ms <ms@taler.net>
Date:   Mon, 31 Jan 2022 08:35:04 +0100

take amount from payto

Diffstat:
Msandbox/src/main/kotlin/tech/libeufin/sandbox/JSON.kt | 2+-
Msandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt | 5+++--
2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/JSON.kt b/sandbox/src/main/kotlin/tech/libeufin/sandbox/JSON.kt @@ -134,5 +134,5 @@ data class NewTransactionReq( */ val paytoUri: String, // $currency:X.Y format - val amount: String + val amount: String? ) \ No newline at end of file diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt @@ -1097,7 +1097,8 @@ val sandboxApp: Application.() -> Unit = { val bankAccount = getBankAccountWithAuth(call) val req = call.receive<NewTransactionReq>() val payto = parsePayto(req.paytoUri) - val amount = parseAmount(req.amount) + val amount: String? = payto.amount ?: req.amount + if (amount == null) throw badRequest("Amount is missing") /** * Need a transaction block only to let the * 'demoBank' field of 'bankAccount' accessed. @@ -1114,7 +1115,7 @@ val sandboxApp: Application.() -> Unit = { subject = payto.message ?: throw badRequest( "'message' query parameter missing in Payto address" ), - amount = amount.amount.toPlainString() + amount = parseAmount(amount).amount.toPlainString() ) } call.respond(object {})