Query Purchase History
This is an asynchronous function which returns the most recent purchase made by the player for each product, even if that purchase is expired, canceled, or consumed. Note: This does not produce a full history of purchases. If you would like that, you will need to keep track of all purchase made yourself.
The parameters include the Product Type to query for purchase history.
Once the asynchronous operation has completed, one of two delegates will be called to handle the success and failure situations.
Product Type
Product Type can either be Subscription or InApp products.
On Success
A delegate that will be called once all recent purchases have been retrieved. The delegate will produce a list of Purchase History Records for you to use. You can simply click and drag this pin to create a custom event.
On Failure
A delegate that will be called if there is an error attempting to look up recent purchases. The delegate will produce a Billing Response Code and debug message for the developer to handle appropriately. You can simply click and drag this pin to create a custom event.
Example
In the below example, we are checking for any recent purchase that have been made. Depending on your use case, you can create your own function to handle the results. Similarly you can create your own method to handle errors.
Keep in mind, this only provides the most recent purhcases grouped by product, not the entire purchase history for each product. Google does not provide a full history. If you want a full history, you will have to keep track of this yourself.
The Play Services: Saved Games plugin is a great solution to keep track of player data across devices using the cloud.