mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-26 22:20:20 +00:00
Start re-work of play billing checkout flow.
This commit is contained in:
committed by
Greyson Parrelli
parent
b340097f9c
commit
48bd57c56a
@@ -6,13 +6,22 @@
|
||||
package org.signal.core.util.billing
|
||||
|
||||
import android.app.Activity
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.emptyFlow
|
||||
|
||||
/**
|
||||
* Variant interface for the BillingApi.
|
||||
*/
|
||||
interface BillingApi {
|
||||
/**
|
||||
* Listenable stream of billing purchase results. It's up to the user
|
||||
* to call queryPurchases after subscription.
|
||||
*/
|
||||
fun getBillingPurchaseResults(): Flow<BillingPurchaseResult> = emptyFlow()
|
||||
|
||||
fun isApiAvailable(): Boolean = false
|
||||
suspend fun queryProducts() = Unit
|
||||
|
||||
suspend fun queryProduct(): BillingProduct? = null
|
||||
|
||||
/**
|
||||
* Queries the user's current purchases. This enqueues a check and will
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
* Copyright 2024 Signal Messenger, LLC
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
package org.signal.core.util.billing
|
||||
|
||||
import org.signal.core.util.money.FiatMoney
|
||||
|
||||
/**
|
||||
* Represents a purchasable product from the Google Play Billing API
|
||||
*/
|
||||
data class BillingProduct(
|
||||
val price: FiatMoney
|
||||
)
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright 2024 Signal Messenger, LLC
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
package org.signal.core.util.billing
|
||||
|
||||
/**
|
||||
* Sealed class hierarchy representing the different success
|
||||
* and error states of google play billing purchases.
|
||||
*/
|
||||
sealed interface BillingPurchaseResult {
|
||||
data class Success(
|
||||
val purchaseToken: String,
|
||||
val isAcknowledged: Boolean,
|
||||
val purchaseTime: Long
|
||||
) : BillingPurchaseResult
|
||||
data object UserCancelled : BillingPurchaseResult
|
||||
data object None : BillingPurchaseResult
|
||||
data object TryAgainLater : BillingPurchaseResult
|
||||
data object AlreadySubscribed : BillingPurchaseResult
|
||||
data object FeatureNotSupported : BillingPurchaseResult
|
||||
data object GenericError : BillingPurchaseResult
|
||||
data object NetworkError : BillingPurchaseResult
|
||||
data object BillingUnavailable : BillingPurchaseResult
|
||||
}
|
||||
Reference in New Issue
Block a user