From e71c580652fe32cf887feeba67f1c75c3c2d7237 Mon Sep 17 00:00:00 2001 From: Torsten Grote Date: Thu, 27 Aug 2020 17:01:13 -0300 Subject: [wallet] fulfillment_url is no longer required in contract terms --- .../taler/wallet/payment/PaymentResponsesTest.kt | 78 ++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 wallet/src/test/java/net/taler/wallet/payment/PaymentResponsesTest.kt (limited to 'wallet/src/test') diff --git a/wallet/src/test/java/net/taler/wallet/payment/PaymentResponsesTest.kt b/wallet/src/test/java/net/taler/wallet/payment/PaymentResponsesTest.kt new file mode 100644 index 0000000..15702c6 --- /dev/null +++ b/wallet/src/test/java/net/taler/wallet/payment/PaymentResponsesTest.kt @@ -0,0 +1,78 @@ +/* + * This file is part of GNU Taler + * (C) 2020 Taler Systems S.A. + * + * GNU Taler is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software + * Foundation; either version 3, or (at your option) any later version. + * + * GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with + * GNU Taler; see the file COPYING. If not, see + */ + +package net.taler.wallet.payment + +import kotlinx.serialization.json.Json +import org.junit.Test + +class PaymentResponsesTest { + + private val json = Json { + ignoreUnknownKeys = true + classDiscriminator = PreparePayResponse.discriminator + } + + @Test + fun testInsufficientBalanceResponse() { + val jsonStr = """ + { + "status": "insufficient-balance", + "contractTerms": { + "summary": "Gummy bears (BFH)", + "amount": "CHF:0.3", + "fulfillment_message": "\/Enjoy+your+", + "auto_refund": { + "d_ms": 300000 + }, + "products": [], + "h_wire": "TAHX3QPREEV64GN5SJRNRJD1EF0ZK50X8Y4BZAGEJSFQ7YVYAW1V3DVTFWVG2RXETPX05ZB9CQSHHXGFX10KRS76JK0XHC60F0YS268", + "wire_method": "x-taler-bank", + "order_id": "2020.240-01MD5F476HMXW", + "timestamp": { + "t_ms": 1598538535000 + }, + "refund_deadline": { + "t_ms": 1598538835000 + }, + "pay_deadline": { + "t_ms": 1598538835000 + }, + "wire_transfer_deadline": { + "t_ms": 1598542135000 + }, + "max_wire_fee": "CHF:0.1", + "max_fee": "CHF:0.1", + "wire_fee_amortization": 10, + "merchant_base_url": "https:\/\/backend.chf.taler.net\/instances\/department\/", + "merchant": { + "name": "BFH Department Technik und Informatik", + "instance": "department" + }, + "exchanges": [], + "auditors": [], + "merchant_pub": "ZMVDPGGAESGYNMZTE4VHDE5QA5BMT7C9A6GR688KGBPMPATF4MKG", + "nonce": "W4WNY6D82H3Y8AV57FBTW4M9YR633N1ARRMBJ6R22MWPYB51JS00" + }, + "proposalId": "BYWTGTHW2TM1FJSM923KD5ZGGFACRYB8EFA461R8AHVK7T9S9ZZG", + "amountRaw": "CHF:0.3" + } + """.trimIndent() + val response = json.decodeFromString(PreparePayResponse.serializer(), jsonStr) + println(response) + } + +} -- cgit v1.2.3