Here is the basic flow for purchasing a consumable in-app product:
Launch a purchase flow with a getBuyIntent call
Get a response Bundlefrom Google Play indicating if the purchase completed successfully.
If the purchase was successful, consume the purchase by making a consumePurchase call.
Get a response code from Google Play indicating if the consumption completed successfully.
If the consumption was successful, provision the product in your application.
Subsequently, when the user starts up or logs in to your application, you should check if the user owns any outstanding consumable in-app products; if so, make sure to consume and provision those items. Here's the recommended application startup flow if you implement consumable in-app products in your application:
Send a getPurchases request to query the owned in-app products for the user.
If there are any consumable in-app products, consume the items by calling consumePurchase. This step is necessary because the application might have completed the purchase order for the consumable item, but stopped or got disconnected before the application had the chance to send a consumption request.
Get a response code from Google Play indicating if the consumption completed successfully.
If the consumption was successful, provision the product in your application.