summaryrefslogtreecommitdiff
path: root/wallet/src/test/java/net/taler/wallet/payment/PaymentResponsesTest.kt
blob: fbdc07dbf1a3816287c352c2b8faf201e1380257 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*
 * 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 <http://www.gnu.org/licenses/>
 */

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": {
              "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)
    }

}