1
votes

In my android games, i have in app purchase that sell multiple item at once, i.e. Get 5000 coins + remove ads. It means that i have consumable and non consumable item at once. The problem is about restoring purchases. I know i can restore non consumable purchase, but since my IAP is consist both consumable and non consumable, i am having trouble restoring the purchase , because i will consume the product.

Is there a way to retrieve purchase details of an item once the consumed is completed?

2

2 Answers

4
votes

Just create an additional consumable item for purchasing additional coins beyond the first 5,000, and consume that one as usual, immediately after it is purchased, recording the 5,000 coin increment yourself, just as is done in the TrivialDrive IAB example.

When the initial purchase of your combined remove ads/Get 5,000 coins item is made, do not consume that item - treat it as non-consumable - but treat the purchase event itself as a one-time trigger for performing the same logic as you would when consuming your "buy additional 5,000 coins" item.

Remember that "consumable" and "non-consumable" items are not different from one another so far as the Google side of this process is concerned. They are consumable or non-consumable only by virtue of the decision made in your code to consume them and record the increments to consumable resources internally, or to leave them there as a permanent record of the fact that the purchase has occurred. Leaving the item there makes it visible on all user devices that support IAB, whereas the consumable items must be recorded (and shared between devices) by other means (e.g., in your app's own database in the cloud).

So, an alternative to the above would be to immediately consume the purchase of the remove ads / add 5,000 coins item, and record that ads are permanently removed, and that the user has 5,000 coins, in your own database. Then, that item could be re-purchased by the user, with the turning off of ads as a redundant no-op, and only the 5,000 coin increment being recorded.

But that second approach would only confuse your users, because the item would still be called "Remove ads/ get 5,000 coins," even after ads had already been removed. Also, the approach I've outlined at the start ofthis answer would allow you to create any number of coin purchase items, with not only 5,000 coins, but other amounts, as well.

1
votes

First, In In-app billing V3, you can consume a managed item. Basically, you shouldn't be using any un-managed items in V3. Create a managed item, purchase it and consume it. if the result code for consume call is BILLING_RESULT_OK, provide the benefits to the user.

Coming to your question, It's your responsibility to track and manage products if you consume it.

EDIT:

Another way you can try is, create 4 iap items for the 4 buttons. Keep a track in your app for all iap items which are responsible for unlocking the ads. when user clicks on the button, check respective iap item is already owned or not using getSkuDetails(). If yes, consume it and purchase it. if not, directly purchase it (unlock ads if the iap item is responsible to unlocks ads). Don't consume the iap item now.

In oncreate(), check all owned items using getSkuDetails(). If any one of the owned items is responsible to unlock ads, and if the ads are not already unlocked, unlock ads(restore).