diff options
Diffstat (limited to 'wallet/src')
4 files changed, 22 insertions, 9 deletions
diff --git a/wallet/src/main/java/net/taler/wallet/payment/PaymentManager.kt b/wallet/src/main/java/net/taler/wallet/payment/PaymentManager.kt index c6351ee..2427afb 100644 --- a/wallet/src/main/java/net/taler/wallet/payment/PaymentManager.kt +++ b/wallet/src/main/java/net/taler/wallet/payment/PaymentManager.kt @@ -26,6 +26,8 @@ import net.taler.common.Amount import net.taler.common.ContractTerms import net.taler.wallet.TAG import net.taler.wallet.backend.WalletBackendApi +import net.taler.wallet.payment.PayStatus.AlreadyPaid +import net.taler.wallet.payment.PayStatus.InsufficientBalance import net.taler.wallet.payment.PreparePayResponse.AlreadyConfirmedResponse import net.taler.wallet.payment.PreparePayResponse.InsufficientBalanceResponse import net.taler.wallet.payment.PreparePayResponse.PaymentPossibleResponse @@ -40,7 +42,8 @@ sealed class PayStatus { data class Prepared( val contractTerms: ContractTerms, val proposalId: String, - val totalFees: Amount + val amountRaw: Amount, + val amountEffective: Amount ) : PayStatus() data class InsufficientBalance(val contractTerms: ContractTerms) : PayStatus() @@ -74,9 +77,9 @@ class PaymentManager( val response: PreparePayResponse = mapper.readValue(result.toString()) Log.e(TAG, "PreparePayResponse $response") mPayStatus.value = when (response) { - is PaymentPossibleResponse -> TODO() - is InsufficientBalanceResponse -> TODO() - is AlreadyConfirmedResponse -> TODO() + is PaymentPossibleResponse -> response.toPayStatusPrepared() + is InsufficientBalanceResponse -> InsufficientBalance(response.contractTerms) + is AlreadyConfirmedResponse -> AlreadyPaid } } } diff --git a/wallet/src/main/java/net/taler/wallet/payment/PaymentResponses.kt b/wallet/src/main/java/net/taler/wallet/payment/PaymentResponses.kt index d2f8e6c..1ff8867 100644 --- a/wallet/src/main/java/net/taler/wallet/payment/PaymentResponses.kt +++ b/wallet/src/main/java/net/taler/wallet/payment/PaymentResponses.kt @@ -19,6 +19,7 @@ package net.taler.wallet.payment import com.fasterxml.jackson.annotation.JsonTypeInfo import com.fasterxml.jackson.annotation.JsonTypeInfo.Id.NAME import com.fasterxml.jackson.annotation.JsonTypeName +import net.taler.common.Amount import net.taler.common.ContractTerms @JsonTypeInfo(use = NAME, property = "status") @@ -26,8 +27,17 @@ sealed class PreparePayResponse(open val proposalId: String) { @JsonTypeName("payment-possible") data class PaymentPossibleResponse( override val proposalId: String, + val amountRaw: Amount, + val amountEffective: Amount, val contractTerms: ContractTerms - ) : PreparePayResponse(proposalId) + ) : PreparePayResponse(proposalId) { + fun toPayStatusPrepared() = PayStatus.Prepared( + contractTerms = contractTerms, + proposalId = proposalId, + amountRaw = amountRaw, + amountEffective = amountEffective + ) + } @JsonTypeName("insufficient-balance") data class InsufficientBalanceResponse( diff --git a/wallet/src/main/java/net/taler/wallet/payment/PromptPaymentFragment.kt b/wallet/src/main/java/net/taler/wallet/payment/PromptPaymentFragment.kt index 6f806b7..ce2b6f7 100644 --- a/wallet/src/main/java/net/taler/wallet/payment/PromptPaymentFragment.kt +++ b/wallet/src/main/java/net/taler/wallet/payment/PromptPaymentFragment.kt @@ -95,7 +95,8 @@ class PromptPaymentFragment : Fragment(), ProductImageClickListener { when (payStatus) { is PayStatus.Prepared -> { showLoading(false) - showOrder(payStatus.contractTerms, payStatus.totalFees) + val fees = payStatus.amountEffective - payStatus.amountRaw + showOrder(payStatus.contractTerms, fees) confirmButton.isEnabled = true confirmButton.setOnClickListener { model.showProgressBar.value = true @@ -109,7 +110,7 @@ class PromptPaymentFragment : Fragment(), ProductImageClickListener { } is PayStatus.InsufficientBalance -> { showLoading(false) - showOrder(payStatus.contractTerms, null) + showOrder(payStatus.contractTerms) errorView.setText(R.string.payment_balance_insufficient) errorView.fadeIn() } @@ -141,7 +142,7 @@ class PromptPaymentFragment : Fragment(), ProductImageClickListener { } } - private fun showOrder(contractTerms: ContractTerms, totalFees: Amount?) { + private fun showOrder(contractTerms: ContractTerms, totalFees: Amount? = null) { orderView.text = contractTerms.summary adapter.setItems(contractTerms.products) if (contractTerms.products.size == 1) paymentManager.toggleDetailsShown() diff --git a/wallet/src/main/res/layout/payment_bottom_bar.xml b/wallet/src/main/res/layout/payment_bottom_bar.xml index a19ac4e..dbc60ae 100644 --- a/wallet/src/main/res/layout/payment_bottom_bar.xml +++ b/wallet/src/main/res/layout/payment_bottom_bar.xml @@ -32,7 +32,6 @@ android:layout_height="wrap_content" android:layout_marginStart="8dp" android:layout_marginTop="8dp" - android:layout_marginBottom="27dp" android:text="@string/payment_label_amount_total" android:visibility="invisible" app:layout_constraintBottom_toTopOf="@+id/confirmButton" |