Consuming purchases
Some purchases are used to indicate additional features that are not initially available to the user. Other products are consumable products and only provide a once-off feature, which will have to be re-purchased to be re-used. These products are consumable products and only provide a once-off feature.
How to do it...
Some products are meant to be consumed, or exhausted, when used; the user is required to purchase them again before they can be reused:
- To consume a product, we pass the purchase to the
ConsumePurchase()
method:var success = billing.ConsumePurchase(purchase);
- We don't really require the
Purchase
instance but rather just the purchase token. When a product is purchased, we can just store the purchase token and use that:var token = purchase.PurchaseToken; var success = billing.ConsumePurchase(token);
- If the consumption is successful, we can use the return value, or make use of the
OnPurchaseConsumed
event:billing.OnPurchaseConsumed += (token) => { //...