From 7473e7a61c3b803c643b2fd7edbd24a64704d8b2 Mon Sep 17 00:00:00 2001 From: spaced4ndy <8711996+spaced4ndy@users.noreply.github.com> Date: Thu, 1 Oct 2026 14:12:28 +0400 Subject: [PATCH] android: no badge can be bought where there is no platform store --- .../kotlin/chat/simplex/common/views/badges/BadgeStore.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/badges/BadgeStore.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/badges/BadgeStore.kt index 53b7fdb2bb..01552d7365 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/badges/BadgeStore.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/badges/BadgeStore.kt @@ -128,6 +128,7 @@ sealed class BadgeStoreError: Exception() { class BillingError(val responseCode: Int, val debugMessage: String): BadgeStoreError() object StoreUnavailable: BadgeStoreError() object NoActiveProfile: BadgeStoreError() + class InvoiceRefused(val err: ChatError): BadgeStoreError() override val message: String get() = when (this) { @@ -135,6 +136,7 @@ sealed class BadgeStoreError: Exception() { is BillingError -> "billingError(responseCode: $responseCode, $debugMessage)" is StoreUnavailable -> "storeUnavailable" is NoActiveProfile -> "noActiveProfile" + is InvoiceRefused -> "invoiceRefused(${err.string})" } } @@ -171,7 +173,7 @@ object BadgeStore { } fun canBuy(userId: Long?): Boolean = - reconciledOnce.value && buying.value.isEmpty() && purchaseState(userId) == null + platform.androidHasPlatformStore && reconciledOnce.value && buying.value.isEmpty() && purchaseState(userId) == null fun setStorePurchases(rhId: Long?, userId: Long, purchases: List) { storePurchases.value = Triple(rhId, userId, purchases) @@ -296,7 +298,7 @@ object BadgeStore { Log.e(TAG, "BadgeStore.presentPurchase: ${r.err?.string}") val refused = badgeReceiptRefused(r.err) if (refused) finish(receipt) - val text = chatModel.controller.redeemErrorText(r.err) + val text = chatModel.controller.redeemErrorText(r.err, purchase = true) alertText = if (refused) text else text + "\n\n" + generalGetString(MR.strings.badges_purchase_will_retry) } null -> {}