taler-android

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

Order.kt (3288B)


      1 /*
      2  * This file is part of GNU Taler
      3  * (C) 2025 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.common
     18 
     19 import kotlinx.serialization.SerialName
     20 import kotlinx.serialization.Serializable
     21 import net.taler.common.TalerUtils.getLocalizedString
     22 
     23 // TODO: order v1 support
     24 
     25 @Serializable
     26 data class Order(
     27     val summary: String,
     28     @SerialName("summary_i18n")
     29     val summaryI18n: Map<String, String>? = null,
     30     val amount: Amount,
     31     @SerialName("fulfillment_url")
     32     val fulfillmentUrl: String? = null,
     33     @SerialName("fulfillment_message")
     34     val fulfillmentMessage: String? = null,
     35     @SerialName("fulfillment_message_i18n")
     36     val fulfillmentMessageI18n: Map <String, String>? = null,
     37     val products: List<ContractProduct>? = null,
     38     @SerialName("wire_transfer_deadline")
     39     val wireTransferDeadline: Timestamp? = null,
     40     @SerialName("refund_deadline")
     41     val refundDeadline: Timestamp? = null,
     42     @SerialName("pay_deadline")
     43     val payDeadline: Timestamp? = null,
     44     /**
     45      * Identifier chosen by the client. Creating an order twice with the same id cannot
     46      * produce two orders, which makes creation safe to retry after a crash.
     47      */
     48     @SerialName("order_id")
     49     val orderId: String? = null,
     50     /**
     51      * Parts of the order already settled outside Taler, such as cash or card (DD 96).
     52      * [amount] then covers only what the wallet still pays. Fixed at creation.
     53      */
     54     @SerialName("amount_external")
     55     val amountExternal: List<ExternalPayment>? = null,
     56 )
     57 
     58 /**
     59  * One payment taken outside Taler before the wallet pays the rest (DD 96).
     60  *
     61  * Entries are flat by design: [method] names the channel and is never "taler", [id] is
     62  * unique within the order, and anything else is a method specific string.
     63  */
     64 @Serializable
     65 data class ExternalPayment(
     66     /** External payment method, such as cash or card; never Taler. */
     67     val method: String,
     68     /** Payment reference unique within the order. */
     69     val id: String,
     70     /** Amount already settled through this method. */
     71     val amount: Amount,
     72     /** Reference the external system assigned, such as a card transaction code. */
     73     @SerialName("transaction_code")
     74     val transactionCode: String? = null,
     75 )
     76 
     77 @Serializable
     78 abstract class OrderProduct {
     79     abstract val productId: String?
     80     abstract val productName: String?
     81     abstract val description: String
     82     abstract val descriptionI18n: Map<String, String>?
     83     abstract val price: Amount?
     84     abstract val location: String?
     85     abstract val image: String?
     86     abstract val taxes: Set<Tax>?
     87     val localizedDescription: String
     88         get() = getLocalizedString(descriptionI18n, description)
     89 }