taler-android

Android apps for GNU Taler (wallet, PoS, cashier)
Log | Files | Refs | README | LICENSE

Orders.kt (3014B)


      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.merchantlib
     18 
     19 import kotlinx.serialization.ExperimentalSerializationApi
     20 import kotlinx.serialization.SerialName
     21 import kotlinx.serialization.Serializable
     22 import kotlinx.serialization.json.JsonClassDiscriminator
     23 import net.taler.common.Amount
     24 import net.taler.common.ContractTerms
     25 import net.taler.common.RelativeTime
     26 
     27 @Serializable
     28 data class PostOrderRequest(
     29     @SerialName("order")
     30     val contractTerms: net.taler.common.Order,
     31     @SerialName("refund_delay")
     32     val refundDelay: RelativeTime? = null,
     33     @SerialName("payment_target")
     34     val paymentTarget: String? = null,
     35     @SerialName("session_id")
     36     val sessionId: String? = null,
     37     @SerialName("inventory_products")
     38     val inventoryProducts: List<MinimalInventoryProduct>? = null,
     39     @SerialName("lock_uuids")
     40     val lockUuids: List<String>? = null,
     41     @SerialName("create_token")
     42     val createToken: Boolean = true,
     43     @SerialName("otp_id")
     44     val otpId: String? = null,
     45 )
     46 
     47 @Serializable
     48 data class MinimalInventoryProduct(
     49     @SerialName("product_id")
     50     val productId: String,
     51     val quantity: Int? = null,
     52     @SerialName("unit_quantity")
     53     val unitQuantity: String? = null,
     54     @SerialName("product_money_pot")
     55     val productMoneyPot: Int? = null,
     56 )
     57 
     58 @Serializable
     59 data class PostOrderResponse(
     60     @SerialName("order_id")
     61     val orderId: String
     62 )
     63 
     64 @OptIn(ExperimentalSerializationApi::class)
     65 @Serializable
     66 @JsonClassDiscriminator("order_status")
     67 sealed class CheckPaymentResponse {
     68     abstract val paid: Boolean
     69 
     70     @Serializable
     71     @SerialName("unpaid")
     72     data class Unpaid(
     73         override val paid: Boolean = false,
     74         @SerialName("taler_pay_uri")
     75         val talerPayUri: String,
     76         @SerialName("already_paid_order_id")
     77         val alreadyPaidOrderId: String? = null
     78     ) : CheckPaymentResponse()
     79 
     80     @Serializable
     81     @SerialName("claimed")
     82     data class Claimed(
     83         override val paid: Boolean = false,
     84     ) : CheckPaymentResponse()
     85 
     86     @Serializable
     87     @SerialName("paid")
     88     data class Paid(
     89         override val paid: Boolean = true,
     90         val refunded: Boolean,
     91         @SerialName("refund_pending")
     92         val refundPending: Boolean = false,
     93         @SerialName("refund_amount")
     94         val refundAmount: Amount? = null,
     95     ) : CheckPaymentResponse()
     96 
     97 }