react-native-iap: BAD CONSUMPTION FUNCTIONALITY!!
refreshAllItems is very poorly named!! The implementation uses fetchHistory on iOS which is non-mutative operation, and uses consumeItem on Android, which destroys purchase history! This is either very bad naming, or very poor purchase flow behaviour! I’ll nominate it for both!
I can’t think of a single case where I’d want to immediately consume all purchased items. What I would expect is that refreshAllItems re-synchronizes the device purchase history with Google Play and the App Store (ie. getPurchases) – this should absolutely be changed so more people don’t make this mistake.
I even checked the source code to make sure I had the right idea about what was going on, but I got as far as getPurchases on the Android side and stopped reading. I didn’t notice this module was automatically consuming those purchases!!
Here’s my suggestion for a fix: rename refreshAllItems to refreshPurchases, and ONLY fetch the user’s purchase history. Do NOT consume items automatically. Consuming behaviour is it’s own flow which should be managed by the application developer, ie explicitly calling consumeItem(...) or something similar.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 1
- Comments: 15 (13 by maintainers)
@dooboolab No worries, I know it can be hard to balance personal and day job projects. Will start by spending some time reading through the codebase, @lwansbrough fork, and currently reported issues.
@javier-artiles You can see the remaining issues in this repo. Testing local receipt validation might be useful too. Also, before all that, we need to test @lwansbrough code and update readme and announce users for migration who’s already using our module. I am running out of time and testing is bit delayed. Sorry for that.
@dooboolab I’ve taken my somewhat rough criticism and have turned it into constructive change! Here’s my work so far: https://github.com/TrackerNetwork/react-native-iap/commit/25e7e9b278cd02e9333590252e0c9e0684ed7182
I’ve refactored a considerable portion of the code base (very much a work in progress still) with the intent of making it more stable and more readable. I’ve also cleaned up the API a bit (removed platform specific functionality) in favour of an easier to maintain core set of functionality.
Thanks for your response + for confirming my suspicions. Unfortunately I think there may be some lasting impact on a few thousand of my users. 😦
@lwansbrough Hi! thank you for really important testing. As you can see we are out of time just focusing on this module. However, I am trying hard to maintain this so others can use
in-app-purchasefunctionality easy as possible. Thank you for the link, I’ve found out that they implemented new api since2017.05forgetPurchaseHistory. I’ve just changed method namerefreshAllItemstofetchHistory, I’ve found out their characteristic was totally different since ios control the purchase process itself. Also if you look in the readme, there isgetPurchasedItemsAndroidmethod for android which query for purchased items in android.Could you please try this commit in
devbranch which I’ve just updated? Since I may take some time setting the testing environment, I wish I can hear from you if this is what you want.Thank you again for the help. If you are fine with this commit, I’ll publish this to
0.2.17.