diff options
4 files changed, 54 insertions, 25 deletions
diff --git a/wallet/src/main/java/net/taler/wallet/refund/RefundPaymentInfo.kt b/wallet/src/main/java/net/taler/wallet/refund/RefundPaymentInfo.kt new file mode 100644 index 0000000..d5f59be --- /dev/null +++ b/wallet/src/main/java/net/taler/wallet/refund/RefundPaymentInfo.kt @@ -0,0 +1,39 @@ +/* + * This file is part of GNU Taler + * (C) 2023 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.refund + +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +class RefundPaymentInfo( + val summary: String, + @SerialName("summary_i18n") + val summaryI18n: Map<String, String>? = null, + /** + * More information about the merchant + */ + val merchant: MerchantInfo, +) + +@Serializable +class MerchantInfo( + val name: String, + val logo: String? = null, + val website: String? = null, + val email: String? = null, +) diff --git a/wallet/src/main/java/net/taler/wallet/refund/TransactionRefundComposable.kt b/wallet/src/main/java/net/taler/wallet/refund/TransactionRefundComposable.kt index 9dc6267..ac5e2da 100644 --- a/wallet/src/main/java/net/taler/wallet/refund/TransactionRefundComposable.kt +++ b/wallet/src/main/java/net/taler/wallet/refund/TransactionRefundComposable.kt @@ -31,14 +31,12 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import net.taler.common.Amount -import net.taler.common.ContractMerchant import net.taler.common.Timestamp import net.taler.common.toAbsoluteTime import net.taler.wallet.R import net.taler.wallet.backend.TalerErrorCode import net.taler.wallet.backend.TalerErrorInfo import net.taler.wallet.compose.TalerSurface -import net.taler.wallet.payment.PurchaseDetails import net.taler.wallet.transactions.AmountType import net.taler.wallet.transactions.ErrorTransactionButton import net.taler.wallet.transactions.TransactionAction @@ -46,7 +44,7 @@ import net.taler.wallet.transactions.TransactionAction.Abort import net.taler.wallet.transactions.TransactionAction.Retry import net.taler.wallet.transactions.TransactionAction.Suspend import net.taler.wallet.transactions.TransactionAmountComposable -import net.taler.wallet.transactions.TransactionInfo +import net.taler.wallet.transactions.TransactionInfoComposable import net.taler.wallet.transactions.TransactionMajorState.Pending import net.taler.wallet.transactions.TransactionRefund import net.taler.wallet.transactions.TransactionState @@ -56,7 +54,6 @@ import net.taler.wallet.transactions.TransitionsComposable fun TransactionRefundComposable( t: TransactionRefund, devMode: Boolean, - onFulfill: (url: String) -> Unit, onTransition: (t: TransactionAction) -> Unit, ) { val scrollState = rememberScrollState() @@ -87,9 +84,10 @@ fun TransactionRefundComposable( amount = t.amountRaw - t.amountEffective, amountType = AmountType.Negative, ) - PurchaseDetails(info = t.info) { - onFulfill(t.info.fulfillmentUrl ?: "") - } + TransactionInfoComposable( + label = stringResource(id = R.string.transaction_order), + info = t.paymentInfo?.summary ?: "", + ) TransitionsComposable(t, devMode, onTransition) if (devMode && t.error != null) { ErrorTransactionButton(error = t.error) @@ -105,13 +103,9 @@ fun TransactionRefundComposablePreview() { timestamp = Timestamp.fromMillis(System.currentTimeMillis() - 360 * 60 * 1000), txState = TransactionState(Pending), txActions = listOf(Retry, Suspend, Abort), - info = TransactionInfo( - orderId = "123", - merchant = ContractMerchant(name = "Taler"), + paymentInfo = RefundPaymentInfo( + merchant = MerchantInfo(name = "Taler"), summary = "Some Product that was bought and can have quite a long label", - fulfillmentMessage = "This is some fulfillment message", - fulfillmentUrl = "https://bank.demo.taler.net/", - products = listOf(), ), refundedTransactionId = "transactionId", amountRaw = Amount.fromString("TESTKUDOS", "42.23"), @@ -119,6 +113,6 @@ fun TransactionRefundComposablePreview() { error = TalerErrorInfo(code = TalerErrorCode.WALLET_WITHDRAWAL_KYC_REQUIRED), ) TalerSurface { - TransactionRefundComposable(t = t, devMode = true, onFulfill = {}) {} + TransactionRefundComposable(t = t, devMode = true) {} } } diff --git a/wallet/src/main/java/net/taler/wallet/transactions/TransactionRefundFragment.kt b/wallet/src/main/java/net/taler/wallet/transactions/TransactionRefundFragment.kt index 306febc..cd50be7 100644 --- a/wallet/src/main/java/net/taler/wallet/transactions/TransactionRefundFragment.kt +++ b/wallet/src/main/java/net/taler/wallet/transactions/TransactionRefundFragment.kt @@ -23,7 +23,6 @@ import android.view.ViewGroup import androidx.compose.runtime.livedata.observeAsState import androidx.compose.ui.platform.ComposeView import net.taler.wallet.compose.TalerSurface -import net.taler.wallet.launchInAppBrowser import net.taler.wallet.refund.TransactionRefundComposable class TransactionRefundFragment : TransactionDetailFragment() { @@ -36,14 +35,9 @@ class TransactionRefundFragment : TransactionDetailFragment() { setContent { TalerSurface { val t = transactionManager.selectedTransaction.observeAsState().value - if (t is TransactionRefund) TransactionRefundComposable(t, devMode, - onFulfill = { url -> - launchInAppBrowser(requireContext(), url) - }, - onTransition = { - onTransitionButtonClicked(t, it) - } - ) + if (t is TransactionRefund) TransactionRefundComposable(t, devMode) { + onTransitionButtonClicked(t, it) + } } } } diff --git a/wallet/src/main/java/net/taler/wallet/transactions/Transactions.kt b/wallet/src/main/java/net/taler/wallet/transactions/Transactions.kt index b6b3587..c6be73a 100644 --- a/wallet/src/main/java/net/taler/wallet/transactions/Transactions.kt +++ b/wallet/src/main/java/net/taler/wallet/transactions/Transactions.kt @@ -42,6 +42,7 @@ import net.taler.wallet.TAG import net.taler.wallet.backend.TalerErrorCode import net.taler.wallet.backend.TalerErrorInfo import net.taler.wallet.cleanExchange +import net.taler.wallet.refund.RefundPaymentInfo import net.taler.wallet.transactions.TransactionMajorState.None import net.taler.wallet.transactions.TransactionMajorState.Pending import net.taler.wallet.transactions.WithdrawalDetails.ManualTransfer @@ -254,7 +255,7 @@ class TransactionRefund( override val txState: TransactionState, override val txActions: List<TransactionAction>, val refundedTransactionId: String, - val info: TransactionInfo, + val paymentInfo: RefundPaymentInfo? = null, override val error: TalerErrorInfo? = null, override val amountRaw: Amount, override val amountEffective: Amount, @@ -265,7 +266,8 @@ class TransactionRefund( @Transient override val amountType = AmountType.Positive override fun getTitle(context: Context): String { - return context.getString(R.string.transaction_refund_from, info.merchant.name) + val merchantName = paymentInfo?.merchant?.name ?: "null" + return context.getString(R.string.transaction_refund_from, merchantName) } override val generalTitleRes = R.string.refund_title |