optimize mfaisa QR, fix bug that fails to switch to default account after ooredoo QR is cancelled and new BML QR is scanned
Auto Tag on Version Change / check-version (push) Successful in 3s

This commit is contained in:
2026-09-21 08:15:23 +05:00
parent a75d8e420a
commit 71dd654edc
@@ -199,25 +199,31 @@ class TransferFragment : Fragment() {
return
}
// Cards can't pay PayMV QR — fall back to default account or clear selection
val isCard = selectedAccount?.let {
it.profileType == "BML_PREPAID" || it.profileType == "BML_CREDIT" || it.profileType == "BML_DEBIT"
} ?: false
if (isCard) {
Toast.makeText(requireContext(), R.string.card_qr_paymv_unsupported, Toast.LENGTH_SHORT).show()
// Neither BML cards nor M-Faisa wallets can pay a PayMV QR. Either can be the selected
// source when the scan happens — an M-Faisa merchant QR auto-switches the source, and
// clearing that merchant leaves the source behind — so fall back to the default account
// (or clear the selection) rather than leaving a source that cannot pay.
val src = selectedAccount
val isCard = src != null &&
(src.profileType == "BML_PREPAID" || src.profileType == "BML_CREDIT" || src.profileType == "BML_DEBIT")
val isMfaisa = src?.bank == "MFAISA"
if (isCard || isMfaisa) {
// The card case has always explained itself; the M-Faisa case switches silently.
if (isCard) Toast.makeText(requireContext(), R.string.card_qr_paymv_unsupported, Toast.LENGTH_SHORT).show()
val defaultNum = CredentialStore(requireContext()).getDefaultAccountNumber()
val defaultAcc = defaultNum?.let { num -> viewModel.accounts.value?.firstOrNull { it.accountNumber == num } }
selectedAccount = defaultAcc
binding.tilAmount.prefixText = null
if (defaultAcc != null) {
updateAmountPrefix(defaultAcc)
showFromCard(defaultAcc)
// Also restores the "To" row out of M-Faisa phone-entry mode, via showFromCard().
selectSourceAccount(defaultAcc)
} else {
selectedAccount = null
binding.cardFromInfo.visibility = View.GONE
binding.tilFrom.visibility = View.VISIBLE
binding.actvFrom.setText("", false)
applyMfaisaToFieldMode(false)
updateTransferButton()
}
updateTransferButton()
}
if (qr.amount != null) binding.etAmount.setText(qr.amount)
@@ -1483,6 +1489,7 @@ class TransferFragment : Fragment() {
internal fun clearForm() {
bmlHandler().resetOtpState()
bmlHandler().clearQrMerchant()
mfaisaHandler?.clearState()
mfaisaHandler?.clearQrMerchant()
selectedAccount = null