-
-
Notifications
You must be signed in to change notification settings - Fork 659
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
Fix/avoid blindly consuming success purchases #1085
Fix/avoid blindly consuming success purchases #1085
Conversation
… throwing non-catchable promise
If the purchase is really pending, nothing will happen (error). Otherwise, the Play Store cache will be force updated
7d20b56
to
df3e055
Compare
TODO: update README |
…PendingAndroid usage in readme
…n & flushFailedPurchasesCachedA
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is so great to see! Let's see how it goes.
Sorry for the delayed review 🙏
Migrating to |
The issue
I noticed that using
consumeAllItemsAndroid
is pretty dangerous in non-dev environnement:If a purchase becomes successful while the app is offline or killed, then calling
consumeAllItemsAndroid
will consume the successful purchase without ever notifying the host app, preventing the purchased product from being delivered (although it is billed)However
consumeAllItemsAndroid
still appears to be pretty useful in some prod cases:When a pending payment fails:
The only way (that I am aware of) to force the cache refresh is to try to consume the pending purchase. You would then get a
BillingResponseCode.ITEM_NOT_OWNED
error, and the item is available for purchase again. (credit to this post)This fix was already suggested in some issues: #126 (comment)
The solution suggested in this PR
We should expose a method to flush all failed purchases that are still - wrongly - marked as pending.
It would simply fetch all pending purchases, and try to consume then individually:
BillingResponseCode.DEVELOPER_ERROR
BillingResponseCode.ITEM_NOT_OWNED
Happy to get your feedback on the implementation/naming/...
I am not a big fan of the "callback hell" of the readme. I guess migrating the example/doc to hooks would help but that a subject for another PR
Worthy discussion:
initConnection
)?