aboutsummaryrefslogtreecommitdiff
path: root/merchant-terminal
diff options
context:
space:
mode:
authorTorsten Grote <t@grobox.de>2021-02-05 13:49:51 -0300
committerTorsten Grote <t@grobox.de>2021-02-05 13:49:51 -0300
commit21c79819fa6aad2bf9c68bd03faa273ff450ca56 (patch)
treeb210ddfff94f797e2e7fae40ba47e6f0329e97d8 /merchant-terminal
parente07a00ed65262f5142ecd46d3f9df6672b28fbb3 (diff)
downloadtaler-android-21c79819fa6aad2bf9c68bd03faa273ff450ca56.tar.gz
taler-android-21c79819fa6aad2bf9c68bd03faa273ff450ca56.tar.bz2
taler-android-21c79819fa6aad2bf9c68bd03faa273ff450ca56.zip
[pos] Remove QR code once order has been claimed
Diffstat (limited to 'merchant-terminal')
-rw-r--r--merchant-terminal/src/main/java/net/taler/merchantpos/payment/Payment.kt1
-rw-r--r--merchant-terminal/src/main/java/net/taler/merchantpos/payment/PaymentManager.kt19
-rw-r--r--merchant-terminal/src/main/java/net/taler/merchantpos/payment/ProcessPaymentFragment.kt20
-rw-r--r--merchant-terminal/src/main/res/values/strings.xml1
4 files changed, 26 insertions, 15 deletions
diff --git a/merchant-terminal/src/main/java/net/taler/merchantpos/payment/Payment.kt b/merchant-terminal/src/main/java/net/taler/merchantpos/payment/Payment.kt
index 9200ced..b3ff14b 100644
--- a/merchant-terminal/src/main/java/net/taler/merchantpos/payment/Payment.kt
+++ b/merchant-terminal/src/main/java/net/taler/merchantpos/payment/Payment.kt
@@ -24,6 +24,7 @@ data class Payment(
val currency: String,
val orderId: String? = null,
val talerPayUri: String? = null,
+ val claimed: Boolean = false,
val paid: Boolean = false,
val error: String? = null
)
diff --git a/merchant-terminal/src/main/java/net/taler/merchantpos/payment/PaymentManager.kt b/merchant-terminal/src/main/java/net/taler/merchantpos/payment/PaymentManager.kt
index b017726..98161db 100644
--- a/merchant-terminal/src/main/java/net/taler/merchantpos/payment/PaymentManager.kt
+++ b/merchant-terminal/src/main/java/net/taler/merchantpos/payment/PaymentManager.kt
@@ -46,7 +46,7 @@ class PaymentManager(
private val context: Context,
private val configManager: ConfigManager,
private val scope: CoroutineScope,
- private val api: MerchantApi
+ private val api: MerchantApi,
) {
private val mPayment = MutableLiveData<Payment>()
@@ -89,12 +89,17 @@ class PaymentManager(
assertUiThread()
if (!isActive) return@handle // don't continue if job was cancelled
val currentValue = requireNotNull(mPayment.value)
- if (response.paid) {
- mPayment.value = currentValue.copy(paid = true)
- checkTimer.cancel()
- } else if (currentValue.talerPayUri == null) {
- response as CheckPaymentResponse.Unpaid
- mPayment.value = currentValue.copy(talerPayUri = response.talerPayUri)
+ when (response) {
+ is CheckPaymentResponse.Unpaid -> {
+ mPayment.value = currentValue.copy(talerPayUri = response.talerPayUri)
+ }
+ is CheckPaymentResponse.Claimed -> {
+ mPayment.value = currentValue.copy(claimed = true)
+ }
+ is CheckPaymentResponse.Paid -> {
+ mPayment.value = currentValue.copy(paid = true)
+ checkTimer.cancel()
+ }
}
}
}
diff --git a/merchant-terminal/src/main/java/net/taler/merchantpos/payment/ProcessPaymentFragment.kt b/merchant-terminal/src/main/java/net/taler/merchantpos/payment/ProcessPaymentFragment.kt
index dc5d554..201c9cf 100644
--- a/merchant-terminal/src/main/java/net/taler/merchantpos/payment/ProcessPaymentFragment.kt
+++ b/merchant-terminal/src/main/java/net/taler/merchantpos/payment/ProcessPaymentFragment.kt
@@ -45,8 +45,8 @@ class ProcessPaymentFragment : Fragment() {
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
- savedInstanceState: Bundle?
- ): View? {
+ savedInstanceState: Bundle?,
+ ): View {
ui = FragmentProcessPaymentBinding.inflate(inflater, container, false)
return ui.root
}
@@ -79,18 +79,22 @@ class ProcessPaymentFragment : Fragment() {
navigate(actionProcessPaymentToPaymentSuccess())
return
}
+ if (payment.claimed) {
+ ui.qrcodeView.fadeOut()
+ ui.payIntroView.setText(R.string.payment_claimed)
+ } else {
+ payment.talerPayUri?.let {
+ ui.qrcodeView.setImageBitmap(makeQrCode(it))
+ ui.qrcodeView.fadeIn()
+ ui.progressBar.fadeOut()
+ }
+ }
ui.payIntroView.fadeIn()
ui.amountView.text = payment.order.total.toString()
payment.orderId?.let {
ui.orderRefView.text = getString(R.string.payment_order_id, it)
ui.orderRefView.fadeIn()
}
- payment.talerPayUri?.let {
- val qrcodeBitmap = makeQrCode(it)
- ui.qrcodeView.setImageBitmap(qrcodeBitmap)
- ui.qrcodeView.fadeIn()
- ui.progressBar.fadeOut()
- }
}
private fun onPaymentCancel() {
diff --git a/merchant-terminal/src/main/res/values/strings.xml b/merchant-terminal/src/main/res/values/strings.xml
index bee3cd4..f06866d 100644
--- a/merchant-terminal/src/main/res/values/strings.xml
+++ b/merchant-terminal/src/main/res/values/strings.xml
@@ -38,6 +38,7 @@
<string name="payment_intro_nfc">Please let customer scan QR Code or use NFC to pay.</string>
<string name="payment_intro">Please let customer scan QR Code to pay.</string>
+ <string name="payment_claimed">Waiting for customer to confirm payment…</string>
<string name="payment_cancel">Cancel payment</string>
<string name="payment_received">Payment received</string>
<string name="payment_back_button">Continue</string>