The code which my client gave me was written by a previous developer. After referring to the docs and checking the source code I identified the cause for this.
The docs says:
If you are using the Version 3 API, you can also consume managed items within your application. You would typically implement consumption for items that can be purchased multiple times (such as in-game currency, fuel, or magic spells). Once purchased, a managed item cannot be purchased again until you consume the item, by sending a consumption request to Google Play.
The previous developer was actually consuming
the purchase which makes it available again for purchase. Since my InApp Purchase was Managed
there was no need to call consume
.
After I removed the call to consume the product
everything worked fine.
Here is the link from the docs.