RevenueCat / purchases-android

Android in-app purchases and subscriptions made easy.
https://www.revenuecat.com/
MIT License
235 stars 45 forks source link

Fix non-consumables not getting acknowledged #1709

Closed vegaro closed 1 month ago

vegaro commented 1 month ago

After #1697 , we stopped consuming non-consumables if the backend indicates to not consume them. Non-consumables still need to be acknowledged, otherwise they get refunded, this PR fixes that.

For reference, https://developer.android.com/google/play/billing/integrate#non-consumable-products

RevenueCat-Danger-Bot commented 1 month ago
1 Message
:book: Size increase: 2.26 KB

Generated by :no_entry_sign: Danger

codecov[bot] commented 1 month ago

Codecov Report

Attention: Patch coverage is 85.71429% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 83.14%. Comparing base (33a4377) to head (b76d5e1).

Files Patch % Lines
.../com/revenuecat/purchases/google/BillingWrapper.kt 85.71% 0 Missing and 1 partial :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #1709 +/- ## ========================================== + Coverage 83.07% 83.14% +0.06% ========================================== Files 222 222 Lines 7581 7582 +1 Branches 1073 1072 -1 ========================================== + Hits 6298 6304 +6 + Misses 857 854 -3 + Partials 426 424 -2 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

vegaro commented 1 month ago

It is possible to consume after only acknowledging. But that made me think of something else, that it is that we are saving tokens in the cache even for non-consumables. That means that when calling queryPurchases, since that token is in the cache, we will post it to the backend, and we will never know if the product has been changed to be a consumable and needs to be consumed. The only way we will consume that purchase after being made a consumable is if the app is reinstalled (and the cache cleaned) or if the user restores purchases (where we don't check the token cache).

tonidero commented 1 month ago

Yeah that's a good point, I considered it but seems like an edge case to me. So this would affect devs that turn a non-consumable into a consumable and want the products to be consumed immediately. And for those, we can ask them to perform a restore as you said... Do you think we should support this use case?