aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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>