mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-08-22 18:50:07 +00:00
wip
This commit is contained in:
@@ -8,8 +8,9 @@ import chat.simplex.common.views.badges.BadgeStoreError
|
||||
fun loadPlayStoreCountry() {}
|
||||
|
||||
// No store in this flavor: no product is offered, so the purchase screen shows nothing to buy
|
||||
// TODO [badges] this build pays via Stripe/crypto - the badge service catalog replaces these
|
||||
@Suppress("UNUSED_PARAMETER")
|
||||
suspend fun loadBadgeProducts(productIds: List<String>): List<BadgeProduct> = emptyList()
|
||||
suspend fun loadBadgeProducts(oneTimeIds: List<String>, subscriptionIds: List<String>): List<BadgeProduct> = emptyList()
|
||||
|
||||
@Suppress("UNUSED_PARAMETER")
|
||||
suspend fun purchaseBadge(productId: String, invoiceId: String): BadgePurchaseOutcome =
|
||||
|
||||
@@ -43,12 +43,12 @@ fun loadPlayStoreCountry() {
|
||||
@Volatile private var badgeProductDetails: Map<String, ProductDetails> = emptyMap()
|
||||
@Volatile private var badgePurchase: CompletableDeferred<BadgePurchaseOutcome>? = null
|
||||
|
||||
suspend fun loadBadgeProducts(productIds: List<String>): List<BadgeProduct> {
|
||||
suspend fun loadBadgeProducts(oneTimeIds: List<String>, subscriptionIds: List<String>): List<BadgeProduct> {
|
||||
val client = connectedBadgeBillingClient()
|
||||
// every id is queried as both types - Play returns only the ones that match, so the product type
|
||||
// does not have to be inferred from the id
|
||||
val details = queryBadgeProducts(client, productIds, BillingClient.ProductType.INAPP) +
|
||||
queryBadgeProducts(client, productIds, BillingClient.ProductType.SUBS)
|
||||
// two queries because Play rejects a product list mixing INAPP and SUBS
|
||||
val details = queryBadgeProducts(client, oneTimeIds, BillingClient.ProductType.INAPP) +
|
||||
queryBadgeProducts(client, subscriptionIds, BillingClient.ProductType.SUBS)
|
||||
val productIds = oneTimeIds + subscriptionIds
|
||||
if (details.size < productIds.size) {
|
||||
// Play drops ids it cannot resolve without saying why, so the package it was asked for and the
|
||||
// store country are logged with them - a debug build's applicationIdSuffix is a common cause
|
||||
|
||||
@@ -345,7 +345,7 @@ class SimplexApp: Application(), LifecycleEventObserver {
|
||||
|
||||
override fun androidLoadPlayStoreCountry() = loadPlayStoreCountry()
|
||||
|
||||
override suspend fun androidLoadBadgeProducts(productIds: List<String>): List<BadgeProduct> = loadBadgeProducts(productIds)
|
||||
override suspend fun androidLoadBadgeProducts(oneTimeIds: List<String>, subscriptionIds: List<String>): List<BadgeProduct> = loadBadgeProducts(oneTimeIds, subscriptionIds)
|
||||
|
||||
override suspend fun androidPurchaseBadge(productId: String, invoiceId: String): BadgePurchaseOutcome = purchaseBadge(productId, invoiceId)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user