Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue within BillingClient 4.0 - SkuDetails missing freeTrialPeriod #498

Closed
joshdholtz opened this issue Feb 25, 2022 · 5 comments
Closed
Labels

Comments

@joshdholtz
Copy link
Member

joshdholtz commented Feb 25, 2022

Google Issue Tracker 👉 https://issuetracker.google.com/issues/219799769?pli=1

There is currently an ongoing issue within BillingClient 4.0 where freeTrialPeriod is null which could cause issues within RevenueCat's Purchases Android.

This does appear to be inconsistent and fairly rare but could still happen.

We are actively working on getting finding somebody that can address this issue 💪

@vegaro
Copy link
Contributor

vegaro commented Mar 18, 2022

I am looking into this and there's something quite interesting. This is our current code in purchases-hybrid-common:

introductoryPricePeriod.mapPeriod()?.let { periodFields ->
            mapOf(
                "price" to introductoryPriceAmountMicros / 1000000.0,
                "priceString" to introductoryPrice,
                "period" to introductoryPricePeriod,
                "cycles" to introductoryPriceCycles
            ) + periodFields
        } ?: null

According to this comment RevenueCat/react-native-purchases#331 (comment), we send something like:

"introPrice": {"cycles": null, "period": null, "periodNumberOfUnits": null, "periodUnit": null, "price": null, "priceString": null}

If as we suspect, introductoryPrice, introductoryPricePeriod and introductoryPriceCycles can be returned as null by Google... Why does the response also have "periodUnit": null and "periodNumberOfUnits": null?. mapPeriod() does this:

return this.takeUnless { this == null || this.isBlank() }
        ?.let { PurchasesPeriod.parse(it) }
        ?.let { period ->
            when {
                period.years > 0 -> mapOf(
                    "periodUnit" to "YEAR",
                    "periodNumberOfUnits" to period.years
                )
                period.months > 0 -> mapOf(
                    "periodUnit" to "MONTH",
                    "periodNumberOfUnits" to period.months
                )
                period.days > 0 -> mapOf(
                    "periodUnit" to "DAY",
                    "periodNumberOfUnits" to period.days
                )
                else -> mapOf(
                    "periodUnit" to "DAY",
                    "periodNumberOfUnits" to 0
                )
            }
        }

There's no way that can return "periodUnit" to null, "periodNumberOfUnits" to null

🤔

@vegaro
Copy link
Contributor

vegaro commented Mar 18, 2022

Not only that, introductoryPricePeriod.mapPeriod() would give a NullPointerException if it were to be null

I just created a test in purchases-hybrid-common where I mocked mockSkuDetails.introductoryPrice to be null, using a Java class with a null constant:

            every { mockSkuDetails.introductoryPrice } returns Constants.aNull

And it crashes with the null pointer, so I think something else is going on here

@taquitos
Copy link
Contributor

@joshdholtz are there any updates here? I don't have permission to view the linked buginizer 😿

@vegaro vegaro removed the bug label Aug 25, 2023
@NachoSoto
Copy link
Contributor

BC4 👋🏻

Copy link

github-actions bot commented Nov 3, 2023

This issue has been automatically locked due to no recent activity after it was closed. Please open a new issue for related reports.

@github-actions github-actions bot locked and limited conversation to collaborators Nov 3, 2023
@vegaro vegaro unpinned this issue Mar 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants