summaryrefslogtreecommitdiff
path: root/wallet/src/main/java/net/taler/wallet/refund/TransactionRefundComposable.kt
diff options
context:
space:
mode:
Diffstat (limited to 'wallet/src/main/java/net/taler/wallet/refund/TransactionRefundComposable.kt')
-rw-r--r--wallet/src/main/java/net/taler/wallet/refund/TransactionRefundComposable.kt59
1 files changed, 32 insertions, 27 deletions
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 bb077f1..637b41a 100644
--- a/wallet/src/main/java/net/taler/wallet/refund/TransactionRefundComposable.kt
+++ b/wallet/src/main/java/net/taler/wallet/refund/TransactionRefundComposable.kt
@@ -31,28 +31,32 @@ 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.CurrencySpecification
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.DeleteTransactionComposable
import net.taler.wallet.transactions.ErrorTransactionButton
-import net.taler.wallet.transactions.ExtendedStatus
+import net.taler.wallet.transactions.TransactionAction
+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
+import net.taler.wallet.transactions.TransitionsComposable
@Composable
fun TransactionRefundComposable(
t: TransactionRefund,
devMode: Boolean,
- onFulfill: (url: String) -> Unit,
- onDelete: () -> Unit,
+ spec: CurrencySpecification?,
+ onTransition: (t: TransactionAction) -> Unit,
) {
val scrollState = rememberScrollState()
Column(
@@ -69,23 +73,27 @@ fun TransactionRefundComposable(
)
TransactionAmountComposable(
label = stringResource(id = R.string.transaction_refund),
- amount = t.amountEffective,
+ amount = t.amountEffective.withSpec(spec),
amountType = AmountType.Positive,
)
TransactionAmountComposable(
label = stringResource(id = R.string.transaction_order_total),
- amount = t.amountRaw,
+ amount = t.amountRaw.withSpec(spec),
amountType = AmountType.Neutral,
)
- TransactionAmountComposable(
- label = stringResource(id = R.string.withdraw_fees),
- amount = t.amountRaw - t.amountEffective,
- amountType = AmountType.Negative,
- )
- PurchaseDetails(info = t.info) {
- onFulfill(t.info.fulfillmentUrl ?: "")
+ val fee = t.amountRaw - t.amountEffective
+ if (!fee.isZero()) {
+ TransactionAmountComposable(
+ label = stringResource(id = R.string.withdraw_fees),
+ amount = fee.withSpec(spec),
+ amountType = AmountType.Negative,
+ )
}
- DeleteTransactionComposable(onDelete)
+ 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)
}
@@ -98,21 +106,18 @@ fun TransactionRefundComposablePreview() {
val t = TransactionRefund(
transactionId = "transactionId",
timestamp = Timestamp.fromMillis(System.currentTimeMillis() - 360 * 60 * 1000),
- extendedStatus = ExtendedStatus.Pending,
- info = TransactionInfo(
- orderId = "123",
- merchant = ContractMerchant(name = "Taler"),
+ txState = TransactionState(Pending),
+ txActions = listOf(Retry, Suspend, Abort),
+ 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.fromDouble("TESTKUDOS", 42.23),
- amountEffective = Amount.fromDouble("TESTKUDOS", 42.1337),
+ amountRaw = Amount.fromString("TESTKUDOS", "42.23"),
+ amountEffective = Amount.fromString("TESTKUDOS", "42.1337"),
error = TalerErrorInfo(code = TalerErrorCode.WALLET_WITHDRAWAL_KYC_REQUIRED),
)
TalerSurface {
- TransactionRefundComposable(t = t, devMode = true, onFulfill = {}) {}
+ TransactionRefundComposable(t = t, devMode = true, spec = null) {}
}
}