diff --git a/apiTester/src/commonMain/kotlin/com/revenuecat/purchases/kmp/apitester/PurchasesCommonAPI.kt b/apiTester/src/commonMain/kotlin/com/revenuecat/purchases/kmp/apitester/PurchasesCommonAPI.kt index b37dc0d..2ca220a 100644 --- a/apiTester/src/commonMain/kotlin/com/revenuecat/purchases/kmp/apitester/PurchasesCommonAPI.kt +++ b/apiTester/src/commonMain/kotlin/com/revenuecat/purchases/kmp/apitester/PurchasesCommonAPI.kt @@ -9,6 +9,7 @@ import com.revenuecat.purchases.kmp.LogLevel import com.revenuecat.purchases.kmp.Offerings import com.revenuecat.purchases.kmp.Package import com.revenuecat.purchases.kmp.Purchases +import com.revenuecat.purchases.kmp.PurchasesAreCompletedBy.MY_APP import com.revenuecat.purchases.kmp.PurchasesConfiguration import com.revenuecat.purchases.kmp.PurchasesDelegate import com.revenuecat.purchases.kmp.PurchasesError @@ -238,7 +239,7 @@ private class PurchasesCommonAPI { val config: PurchasesConfiguration = PurchasesConfiguration(apiKey = "") { appUserId = "" - observerMode = true + purchasesAreCompletedBy = MY_APP showInAppMessagesAutomatically = true dangerousSettings = DangerousSettings(autoSyncPurchases = true) verificationMode = EntitlementVerificationMode.INFORMATIONAL @@ -247,7 +248,7 @@ private class PurchasesCommonAPI { val configuredInstance: Purchases = Purchases.configure(config) val otherConfiguredInstance: Purchases = Purchases.configure(apiKey = "") { appUserId = "" - observerMode = true + purchasesAreCompletedBy = MY_APP showInAppMessagesAutomatically = true dangerousSettings = DangerousSettings(autoSyncPurchases = true) verificationMode = EntitlementVerificationMode.INFORMATIONAL diff --git a/core/api/core.api b/core/api/core.api index cd4ed1e..1dd480c 100644 --- a/core/api/core.api +++ b/core/api/core.api @@ -128,7 +128,6 @@ public final class com/revenuecat/purchases/kmp/Purchases { public final fun getCustomerInfo (Lcom/revenuecat/purchases/CacheFetchPolicy;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;)V public static synthetic fun getCustomerInfo$default (Lcom/revenuecat/purchases/kmp/Purchases;Lcom/revenuecat/purchases/CacheFetchPolicy;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)V public final fun getDelegate ()Lcom/revenuecat/purchases/kmp/PurchasesDelegate; - public final fun getFinishTransactions ()Z public static final fun getForceUniversalAppStore ()Z public static final fun getLogHandler ()Lcom/revenuecat/purchases/LogHandler; public static final fun getLogLevel ()Lcom/revenuecat/purchases/LogLevel; @@ -136,6 +135,7 @@ public final class com/revenuecat/purchases/kmp/Purchases { public final fun getProducts (Ljava/util/List;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;)V public final fun getPromotionalOffer (Lcom/revenuecat/purchases/kmp/models/StoreProductDiscount;Lcom/revenuecat/purchases/kmp/models/StoreProduct;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;)V public static final fun getProxyURL ()Ljava/lang/String; + public final fun getPurchasesAreCompletedBy ()Lcom/revenuecat/purchases/kmp/PurchasesAreCompletedBy; public static final fun getSharedInstance ()Lcom/revenuecat/purchases/kmp/Purchases; public static final fun getSimulatesAskToBuyInSandbox ()Z public final fun getStore ()Lcom/revenuecat/purchases/Store; @@ -166,7 +166,6 @@ public final class com/revenuecat/purchases/kmp/Purchases { public final fun setDisplayName (Ljava/lang/String;)V public final fun setEmail (Ljava/lang/String;)V public final fun setFBAnonymousID (Ljava/lang/String;)V - public final fun setFinishTransactions (Z)V public final fun setFirebaseAppInstanceID (Ljava/lang/String;)V public static final fun setForceUniversalAppStore (Z)V public final fun setKeyword (Ljava/lang/String;)V @@ -179,12 +178,13 @@ public final class com/revenuecat/purchases/kmp/Purchases { public final fun setOnesignalUserID (Ljava/lang/String;)V public final fun setPhoneNumber (Ljava/lang/String;)V public static final fun setProxyURL (Ljava/lang/String;)V + public final fun setPurchasesAreCompletedBy (Lcom/revenuecat/purchases/kmp/PurchasesAreCompletedBy;)V public final fun setPushToken (Ljava/lang/String;)V public static final fun setSimulatesAskToBuyInSandbox (Z)V public final fun showInAppMessagesIfNeeded (Ljava/util/List;)V public static synthetic fun showInAppMessagesIfNeeded$default (Lcom/revenuecat/purchases/kmp/Purchases;Ljava/util/List;ILjava/lang/Object;)V + public final fun syncAmazonPurchase (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Double;)V public final fun syncAttributesAndOfferingsIfNeeded (Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;)V - public final fun syncObserverModeAmazonPurchase (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Double;)V public final fun syncPurchases (Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;)V } @@ -206,13 +206,21 @@ public final class com/revenuecat/purchases/kmp/Purchases$Companion { public final fun setSimulatesAskToBuyInSandbox (Z)V } +public final class com/revenuecat/purchases/kmp/PurchasesAreCompletedBy : java/lang/Enum { + public static final field MY_APP Lcom/revenuecat/purchases/kmp/PurchasesAreCompletedBy; + public static final field REVENUECAT Lcom/revenuecat/purchases/kmp/PurchasesAreCompletedBy; + public static fun getEntries ()Lkotlin/enums/EnumEntries; + public static fun valueOf (Ljava/lang/String;)Lcom/revenuecat/purchases/kmp/PurchasesAreCompletedBy; + public static fun values ()[Lcom/revenuecat/purchases/kmp/PurchasesAreCompletedBy; +} + public final class com/revenuecat/purchases/kmp/PurchasesConfiguration { - public synthetic fun (Ljava/lang/String;Ljava/lang/String;ZLjava/lang/String;ZLcom/revenuecat/purchases/Store;ZLcom/revenuecat/purchases/kmp/DangerousSettings;Lcom/revenuecat/purchases/kmp/EntitlementVerificationMode;Lkotlin/jvm/internal/DefaultConstructorMarker;)V + public synthetic fun (Ljava/lang/String;Ljava/lang/String;Lcom/revenuecat/purchases/kmp/PurchasesAreCompletedBy;Ljava/lang/String;ZLcom/revenuecat/purchases/Store;ZLcom/revenuecat/purchases/kmp/DangerousSettings;Lcom/revenuecat/purchases/kmp/EntitlementVerificationMode;Lkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun getApiKey ()Ljava/lang/String; public final fun getAppUserId ()Ljava/lang/String; public final fun getDangerousSettings ()Lcom/revenuecat/purchases/kmp/DangerousSettings; public final fun getDiagnosticsEnabled ()Z - public final fun getObserverMode ()Z + public final fun getPurchasesAreCompletedBy ()Lcom/revenuecat/purchases/kmp/PurchasesAreCompletedBy; public final fun getShowInAppMessagesAutomatically ()Z public final fun getStore ()Lcom/revenuecat/purchases/Store; public final fun getUserDefaultsSuiteName ()Ljava/lang/String; @@ -231,17 +239,17 @@ public final class com/revenuecat/purchases/kmp/PurchasesConfiguration$Builder { public final fun getAppUserId ()Ljava/lang/String; public final fun getDangerousSettings ()Lcom/revenuecat/purchases/kmp/DangerousSettings; public final fun getDiagnosticsEnabled ()Z - public final fun getObserverMode ()Z + public final fun getPurchasesAreCompletedBy ()Lcom/revenuecat/purchases/kmp/PurchasesAreCompletedBy; public final fun getShowInAppMessagesAutomatically ()Z public final fun getStore ()Lcom/revenuecat/purchases/Store; public final fun getUserDefaultsSuiteName ()Ljava/lang/String; public final fun getVerificationMode ()Lcom/revenuecat/purchases/kmp/EntitlementVerificationMode; - public final fun observerMode (Z)Lcom/revenuecat/purchases/kmp/PurchasesConfiguration$Builder; + public final fun purchasesAreCompletedBy (Lcom/revenuecat/purchases/kmp/PurchasesAreCompletedBy;)Lcom/revenuecat/purchases/kmp/PurchasesConfiguration$Builder; public final synthetic fun setApiKey (Ljava/lang/String;)V public final synthetic fun setAppUserId (Ljava/lang/String;)V public final synthetic fun setDangerousSettings (Lcom/revenuecat/purchases/kmp/DangerousSettings;)V public final synthetic fun setDiagnosticsEnabled (Z)V - public final synthetic fun setObserverMode (Z)V + public final synthetic fun setPurchasesAreCompletedBy (Lcom/revenuecat/purchases/kmp/PurchasesAreCompletedBy;)V public final synthetic fun setShowInAppMessagesAutomatically (Z)V public final synthetic fun setStore (Lcom/revenuecat/purchases/Store;)V public final synthetic fun setUserDefaultsSuiteName (Ljava/lang/String;)V diff --git a/core/api/core.klib.api b/core/api/core.klib.api index f677979..1eb7619 100644 --- a/core/api/core.klib.api +++ b/core/api/core.klib.api @@ -173,8 +173,8 @@ final class com.revenuecat.purchases.kmp/Purchases { // com.revenuecat.purchases final fun setPhoneNumber(kotlin/String?) // com.revenuecat.purchases.kmp/Purchases.setPhoneNumber|setPhoneNumber(kotlin.String?){}[0] final fun setPushToken(kotlin/String?) // com.revenuecat.purchases.kmp/Purchases.setPushToken|setPushToken(kotlin.String?){}[0] final fun showInAppMessagesIfNeeded(kotlin.collections/List = ...) // com.revenuecat.purchases.kmp/Purchases.showInAppMessagesIfNeeded|showInAppMessagesIfNeeded(kotlin.collections.List){}[0] + final fun syncAmazonPurchase(kotlin/String, kotlin/String, kotlin/String, kotlin/String?, kotlin/Double?) // com.revenuecat.purchases.kmp/Purchases.syncAmazonPurchase|syncAmazonPurchase(kotlin.String;kotlin.String;kotlin.String;kotlin.String?;kotlin.Double?){}[0] final fun syncAttributesAndOfferingsIfNeeded(kotlin/Function1, kotlin/Function1) // com.revenuecat.purchases.kmp/Purchases.syncAttributesAndOfferingsIfNeeded|syncAttributesAndOfferingsIfNeeded(kotlin.Function1;kotlin.Function1){}[0] - final fun syncObserverModeAmazonPurchase(kotlin/String, kotlin/String, kotlin/String, kotlin/String?, kotlin/Double?) // com.revenuecat.purchases.kmp/Purchases.syncObserverModeAmazonPurchase|syncObserverModeAmazonPurchase(kotlin.String;kotlin.String;kotlin.String;kotlin.String?;kotlin.Double?){}[0] final fun syncPurchases(kotlin/Function1, kotlin/Function1) // com.revenuecat.purchases.kmp/Purchases.syncPurchases|syncPurchases(kotlin.Function1;kotlin.Function1){}[0] final object Companion { // com.revenuecat.purchases.kmp/Purchases.Companion|null[0] final fun canMakePayments(kotlin.collections/List = ..., kotlin/Function1) // com.revenuecat.purchases.kmp/Purchases.Companion.canMakePayments|canMakePayments(kotlin.collections.List;kotlin.Function1){}[0] @@ -208,9 +208,9 @@ final class com.revenuecat.purchases.kmp/Purchases { // com.revenuecat.purchases final var delegate // com.revenuecat.purchases.kmp/Purchases.delegate|{}delegate[0] final fun (): com.revenuecat.purchases.kmp/PurchasesDelegate? // com.revenuecat.purchases.kmp/Purchases.delegate.|(){}[0] final fun (com.revenuecat.purchases.kmp/PurchasesDelegate?) // com.revenuecat.purchases.kmp/Purchases.delegate.|(com.revenuecat.purchases.kmp.PurchasesDelegate?){}[0] - final var finishTransactions // com.revenuecat.purchases.kmp/Purchases.finishTransactions|{}finishTransactions[0] - final fun (): kotlin/Boolean // com.revenuecat.purchases.kmp/Purchases.finishTransactions.|(){}[0] - final fun (kotlin/Boolean) // com.revenuecat.purchases.kmp/Purchases.finishTransactions.|(kotlin.Boolean){}[0] + final var purchasesAreCompletedBy // com.revenuecat.purchases.kmp/Purchases.purchasesAreCompletedBy|{}purchasesAreCompletedBy[0] + final fun (): com.revenuecat.purchases.kmp/PurchasesAreCompletedBy // com.revenuecat.purchases.kmp/Purchases.purchasesAreCompletedBy.|(){}[0] + final fun (com.revenuecat.purchases.kmp/PurchasesAreCompletedBy) // com.revenuecat.purchases.kmp/Purchases.purchasesAreCompletedBy.|(com.revenuecat.purchases.kmp.PurchasesAreCompletedBy){}[0] } final class com.revenuecat.purchases.kmp/PurchasesConfiguration { // com.revenuecat.purchases.kmp/PurchasesConfiguration|null[0] final class Builder { // com.revenuecat.purchases.kmp/PurchasesConfiguration.Builder|null[0] @@ -220,7 +220,7 @@ final class com.revenuecat.purchases.kmp/PurchasesConfiguration { // com.revenue final fun build(): com.revenuecat.purchases.kmp/PurchasesConfiguration // com.revenuecat.purchases.kmp/PurchasesConfiguration.Builder.build|build(){}[0] final fun dangerousSettings(com.revenuecat.purchases.kmp/DangerousSettings): com.revenuecat.purchases.kmp/PurchasesConfiguration.Builder // com.revenuecat.purchases.kmp/PurchasesConfiguration.Builder.dangerousSettings|dangerousSettings(com.revenuecat.purchases.kmp.DangerousSettings){}[0] final fun diagnosticsEnabled(kotlin/Boolean): com.revenuecat.purchases.kmp/PurchasesConfiguration.Builder // com.revenuecat.purchases.kmp/PurchasesConfiguration.Builder.diagnosticsEnabled|diagnosticsEnabled(kotlin.Boolean){}[0] - final fun observerMode(kotlin/Boolean): com.revenuecat.purchases.kmp/PurchasesConfiguration.Builder // com.revenuecat.purchases.kmp/PurchasesConfiguration.Builder.observerMode|observerMode(kotlin.Boolean){}[0] + final fun purchasesAreCompletedBy(com.revenuecat.purchases.kmp/PurchasesAreCompletedBy): com.revenuecat.purchases.kmp/PurchasesConfiguration.Builder // com.revenuecat.purchases.kmp/PurchasesConfiguration.Builder.purchasesAreCompletedBy|purchasesAreCompletedBy(com.revenuecat.purchases.kmp.PurchasesAreCompletedBy){}[0] final fun showInAppMessagesAutomatically(kotlin/Boolean): com.revenuecat.purchases.kmp/PurchasesConfiguration.Builder // com.revenuecat.purchases.kmp/PurchasesConfiguration.Builder.showInAppMessagesAutomatically|showInAppMessagesAutomatically(kotlin.Boolean){}[0] final fun store(com.revenuecat.purchases.kmp/Store?): com.revenuecat.purchases.kmp/PurchasesConfiguration.Builder // com.revenuecat.purchases.kmp/PurchasesConfiguration.Builder.store|store(com.revenuecat.purchases.kmp.Store?){}[0] final fun userDefaultsSuiteName(kotlin/String?): com.revenuecat.purchases.kmp/PurchasesConfiguration.Builder // com.revenuecat.purchases.kmp/PurchasesConfiguration.Builder.userDefaultsSuiteName|userDefaultsSuiteName(kotlin.String?){}[0] @@ -237,9 +237,9 @@ final class com.revenuecat.purchases.kmp/PurchasesConfiguration { // com.revenue final var diagnosticsEnabled // com.revenuecat.purchases.kmp/PurchasesConfiguration.Builder.diagnosticsEnabled|{}diagnosticsEnabled[0] final fun (): kotlin/Boolean // com.revenuecat.purchases.kmp/PurchasesConfiguration.Builder.diagnosticsEnabled.|(){}[0] final fun (kotlin/Boolean) // com.revenuecat.purchases.kmp/PurchasesConfiguration.Builder.diagnosticsEnabled.|(kotlin.Boolean){}[0] - final var observerMode // com.revenuecat.purchases.kmp/PurchasesConfiguration.Builder.observerMode|{}observerMode[0] - final fun (): kotlin/Boolean // com.revenuecat.purchases.kmp/PurchasesConfiguration.Builder.observerMode.|(){}[0] - final fun (kotlin/Boolean) // com.revenuecat.purchases.kmp/PurchasesConfiguration.Builder.observerMode.|(kotlin.Boolean){}[0] + final var purchasesAreCompletedBy // com.revenuecat.purchases.kmp/PurchasesConfiguration.Builder.purchasesAreCompletedBy|{}purchasesAreCompletedBy[0] + final fun (): com.revenuecat.purchases.kmp/PurchasesAreCompletedBy // com.revenuecat.purchases.kmp/PurchasesConfiguration.Builder.purchasesAreCompletedBy.|(){}[0] + final fun (com.revenuecat.purchases.kmp/PurchasesAreCompletedBy) // com.revenuecat.purchases.kmp/PurchasesConfiguration.Builder.purchasesAreCompletedBy.|(com.revenuecat.purchases.kmp.PurchasesAreCompletedBy){}[0] final var showInAppMessagesAutomatically // com.revenuecat.purchases.kmp/PurchasesConfiguration.Builder.showInAppMessagesAutomatically|{}showInAppMessagesAutomatically[0] final fun (): kotlin/Boolean // com.revenuecat.purchases.kmp/PurchasesConfiguration.Builder.showInAppMessagesAutomatically.|(){}[0] final fun (kotlin/Boolean) // com.revenuecat.purchases.kmp/PurchasesConfiguration.Builder.showInAppMessagesAutomatically.|(kotlin.Boolean){}[0] @@ -262,8 +262,8 @@ final class com.revenuecat.purchases.kmp/PurchasesConfiguration { // com.revenue final fun (): com.revenuecat.purchases.kmp/DangerousSettings // com.revenuecat.purchases.kmp/PurchasesConfiguration.dangerousSettings.|(){}[0] final val diagnosticsEnabled // com.revenuecat.purchases.kmp/PurchasesConfiguration.diagnosticsEnabled|{}diagnosticsEnabled[0] final fun (): kotlin/Boolean // com.revenuecat.purchases.kmp/PurchasesConfiguration.diagnosticsEnabled.|(){}[0] - final val observerMode // com.revenuecat.purchases.kmp/PurchasesConfiguration.observerMode|{}observerMode[0] - final fun (): kotlin/Boolean // com.revenuecat.purchases.kmp/PurchasesConfiguration.observerMode.|(){}[0] + final val purchasesAreCompletedBy // com.revenuecat.purchases.kmp/PurchasesConfiguration.purchasesAreCompletedBy|{}purchasesAreCompletedBy[0] + final fun (): com.revenuecat.purchases.kmp/PurchasesAreCompletedBy // com.revenuecat.purchases.kmp/PurchasesConfiguration.purchasesAreCompletedBy.|(){}[0] final val showInAppMessagesAutomatically // com.revenuecat.purchases.kmp/PurchasesConfiguration.showInAppMessagesAutomatically|{}showInAppMessagesAutomatically[0] final fun (): kotlin/Boolean // com.revenuecat.purchases.kmp/PurchasesConfiguration.showInAppMessagesAutomatically.|(){}[0] final val store // com.revenuecat.purchases.kmp/PurchasesConfiguration.store|{}store[0] @@ -437,6 +437,14 @@ final enum class com.revenuecat.purchases.kmp/ProductType : kotlin/Enum(): kotlin.enums/EnumEntries // com.revenuecat.purchases.kmp/ProductType.entries.|#static(){}[0] } +final enum class com.revenuecat.purchases.kmp/PurchasesAreCompletedBy : kotlin/Enum { // com.revenuecat.purchases.kmp/PurchasesAreCompletedBy|null[0] + enum entry MY_APP // com.revenuecat.purchases.kmp/PurchasesAreCompletedBy.MY_APP|null[0] + enum entry REVENUECAT // com.revenuecat.purchases.kmp/PurchasesAreCompletedBy.REVENUECAT|null[0] + final fun valueOf(kotlin/String): com.revenuecat.purchases.kmp/PurchasesAreCompletedBy // com.revenuecat.purchases.kmp/PurchasesAreCompletedBy.valueOf|valueOf#static(kotlin.String){}[0] + final fun values(): kotlin/Array // com.revenuecat.purchases.kmp/PurchasesAreCompletedBy.values|values#static(){}[0] + final val entries // com.revenuecat.purchases.kmp/PurchasesAreCompletedBy.entries|#static{}entries[0] + final fun (): kotlin.enums/EnumEntries // com.revenuecat.purchases.kmp/PurchasesAreCompletedBy.entries.|#static(){}[0] +} final enum class com.revenuecat.purchases.kmp/PurchasesErrorCode : kotlin/Enum { // com.revenuecat.purchases.kmp/PurchasesErrorCode|null[0] enum entry ApiEndpointBlocked // com.revenuecat.purchases.kmp/PurchasesErrorCode.ApiEndpointBlocked|null[0] enum entry BeginRefundRequestError // com.revenuecat.purchases.kmp/PurchasesErrorCode.BeginRefundRequestError|null[0] diff --git a/core/src/androidMain/kotlin/com/revenuecat/purchases/kmp/Purchases.android.kt b/core/src/androidMain/kotlin/com/revenuecat/purchases/kmp/Purchases.android.kt index 2a6cc39..4a54257 100644 --- a/core/src/androidMain/kotlin/com/revenuecat/purchases/kmp/Purchases.android.kt +++ b/core/src/androidMain/kotlin/com/revenuecat/purchases/kmp/Purchases.android.kt @@ -5,6 +5,8 @@ import com.revenuecat.purchases.common.PlatformInfo import com.revenuecat.purchases.getCustomerInfoWith import com.revenuecat.purchases.getOfferingsWith import com.revenuecat.purchases.getProductsWith +import com.revenuecat.purchases.kmp.PurchasesAreCompletedBy.MY_APP +import com.revenuecat.purchases.kmp.PurchasesAreCompletedBy.REVENUECAT import com.revenuecat.purchases.kmp.di.AndroidProvider import com.revenuecat.purchases.kmp.di.requireActivity import com.revenuecat.purchases.kmp.di.requireApplication @@ -67,10 +69,13 @@ public actual class Purchases private constructor(private val androidPurchases: with(configuration) { // Using the common configure() call allows us to pass PlatformInfo. commonConfigure( - AndroidProvider.requireApplication(), + context = AndroidProvider.requireApplication(), apiKey = apiKey, appUserID = appUserId, - observerMode = observerMode, + observerMode = when (configuration.purchasesAreCompletedBy) { + REVENUECAT -> false + MY_APP -> true + }, platformInfo = PlatformInfo( flavor = BuildKonfig.platformFlavor, version = frameworkVersion, @@ -98,8 +103,17 @@ public actual class Purchases private constructor(private val androidPurchases: AndroidDangerousSettings(autoSyncPurchases) } - - public actual var finishTransactions: Boolean by androidPurchases::finishTransactions + public actual var purchasesAreCompletedBy: PurchasesAreCompletedBy + get() = when (androidPurchases.finishTransactions) { + true -> REVENUECAT + false -> MY_APP + } + set(value) { + androidPurchases.finishTransactions = when (value) { + REVENUECAT -> true + MY_APP -> false + } + } public actual val appUserID: String by androidPurchases::appUserID @@ -121,7 +135,7 @@ public actual class Purchases private constructor(private val androidPurchases: onSuccess = { onSuccess(it) }, ) - public actual fun syncObserverModeAmazonPurchase( + public actual fun syncAmazonPurchase( productID: String, receiptID: String, amazonUserID: String, diff --git a/core/src/androidMain/kotlin/com/revenuecat/purchases/kmp/PurchasesAreCompletedBy.android.kt b/core/src/androidMain/kotlin/com/revenuecat/purchases/kmp/PurchasesAreCompletedBy.android.kt new file mode 100644 index 0000000..439359a --- /dev/null +++ b/core/src/androidMain/kotlin/com/revenuecat/purchases/kmp/PurchasesAreCompletedBy.android.kt @@ -0,0 +1,6 @@ +package com.revenuecat.purchases.kmp + +public actual enum class PurchasesAreCompletedBy { + REVENUECAT, + MY_APP, +} diff --git a/core/src/commonMain/kotlin/com/revenuecat/purchases/kmp/Purchases.kt b/core/src/commonMain/kotlin/com/revenuecat/purchases/kmp/Purchases.kt index 388eb03..6c6b36c 100644 --- a/core/src/commonMain/kotlin/com/revenuecat/purchases/kmp/Purchases.kt +++ b/core/src/commonMain/kotlin/com/revenuecat/purchases/kmp/Purchases.kt @@ -1,5 +1,7 @@ package com.revenuecat.purchases.kmp +import com.revenuecat.purchases.kmp.PurchasesAreCompletedBy.MY_APP +import com.revenuecat.purchases.kmp.PurchasesAreCompletedBy.REVENUECAT import com.revenuecat.purchases.kmp.models.BillingFeature import com.revenuecat.purchases.kmp.models.GoogleReplacementMode import com.revenuecat.purchases.kmp.models.PromotionalOffer @@ -92,10 +94,10 @@ public expect class Purchases { } /** - * Default to TRUE, set this to FALSE if you are consuming and acknowledging transactions - * outside of the Purchases SDK. + * Default to [REVENUECAT], set this to [MY_APP] if you are consuming and acknowledging + * transactions outside of the Purchases SDK. */ - public var finishTransactions: Boolean + public var purchasesAreCompletedBy: PurchasesAreCompletedBy /** * The passed in or generated app user ID. @@ -137,8 +139,9 @@ public expect class Purchases { ) /** - * This method will send a purchase to the RevenueCat backend. This function should only be - * called if you are in Amazon observer mode or performing a client side migration of your + * This method will send an Amazon purchase to the RevenueCat backend. This function should + * only be called if you have set [purchasesAreCompletedBy] to + * [MY_APP][PurchasesAreCompletedBy.MY_APP] or when performing a client side migration of your * current users to RevenueCat. * * The receipt IDs are cached if successfully posted so they are not posted more than once. @@ -150,7 +153,7 @@ public expect class Purchases { * @param [isoCurrencyCode] Product's currency code in ISO 4217 format. * @param [price] Product's price. */ - public fun syncObserverModeAmazonPurchase( + public fun syncAmazonPurchase( productID: String, receiptID: String, amazonUserID: String, diff --git a/core/src/commonMain/kotlin/com/revenuecat/purchases/kmp/PurchasesAreCompletedBy.kt b/core/src/commonMain/kotlin/com/revenuecat/purchases/kmp/PurchasesAreCompletedBy.kt new file mode 100644 index 0000000..80c82a8 --- /dev/null +++ b/core/src/commonMain/kotlin/com/revenuecat/purchases/kmp/PurchasesAreCompletedBy.kt @@ -0,0 +1,23 @@ +package com.revenuecat.purchases.kmp + +/** + * Modes for completing the purchase process. + */ +public expect enum class PurchasesAreCompletedBy { + /** + * RevenueCat will automatically acknowledge verified purchases. No action is required by you. + */ + REVENUECAT, + + /** + * RevenueCat will **not** automatically acknowledge any purchases. You will have to do so manually. + * + * **Note:** failing to acknowledge a purchase within 3 days will lead to Google Play automatically issuing a + * refund to the user. + * + * For more info, see + * [revenuecat.com](https://www.revenuecat.com/docs/migrating-to-revenuecat/sdk-or-not/finishing-transactions) and + * [developer.android.com](https://developer.android.com/google/play/billing/integrate#process). + */ + MY_APP, +} diff --git a/core/src/commonMain/kotlin/com/revenuecat/purchases/kmp/PurchasesConfiguration.kt b/core/src/commonMain/kotlin/com/revenuecat/purchases/kmp/PurchasesConfiguration.kt index ba10f23..ded23ff 100644 --- a/core/src/commonMain/kotlin/com/revenuecat/purchases/kmp/PurchasesConfiguration.kt +++ b/core/src/commonMain/kotlin/com/revenuecat/purchases/kmp/PurchasesConfiguration.kt @@ -1,5 +1,6 @@ package com.revenuecat.purchases.kmp +import com.revenuecat.purchases.kmp.PurchasesAreCompletedBy.REVENUECAT import com.revenuecat.purchases.kmp.PurchasesConfiguration.Builder import kotlin.jvm.JvmSynthetic @@ -10,7 +11,7 @@ import kotlin.jvm.JvmSynthetic public class PurchasesConfiguration private constructor( public val apiKey: String, public val appUserId: String?, - public val observerMode: Boolean, + public val purchasesAreCompletedBy: PurchasesAreCompletedBy, public val userDefaultsSuiteName: String?, public val showInAppMessagesAutomatically: Boolean, public val store: Store?, @@ -22,7 +23,7 @@ public class PurchasesConfiguration private constructor( "PurchasesConfiguration(" + "apiKey=$apiKey, " + "appUserId=$appUserId, " + - "observerMode=$observerMode, " + + "purchasesAreCompletedBy=$purchasesAreCompletedBy, " + "userDefaultsSuiteName=$userDefaultsSuiteName, " + "showInAppMessagesAutomatically=$showInAppMessagesAutomatically, " + "store=$store, " + @@ -42,7 +43,7 @@ public class PurchasesConfiguration private constructor( public var appUserId: String? = null @set:JvmSynthetic - public var observerMode: Boolean = false + public var purchasesAreCompletedBy: PurchasesAreCompletedBy = REVENUECAT @set:JvmSynthetic public var userDefaultsSuiteName: String? = null @@ -76,12 +77,23 @@ public class PurchasesConfiguration private constructor( apply { this.appUserId = appUserId } /** - * An optional boolean. Set this to TRUE if you have your own IAP implementation and - * want to use only RevenueCat's backend. Default is FALSE. If you are on Android and setting this to TRUE, - * you will have to acknowledge the purchases yourself. + * An optional setting. Set this to [MY_APP][PurchasesAreCompletedBy.MY_APP] if you have + * your own IAP + * implementation and want to use only RevenueCat's backend. Default is + * [REVENUECAT][PurchasesAreCompletedBy.REVENUECAT]. If you are on Android and setting this + * to [MY_APP][PurchasesAreCompletedBy.MY_APP], you will have to acknowledge the purchases + * yourself. + * + * **Note:** failing to acknowledge a purchase within 3 days will lead to Google Play + * automatically issuing a refund to the user. + * + * For more info, see + * [revenuecat.com](https://www.revenuecat.com/docs/migrating-to-revenuecat/sdk-or-not/finishing-transactions) + * and [developer.android.com](https://developer.android.com/google/play/billing/integrate#process). */ - public fun observerMode(observerMode: Boolean): Builder = - apply { this.observerMode = observerMode } + public fun purchasesAreCompletedBy( + purchasesAreCompletedBy: PurchasesAreCompletedBy + ): Builder = apply { this.purchasesAreCompletedBy = purchasesAreCompletedBy } /** * iOS-only, will be ignored for Android. Set this if you would like the RevenueCat SDK to @@ -147,7 +159,7 @@ public class PurchasesConfiguration private constructor( public fun build(): PurchasesConfiguration = PurchasesConfiguration( apiKey = apiKey, appUserId = appUserId, - observerMode = observerMode, + purchasesAreCompletedBy = purchasesAreCompletedBy, userDefaultsSuiteName = userDefaultsSuiteName, showInAppMessagesAutomatically = showInAppMessagesAutomatically, store = store, diff --git a/core/src/iosMain/kotlin/com/revenuecat/purchases/kmp/Purchases.ios.kt b/core/src/iosMain/kotlin/com/revenuecat/purchases/kmp/Purchases.ios.kt index f67dde1..5bf6bcd 100644 --- a/core/src/iosMain/kotlin/com/revenuecat/purchases/kmp/Purchases.ios.kt +++ b/core/src/iosMain/kotlin/com/revenuecat/purchases/kmp/Purchases.ios.kt @@ -6,6 +6,8 @@ import cocoapods.PurchasesHybridCommon.configureWithAPIKey import cocoapods.PurchasesHybridCommon.setAirshipChannelID import cocoapods.PurchasesHybridCommon.setOnesignalUserID import cocoapods.PurchasesHybridCommon.showStoreMessagesForTypes +import com.revenuecat.purchases.kmp.PurchasesAreCompletedBy.MY_APP +import com.revenuecat.purchases.kmp.PurchasesAreCompletedBy.REVENUECAT import com.revenuecat.purchases.kmp.models.BillingFeature import com.revenuecat.purchases.kmp.models.GoogleReplacementMode import com.revenuecat.purchases.kmp.models.PromotionalOffer @@ -62,7 +64,10 @@ public actual class Purchases private constructor(private val iosPurchases: IosP IosPurchases.configureWithAPIKey( apiKey = apiKey, appUserID = appUserId, - observerMode = observerMode, + observerMode = when (configuration.purchasesAreCompletedBy) { + REVENUECAT -> false + MY_APP -> true + }, userDefaultsSuiteName = userDefaultsSuiteName, platformFlavor = BuildKonfig.platformFlavor, platformFlavorVersion = frameworkVersion, @@ -96,10 +101,18 @@ public actual class Purchases private constructor(private val iosPurchases: IosP IosDangerousSettings(autoSyncPurchases) } - public actual var finishTransactions: Boolean - get() = iosPurchases.finishTransactions() + public actual var purchasesAreCompletedBy: PurchasesAreCompletedBy + get() = when (iosPurchases.finishTransactions()) { + true -> REVENUECAT + false -> MY_APP + } set(value) { - iosPurchases.setFinishTransactions(value) + iosPurchases.setFinishTransactions( + when (value) { + REVENUECAT -> true + MY_APP -> false + } + ) } public actual val appUserID: String @@ -123,7 +136,7 @@ public actual class Purchases private constructor(private val iosPurchases: IosP else onSuccess(customerInfo ?: error("Expected a non-null RCCustomerInfo")) } - public actual fun syncObserverModeAmazonPurchase( + public actual fun syncAmazonPurchase( productID: String, receiptID: String, amazonUserID: String, diff --git a/core/src/iosMain/kotlin/com/revenuecat/purchases/kmp/PurchasesAreCompletedBy.ios.kt b/core/src/iosMain/kotlin/com/revenuecat/purchases/kmp/PurchasesAreCompletedBy.ios.kt new file mode 100644 index 0000000..439359a --- /dev/null +++ b/core/src/iosMain/kotlin/com/revenuecat/purchases/kmp/PurchasesAreCompletedBy.ios.kt @@ -0,0 +1,6 @@ +package com.revenuecat.purchases.kmp + +public actual enum class PurchasesAreCompletedBy { + REVENUECAT, + MY_APP, +}