summaryrefslogtreecommitdiff
path: root/wallet/src/main/java/net/taler/wallet/payment
diff options
context:
space:
mode:
Diffstat (limited to 'wallet/src/main/java/net/taler/wallet/payment')
-rw-r--r--wallet/src/main/java/net/taler/wallet/payment/PaymentManager.kt6
-rw-r--r--wallet/src/main/java/net/taler/wallet/payment/PaymentSuccessfulFragment.kt49
-rw-r--r--wallet/src/main/java/net/taler/wallet/payment/PromptPaymentFragment.kt14
3 files changed, 14 insertions, 55 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 8aaebbc..5c73d6c 100644
--- a/wallet/src/main/java/net/taler/wallet/payment/PaymentManager.kt
+++ b/wallet/src/main/java/net/taler/wallet/payment/PaymentManager.kt
@@ -107,11 +107,11 @@ class PaymentManager(
mDetailsShown.value = !oldValue
}
- fun confirmPay(proposalId: String) {
+ fun confirmPay(proposalId: String, currency: String) {
val args = JSONObject(mapOf("proposalId" to proposalId))
walletBackendApi.sendRequest("confirmPay", args) { _, _ ->
- mPayStatus.postValue(PayStatus.Success)
+ mPayStatus.postValue(PayStatus.Success(currency))
}
}
@@ -157,5 +157,5 @@ sealed class PayStatus {
data class InsufficientBalance(val contractTerms: ContractTerms) : PayStatus()
data class AlreadyPaid(val contractTerms: ContractTerms) : PayStatus()
data class Error(val error: String) : PayStatus()
- object Success : PayStatus()
+ data class Success(val currency: String) : PayStatus()
}
diff --git a/wallet/src/main/java/net/taler/wallet/payment/PaymentSuccessfulFragment.kt b/wallet/src/main/java/net/taler/wallet/payment/PaymentSuccessfulFragment.kt
deleted file mode 100644
index 2a868b0..0000000
--- a/wallet/src/main/java/net/taler/wallet/payment/PaymentSuccessfulFragment.kt
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * This file is part of GNU Taler
- * (C) 2020 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.payment
-
-import android.os.Bundle
-import android.view.LayoutInflater
-import android.view.View
-import android.view.ViewGroup
-import androidx.fragment.app.Fragment
-import androidx.navigation.fragment.findNavController
-import kotlinx.android.synthetic.main.fragment_payment_successful.*
-import net.taler.common.fadeIn
-import net.taler.wallet.R
-
-/**
- * Fragment that shows the success message for a payment.
- */
-class PaymentSuccessfulFragment : Fragment() {
-
- override fun onCreateView(
- inflater: LayoutInflater, container: ViewGroup?,
- savedInstanceState: Bundle?
- ): View? {
- return inflater.inflate(R.layout.fragment_payment_successful, container, false)
- }
-
- override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
- successImageView.fadeIn()
- successTextView.fadeIn()
- backButton.setOnClickListener {
- findNavController().navigateUp()
- }
- }
-
-}
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 6d31879..ab109bc 100644
--- a/wallet/src/main/java/net/taler/wallet/payment/PromptPaymentFragment.kt
+++ b/wallet/src/main/java/net/taler/wallet/payment/PromptPaymentFragment.kt
@@ -30,14 +30,16 @@ import androidx.lifecycle.observe
import androidx.navigation.fragment.findNavController
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.transition.TransitionManager.beginDelayedTransition
+import com.google.android.material.snackbar.Snackbar
+import com.google.android.material.snackbar.Snackbar.LENGTH_LONG
import kotlinx.android.synthetic.main.payment_bottom_bar.*
import kotlinx.android.synthetic.main.payment_details.*
import net.taler.common.Amount
import net.taler.common.ContractTerms
import net.taler.common.fadeIn
import net.taler.common.fadeOut
-import net.taler.wallet.R
import net.taler.wallet.MainViewModel
+import net.taler.wallet.R
/**
* Show a payment and ask the user to accept/decline.
@@ -97,7 +99,10 @@ class PromptPaymentFragment : Fragment(), ProductImageClickListener {
confirmButton.isEnabled = true
confirmButton.setOnClickListener {
model.showProgressBar.value = true
- paymentManager.confirmPay(payStatus.proposalId)
+ paymentManager.confirmPay(
+ payStatus.proposalId,
+ payStatus.contractTerms.amount.currency
+ )
confirmButton.fadeOut()
confirmProgressBar.fadeIn()
}
@@ -111,7 +116,10 @@ class PromptPaymentFragment : Fragment(), ProductImageClickListener {
is PayStatus.Success -> {
showLoading(false)
paymentManager.resetPayStatus()
- findNavController().navigate(R.id.action_promptPayment_to_paymentSuccessful)
+ // TODO bring the user to the currency's transaction page, if there's more than one currency
+ model.transactionManager.selectedCurrency = payStatus.currency
+ findNavController().navigate(R.id.action_promptPayment_to_nav_main)
+ Snackbar.make(requireView(), R.string.payment_initiated, LENGTH_LONG).show()
}
is PayStatus.AlreadyPaid -> {
showLoading(false)