diff --git a/facebook-core/src/main/java/com/facebook/appevents/iap/InAppPurchaseAutoLogger.kt b/facebook-core/src/main/java/com/facebook/appevents/iap/InAppPurchaseAutoLogger.kt index 1851a7e6ab..dc63efd19e 100644 --- a/facebook-core/src/main/java/com/facebook/appevents/iap/InAppPurchaseAutoLogger.kt +++ b/facebook-core/src/main/java/com/facebook/appevents/iap/InAppPurchaseAutoLogger.kt @@ -13,6 +13,8 @@ import com.facebook.appevents.iap.InAppPurchaseUtils.BillingClientVersion.V5_V7 import com.facebook.appevents.iap.InAppPurchaseUtils.IAPProductType.INAPP import android.content.Context import androidx.annotation.RestrictTo +import com.facebook.appevents.iap.InAppPurchaseLoggerManager.getIsFirstAppLaunch +import com.facebook.appevents.iap.InAppPurchaseLoggerManager.setAppHasBeenLaunched import com.facebook.appevents.iap.InAppPurchaseUtils.IAPProductType.SUBS import com.facebook.appevents.integrity.ProtectedModeManager import com.facebook.internal.FeatureManager @@ -46,7 +48,7 @@ object InAppPurchaseAutoLogger { failedToCreateWrapper.set(true) return } - + if (isEnabled(FeatureManager.Feature.AndroidIAPSubscriptionAutoLogging) && (!ProtectedModeManager.isEnabled() || billingClientVersion == V2_V4) ) { @@ -66,20 +68,23 @@ object InAppPurchaseAutoLogger { billingClientVersion: InAppPurchaseUtils.BillingClientVersion, packageName: String ) { + val isFirstAppLaunch = getIsFirstAppLaunch() if (billingClientVersion == V2_V4) { InAppPurchaseLoggerManager.filterPurchaseLogging( InAppPurchaseBillingClientWrapperV2V4.iapPurchaseDetailsMap, InAppPurchaseBillingClientWrapperV2V4.skuDetailsMap, false, packageName, - billingClientVersion + billingClientVersion, + isFirstAppLaunch ) InAppPurchaseLoggerManager.filterPurchaseLogging( InAppPurchaseBillingClientWrapperV2V4.subsPurchaseDetailsMap, InAppPurchaseBillingClientWrapperV2V4.skuDetailsMap, true, packageName, - billingClientVersion + billingClientVersion, + isFirstAppLaunch ) InAppPurchaseBillingClientWrapperV2V4.iapPurchaseDetailsMap.clear() InAppPurchaseBillingClientWrapperV2V4.subsPurchaseDetailsMap.clear() @@ -89,17 +94,22 @@ object InAppPurchaseAutoLogger { InAppPurchaseBillingClientWrapperV5V7.productDetailsMap, false, packageName, - billingClientVersion + billingClientVersion, + isFirstAppLaunch ) InAppPurchaseLoggerManager.filterPurchaseLogging( InAppPurchaseBillingClientWrapperV5V7.subsPurchaseDetailsMap, InAppPurchaseBillingClientWrapperV5V7.productDetailsMap, true, packageName, - billingClientVersion + billingClientVersion, + isFirstAppLaunch ) InAppPurchaseBillingClientWrapperV5V7.iapPurchaseDetailsMap.clear() InAppPurchaseBillingClientWrapperV5V7.subsPurchaseDetailsMap.clear() } + if (isFirstAppLaunch) { + setAppHasBeenLaunched() + } } } diff --git a/facebook-core/src/main/java/com/facebook/appevents/iap/InAppPurchaseLoggerManager.kt b/facebook-core/src/main/java/com/facebook/appevents/iap/InAppPurchaseLoggerManager.kt index ca0721b95c..f38647f317 100644 --- a/facebook-core/src/main/java/com/facebook/appevents/iap/InAppPurchaseLoggerManager.kt +++ b/facebook-core/src/main/java/com/facebook/appevents/iap/InAppPurchaseLoggerManager.kt @@ -16,11 +16,11 @@ import com.facebook.FacebookSdk.getApplicationContext import com.facebook.appevents.internal.AutomaticAnalyticsLogger.logPurchase import com.facebook.appevents.internal.Constants import com.facebook.internal.instrument.crashshield.AutoHandleExceptions -import java.lang.Exception import java.util.HashMap import java.util.concurrent.ConcurrentHashMap import java.util.concurrent.CopyOnWriteArraySet import org.json.JSONObject +import kotlin.Exception import kotlin.math.max import kotlin.math.min @@ -38,9 +38,10 @@ object InAppPurchaseLoggerManager { private const val IAP_CACHE_GPBLV2V7 = "com.facebook.internal.iap.IAP_CACHE_GPBLV2V7" private const val CACHED_PURCHASES_KEY = "PURCHASE_DETAILS_SET" + private const val APP_HAS_BEEN_LAUNCHED_KEY = "APP_HAS_BEEN_LAUNCHED_KEY" private const val TIME_OF_LAST_LOGGED_PURCHASE_KEY = "TIME_OF_LAST_LOGGED_PURCHASE" private const val TIME_OF_LAST_LOGGED_SUBSCRIPTION_KEY = "TIME_OF_LAST_LOGGED_SUBSCRIPTION" - private var firstTimeLoggingIAP = false + private var oldCacheHistoryExists = false private fun readOldCaches() { // clear cached purchases logged by lib 1 @@ -53,14 +54,13 @@ object InAppPurchaseLoggerManager { cachedSkuSharedPref.edit().clear().apply() cachedPurchaseSharedPref.edit().clear().apply() - sharedPreferences = getApplicationContext().getSharedPreferences( IAP_CACHE_OLD, Context.MODE_PRIVATE ) if (sharedPreferences.contains(CACHED_PURCHASES_KEY)) { - firstTimeLoggingIAP = true + oldCacheHistoryExists = true cachedPurchaseSet.addAll( sharedPreferences.getStringSet(CACHED_PURCHASES_KEY, hashSetOf()) ?: hashSetOf() ) @@ -70,30 +70,56 @@ object InAppPurchaseLoggerManager { val splitPurchase = purchaseHistory.split(";", limit = 2) cachedPurchaseMap[splitPurchase[0]] = splitPurchase[1].toLong() } - } + // clear cached purchases logged by lib2 - lib4 in the old implementation of IAP auto-logging sharedPreferences.edit().clear().apply() } + @JvmStatic + fun getIsFirstAppLaunch(): Boolean { + val iapCache = + getApplicationContext().getSharedPreferences( + IAP_CACHE_GPBLV2V7, + Context.MODE_PRIVATE + ) + return !iapCache.contains(APP_HAS_BEEN_LAUNCHED_KEY) + } + + @JvmStatic + fun setAppHasBeenLaunched() { + val iapCache = + getApplicationContext().getSharedPreferences( + IAP_CACHE_GPBLV2V7, + Context.MODE_PRIVATE + ) + try { + iapCache.edit() + .putBoolean(APP_HAS_BEEN_LAUNCHED_KEY, true) + .apply() + } catch (e: Exception) { + val x = 1 + } + } + @JvmStatic fun filterPurchaseLogging( purchaseDetailsMap: MutableMap, skuDetailsMap: Map, isSubscription: Boolean, packageName: String, - billingClientVersion: InAppPurchaseUtils.BillingClientVersion - + billingClientVersion: InAppPurchaseUtils.BillingClientVersion, + isFirstAppLaunch: Boolean ) { readOldCaches() - val loggingReadyMap: Map = - constructLoggingReadyMap( - cacheDeDupPurchase(purchaseDetailsMap, isSubscription), - skuDetailsMap, - packageName - ) - logPurchases(loggingReadyMap, isSubscription, billingClientVersion) + val deduped = cacheDeDupPurchase(purchaseDetailsMap, isSubscription) + val loggingReady = constructLoggingReadyMap( + deduped, + skuDetailsMap, + packageName + ) + logPurchases(loggingReady, isSubscription, billingClientVersion, isFirstAppLaunch) } @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE) @@ -111,11 +137,19 @@ object InAppPurchaseLoggerManager { private fun logPurchases( purchaseDetailsMap: Map, isSubscription: Boolean, - billingClientVersion: InAppPurchaseUtils.BillingClientVersion + billingClientVersion: InAppPurchaseUtils.BillingClientVersion, + isFirstAppLaunch: Boolean ) { for ((purchaseDetails, skuDetails) in purchaseDetailsMap) { - logPurchase(purchaseDetails, skuDetails, isSubscription, billingClientVersion) + logPurchase( + purchaseDetails, + skuDetails, + isSubscription, + billingClientVersion, + isFirstAppLaunch + ) } + } @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE) @@ -130,7 +164,7 @@ object InAppPurchaseLoggerManager { ) var timeOfLatestNewlyLoggedPurchase: Long = 0 var timeOfLastLoggedPurchase: Long = 0 - if (firstTimeLoggingIAP) { + if (oldCacheHistoryExists) { timeOfLastLoggedPurchase = getTimeOfNewestPurchaseInOldCache() } else { if (isSubscription) { @@ -159,7 +193,7 @@ object InAppPurchaseLoggerManager { /* swallow */ } } - if (firstTimeLoggingIAP) { + if (oldCacheHistoryExists) { iapCache.edit() .putLong(TIME_OF_LAST_LOGGED_SUBSCRIPTION_KEY, timeOfLatestNewlyLoggedPurchase) .apply() @@ -177,7 +211,7 @@ object InAppPurchaseLoggerManager { .apply() } } - firstTimeLoggingIAP = false + oldCacheHistoryExists = false return HashMap(purchaseDetailsMap) } diff --git a/facebook-core/src/main/java/com/facebook/appevents/internal/AutomaticAnalyticsLogger.kt b/facebook-core/src/main/java/com/facebook/appevents/internal/AutomaticAnalyticsLogger.kt index 48dc77fa2e..4918ca2275 100644 --- a/facebook-core/src/main/java/com/facebook/appevents/internal/AutomaticAnalyticsLogger.kt +++ b/facebook-core/src/main/java/com/facebook/appevents/internal/AutomaticAnalyticsLogger.kt @@ -87,7 +87,8 @@ object AutomaticAnalyticsLogger { purchase: String, skuDetails: String, isSubscription: Boolean, - billingClientVersion: InAppPurchaseUtils.BillingClientVersion? + billingClientVersion: InAppPurchaseUtils.BillingClientVersion?, + isFirstAppLaunch: Boolean = false ) { if (!isImplicitPurchaseLoggingEnabled()) { return @@ -104,14 +105,20 @@ object AutomaticAnalyticsLogger { FacebookSdk.getApplicationId(), false ) - var eventName = AppEventsConstants.EVENT_NAME_PURCHASED - if (logAsSubs) { - eventName = - if (InAppPurchaseEventManager.hasFreeTrialPeirod(skuDetails)) { - AppEventsConstants.EVENT_NAME_START_TRIAL - } else { - AppEventsConstants.EVENT_NAME_SUBSCRIBE - } + val eventName = if (logAsSubs) { + if (isFirstAppLaunch) { + Constants.EVENT_NAME_SUBSCRIPTION_RESTORED + } else if (InAppPurchaseEventManager.hasFreeTrialPeirod(skuDetails)) { + AppEventsConstants.EVENT_NAME_START_TRIAL + } else { + AppEventsConstants.EVENT_NAME_SUBSCRIBE + } + } else { + if (isFirstAppLaunch) { + Constants.EVENT_NAME_PURCHASE_RESTORED + } else { + AppEventsConstants.EVENT_NAME_PURCHASED + } } val dedupeParameters = if (isSubscription && @@ -131,7 +138,7 @@ object AutomaticAnalyticsLogger { ) loggingParameters[0].param = combinedParameters ?: Bundle() - if (logAsSubs) { + if (eventName != AppEventsConstants.EVENT_NAME_PURCHASED) { internalAppEventsLogger.logEventImplicitly( eventName, loggingParameters[0].purchaseAmount, diff --git a/facebook-core/src/main/java/com/facebook/appevents/internal/Constants.kt b/facebook-core/src/main/java/com/facebook/appevents/internal/Constants.kt index d237a646cd..a5c497a90f 100644 --- a/facebook-core/src/main/java/com/facebook/appevents/internal/Constants.kt +++ b/facebook-core/src/main/java/com/facebook/appevents/internal/Constants.kt @@ -11,6 +11,8 @@ package com.facebook.appevents.internal object Constants { const val LOG_TIME_APP_EVENT_KEY = "_logTime" const val EVENT_NAME_EVENT_KEY = "_eventName" + const val EVENT_NAME_PURCHASE_RESTORED = "fb_mobile_purchase_restored" + const val EVENT_NAME_SUBSCRIPTION_RESTORED = "SubscriptionRestore" // The following are for Automatic Analytics events and parameters const val AA_TIME_SPENT_EVENT_NAME = "fb_aa_time_spent_on_view" diff --git a/facebook-core/src/test/kotlin/com/facebook/appevents/iap/InAppPurchaseAutoLoggerTest.kt b/facebook-core/src/test/kotlin/com/facebook/appevents/iap/InAppPurchaseAutoLoggerTest.kt index 9704bb2736..7c0e1d91f4 100644 --- a/facebook-core/src/test/kotlin/com/facebook/appevents/iap/InAppPurchaseAutoLoggerTest.kt +++ b/facebook-core/src/test/kotlin/com/facebook/appevents/iap/InAppPurchaseAutoLoggerTest.kt @@ -134,7 +134,8 @@ class InAppPurchaseAutoLoggerTest : FacebookPowerMockTestCase() { any(), any(), any(), - any() + any(), + any(), ) ).thenAnswer { logPurchaseCallTimes++ @@ -196,6 +197,7 @@ class InAppPurchaseAutoLoggerTest : FacebookPowerMockTestCase() { any(), any(), any(), + any(), any() ) ).thenAnswer { @@ -245,6 +247,7 @@ class InAppPurchaseAutoLoggerTest : FacebookPowerMockTestCase() { any(), any(), any(), + any(), any() ) ).thenAnswer { @@ -308,7 +311,8 @@ class InAppPurchaseAutoLoggerTest : FacebookPowerMockTestCase() { any(), any(), any(), - any() + any(), + any(), ) ).thenAnswer { logPurchaseCallTimes++ @@ -369,6 +373,7 @@ class InAppPurchaseAutoLoggerTest : FacebookPowerMockTestCase() { any(), any(), any(), + any(), any() ) ).thenAnswer { diff --git a/facebook-core/src/test/kotlin/com/facebook/appevents/iap/InAppPurchaseLoggerManagerTest.kt b/facebook-core/src/test/kotlin/com/facebook/appevents/iap/InAppPurchaseLoggerManagerTest.kt index 9a914eb66d..0041120855 100644 --- a/facebook-core/src/test/kotlin/com/facebook/appevents/iap/InAppPurchaseLoggerManagerTest.kt +++ b/facebook-core/src/test/kotlin/com/facebook/appevents/iap/InAppPurchaseLoggerManagerTest.kt @@ -99,7 +99,7 @@ class InAppPurchaseLoggerManagerTest : FacebookPowerMockTestCase() { ) Whitebox.setInternalState( InAppPurchaseLoggerManager::class.java, - "firstTimeLoggingIAP", + "oldCacheHistoryExists", true ) @@ -109,7 +109,7 @@ class InAppPurchaseLoggerManagerTest : FacebookPowerMockTestCase() { Assertions.assertThat( Whitebox.getInternalState( InAppPurchaseLoggerManager::class.java, - "firstTimeLoggingIAP" + "oldCacheHistoryExists" ) as Boolean ).isFalse() @@ -144,7 +144,7 @@ class InAppPurchaseLoggerManagerTest : FacebookPowerMockTestCase() { ) Whitebox.setInternalState( InAppPurchaseLoggerManager::class.java, - "firstTimeLoggingIAP", + "oldCacheHistoryExists", true ) @@ -153,7 +153,7 @@ class InAppPurchaseLoggerManagerTest : FacebookPowerMockTestCase() { Assertions.assertThat( Whitebox.getInternalState( InAppPurchaseLoggerManager::class.java, - "firstTimeLoggingIAP" + "oldCacheHistoryExists" ) as Boolean ).isFalse() @@ -188,7 +188,7 @@ class InAppPurchaseLoggerManagerTest : FacebookPowerMockTestCase() { ) Whitebox.setInternalState( InAppPurchaseLoggerManager::class.java, - "firstTimeLoggingIAP", + "oldCacheHistoryExists", true ) @@ -197,7 +197,7 @@ class InAppPurchaseLoggerManagerTest : FacebookPowerMockTestCase() { Assertions.assertThat( Whitebox.getInternalState( InAppPurchaseLoggerManager::class.java, - "firstTimeLoggingIAP" + "oldCacheHistoryExists" ) as Boolean ).isFalse() @@ -224,7 +224,7 @@ class InAppPurchaseLoggerManagerTest : FacebookPowerMockTestCase() { Whitebox.setInternalState( InAppPurchaseLoggerManager::class.java, - "firstTimeLoggingIAP", + "oldCacheHistoryExists", false ) @@ -234,7 +234,7 @@ class InAppPurchaseLoggerManagerTest : FacebookPowerMockTestCase() { Assertions.assertThat( Whitebox.getInternalState( InAppPurchaseLoggerManager::class.java, - "firstTimeLoggingIAP" + "oldCacheHistoryExists" ) as Boolean ).isFalse() @@ -261,7 +261,7 @@ class InAppPurchaseLoggerManagerTest : FacebookPowerMockTestCase() { Whitebox.setInternalState( InAppPurchaseLoggerManager::class.java, - "firstTimeLoggingIAP", + "oldCacheHistoryExists", false ) @@ -271,7 +271,7 @@ class InAppPurchaseLoggerManagerTest : FacebookPowerMockTestCase() { Assertions.assertThat( Whitebox.getInternalState( InAppPurchaseLoggerManager::class.java, - "firstTimeLoggingIAP" + "oldCacheHistoryExists" ) as Boolean ).isFalse() @@ -306,7 +306,7 @@ class InAppPurchaseLoggerManagerTest : FacebookPowerMockTestCase() { ) Whitebox.setInternalState( InAppPurchaseLoggerManager::class.java, - "firstTimeLoggingIAP", + "oldCacheHistoryExists", true ) @@ -316,7 +316,7 @@ class InAppPurchaseLoggerManagerTest : FacebookPowerMockTestCase() { Assertions.assertThat( Whitebox.getInternalState( InAppPurchaseLoggerManager::class.java, - "firstTimeLoggingIAP" + "oldCacheHistoryExists" ) as Boolean ).isFalse() @@ -351,7 +351,7 @@ class InAppPurchaseLoggerManagerTest : FacebookPowerMockTestCase() { ) Whitebox.setInternalState( InAppPurchaseLoggerManager::class.java, - "firstTimeLoggingIAP", + "oldCacheHistoryExists", true ) @@ -360,7 +360,7 @@ class InAppPurchaseLoggerManagerTest : FacebookPowerMockTestCase() { Assertions.assertThat( Whitebox.getInternalState( InAppPurchaseLoggerManager::class.java, - "firstTimeLoggingIAP" + "oldCacheHistoryExists" ) as Boolean ).isFalse() @@ -387,7 +387,7 @@ class InAppPurchaseLoggerManagerTest : FacebookPowerMockTestCase() { Whitebox.setInternalState( InAppPurchaseLoggerManager::class.java, - "firstTimeLoggingIAP", + "oldCacheHistoryExists", false ) @@ -397,7 +397,7 @@ class InAppPurchaseLoggerManagerTest : FacebookPowerMockTestCase() { Assertions.assertThat( Whitebox.getInternalState( InAppPurchaseLoggerManager::class.java, - "firstTimeLoggingIAP" + "oldCacheHistoryExists" ) as Boolean ).isFalse() @@ -424,7 +424,7 @@ class InAppPurchaseLoggerManagerTest : FacebookPowerMockTestCase() { Whitebox.setInternalState( InAppPurchaseLoggerManager::class.java, - "firstTimeLoggingIAP", + "oldCacheHistoryExists", false ) @@ -434,7 +434,7 @@ class InAppPurchaseLoggerManagerTest : FacebookPowerMockTestCase() { Assertions.assertThat( Whitebox.getInternalState( InAppPurchaseLoggerManager::class.java, - "firstTimeLoggingIAP" + "oldCacheHistoryExists" ) as Boolean ).isFalse() diff --git a/facebook-core/src/test/kotlin/com/facebook/appevents/internal/AutomaticAnalyticsLoggerTest.kt b/facebook-core/src/test/kotlin/com/facebook/appevents/internal/AutomaticAnalyticsLoggerTest.kt index 50c41e8725..2fde361eb2 100644 --- a/facebook-core/src/test/kotlin/com/facebook/appevents/internal/AutomaticAnalyticsLoggerTest.kt +++ b/facebook-core/src/test/kotlin/com/facebook/appevents/internal/AutomaticAnalyticsLoggerTest.kt @@ -441,6 +441,58 @@ class AutomaticAnalyticsLoggerTest : FacebookPowerMockTestCase() { ).isEqualTo("GPBL.5.1.0") } + @Test + fun `test log subscription restored on first app launch`() { + whenever(FacebookSdk.getAutoLogAppEventsEnabled()).thenReturn(true) + AutomaticAnalyticsLogger.logPurchase( + subscriptionPurchase, + subscriptionDetailsGPBLV5V7, + true, + InAppPurchaseUtils.BillingClientVersion.V5_V7, + true + ) + verify(mockInternalAppEventsLogger) + .logEventImplicitly( + eq(Constants.EVENT_NAME_SUBSCRIPTION_RESTORED), + any(), + any(), + any() + ) + + Assertions.assertThat(bundle).isNotNull + Assertions.assertThat(bundle?.getCharSequence(Constants.IAP_AUTOLOG_IMPLEMENTATION)) + .isEqualTo(InAppPurchaseUtils.BillingClientVersion.V5_V7.type) + Assertions.assertThat(bundle?.getCharSequence(Constants.IAP_PRODUCT_ID)).isEqualTo("id123") + Assertions.assertThat(bundle?.getCharSequence(Constants.IAP_PURCHASE_TIME)) + .isEqualTo("12345") + Assertions.assertThat(bundle?.getCharSequence(Constants.IAP_PURCHASE_TOKEN)) + .isEqualTo("token123") + Assertions.assertThat(bundle?.getCharSequence(Constants.IAP_PACKAGE_NAME)) + .isEqualTo("examplePackageName") + Assertions.assertThat(bundle?.getCharSequence(Constants.IAP_PRODUCT_TITLE)) + .isEqualTo("ExampleTitle") + Assertions.assertThat(bundle?.getCharSequence(Constants.IAP_PRODUCT_DESCRIPTION)) + .isEqualTo("Exampledescription.") + Assertions.assertThat(bundle?.getCharSequence(Constants.IAP_PRODUCT_TYPE)) + .isEqualTo("subs") + Assertions.assertThat(bundle?.getCharSequence(Constants.IAP_SUBSCRIPTION_AUTORENEWING)) + .isEqualTo("true") + Assertions.assertThat(bundle?.getCharSequence(Constants.IAP_SUBSCRIPTION_PERIOD)) + .isEqualTo("P2W") + val basePlanId = bundle?.getCharSequence(Constants.IAP_BASE_PLAN) + val validBasePlan = basePlanId == "baseplanId" || basePlanId == "basePlanId2" + Assertions.assertThat(validBasePlan) + .isTrue() + Assertions.assertThat(currency).isEqualTo(Currency.getInstance("USD")) + Assertions.assertThat(amount).isEqualTo(BigDecimal(3.99)) + Assertions.assertThat(eventName).isEqualTo(Constants.EVENT_NAME_SUBSCRIPTION_RESTORED) + Assertions.assertThat( + bundle?.getCharSequence( + Constants.IAP_BILLING_LIBRARY_VERSION, + ) + ).isEqualTo("GPBL.5.1.0") + } + @Test fun `test actual and test dedupe implicit purchase with GPBL v5 - v7`() { whenever(FeatureManager.isEnabled(FeatureManager.Feature.AndroidManualImplicitPurchaseDedupe)) @@ -906,6 +958,49 @@ class AutomaticAnalyticsLoggerTest : FacebookPowerMockTestCase() { } + @Test + fun `test log purchase restored event`() { + AutomaticAnalyticsLogger.logPurchase( + oneTimePurchase, + oneTimePurchaseDetailsGPBLV5V7, + false, + InAppPurchaseUtils.BillingClientVersion.V5_V7, + true + ) + verify(mockInternalAppEventsLogger) + .logEventImplicitly( + eq(Constants.EVENT_NAME_PURCHASE_RESTORED), + any(), + any(), + any() + ) + Assertions.assertThat(bundle).isNotNull + Assertions.assertThat(bundle?.getCharSequence(Constants.IAP_AUTOLOG_IMPLEMENTATION)) + .isEqualTo(InAppPurchaseUtils.BillingClientVersion.V5_V7.type) + Assertions.assertThat(bundle?.getCharSequence(Constants.IAP_PRODUCT_ID)).isEqualTo("id123") + Assertions.assertThat(bundle?.getCharSequence(Constants.IAP_PURCHASE_TIME)) + .isEqualTo("12345") + Assertions.assertThat(bundle?.getCharSequence(Constants.IAP_PURCHASE_TOKEN)) + .isEqualTo("token123") + Assertions.assertThat(bundle?.getCharSequence(Constants.IAP_PACKAGE_NAME)) + .isEqualTo("examplePackageName") + Assertions.assertThat(bundle?.getCharSequence(Constants.IAP_PRODUCT_TITLE)) + .isEqualTo("ExampleTitle") + Assertions.assertThat(bundle?.getCharSequence(Constants.IAP_PRODUCT_DESCRIPTION)) + .isEqualTo("Exampledescription.") + Assertions.assertThat(bundle?.getCharSequence(Constants.IAP_PRODUCT_TYPE)) + .isEqualTo("inapp") + Assertions.assertThat(currency).isEqualTo(Currency.getInstance("USD")) + Assertions.assertThat(amount).isEqualTo(BigDecimal(12)) + Assertions.assertThat(eventName).isEqualTo(Constants.EVENT_NAME_PURCHASE_RESTORED) + Assertions.assertThat( + bundle?.getCharSequence( + Constants.IAP_BILLING_LIBRARY_VERSION, + ) + ).isEqualTo("GPBL.5.1.0") + + } + @Test fun `test is implicit purchase logging enabled when autoLogAppEvent Disable`() { whenever(FacebookSdk.getAutoLogAppEventsEnabled()).thenReturn(false)