PaymentResponsesTest.kt (3304B)
1 /* 2 * This file is part of GNU Taler 3 * (C) 2020 Taler Systems S.A. 4 * 5 * GNU Taler is free software; you can redistribute it and/or modify it under the 6 * terms of the GNU General Public License as published by the Free Software 7 * Foundation; either version 3, or (at your option) any later version. 8 * 9 * GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY 10 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 11 * A PARTICULAR PURPOSE. See the GNU General Public License for more details. 12 * 13 * You should have received a copy of the GNU General Public License along with 14 * GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> 15 */ 16 17 package net.taler.wallet.payment 18 19 import kotlinx.serialization.json.Json 20 import org.junit.Test 21 22 class PaymentResponsesTest { 23 24 private val json = Json { 25 ignoreUnknownKeys = true 26 } 27 28 @Test 29 fun testInsufficientBalanceResponse() { 30 val jsonStr = """ 31 { 32 "status": "insufficient-balance", 33 "transactionId": "txn:payment:ZVY9B3R99W5EGGTJJMK4JYVS726BS57T4MM6HS2DPE475NGDRDRG", 34 "contractTerms": { 35 "summary": "Gummy bears (BFH)", 36 "amount": "CHF:0.3", 37 "fulfillment_message": "\/Enjoy+your+", 38 "auto_refund": { 39 "d_ms": 300000 40 }, 41 "products": [], 42 "h_wire": "TAHX3QPREEV64GN5SJRNRJD1EF0ZK50X8Y4BZAGEJSFQ7YVYAW1V3DVTFWVG2RXETPX05ZB9CQSHHXGFX10KRS76JK0XHC60F0YS268", 43 "wire_method": "x-taler-bank", 44 "order_id": "2020.240-01MD5F476HMXW", 45 "timestamp": { 46 "t_s": 1598538535 47 }, 48 "refund_deadline": { 49 "t_s": 1598538835 50 }, 51 "pay_deadline": { 52 "t_s": 1598538835 53 }, 54 "wire_transfer_deadline": { 55 "t_s": 1598542135 56 }, 57 "max_wire_fee": "CHF:0.1", 58 "max_fee": "CHF:0.1", 59 "wire_fee_amortization": 10, 60 "merchant": { 61 "name": "BFH Department Technik und Informatik", 62 "instance": "department" 63 }, 64 "merchant_base_url": "https://backend.bfh.taler.net/", 65 "exchanges": [], 66 "auditors": [], 67 "merchant_pub": "ZMVDPGGAESGYNMZTE4VHDE5QA5BMT7C9A6GR688KGBPMPATF4MKG", 68 "nonce": "W4WNY6D82H3Y8AV57FBTW4M9YR633N1ARRMBJ6R22MWPYB51JS00" 69 }, 70 "proposalId": "BYWTGTHW2TM1FJSM923KD5ZGGFACRYB8EFA461R8AHVK7T9S9ZZG", 71 "amountRaw": "CHF:0.3", 72 "balanceDetails": { 73 "amountRequested": "CHF:0.3", 74 "wireMethod": "iban", 75 "causeHint": "merchant-deposit-insufficient", 76 "balanceAvailable": "CHF:0.3", 77 "balanceMaterial": "CHF:0.3", 78 "balanceAgeAcceptable": "CHF:0.3", 79 "balanceReceiverAcceptable": "CHF:0.3", 80 "balanceReceiverDepositable": "CHF:0.2", 81 "balanceExchangeDepositable": "CHF:0.2", 82 "maxEffectiveSpendAmount": "CHF:0.3", 83 "perExchange": {} 84 } 85 } 86 """.trimIndent() 87 val response = json.decodeFromString(PreparePayResponse.serializer(), jsonStr) 88 println(response) 89 } 90 91 }