0
votes

I use consumable purchases (user may buy one item many times, in my app it convert to digital good) and need ability to restore purchases in future.

I think, there is only way to do this is save user email on server side and when I need to restore purchases, I request user autorization thru Google Play Services, send email to server and restore all data.

It is possible to get user email by which the user makes a purchase after purchase flow?

Or, it may be, there is another method for restoring consumable purchases?

Authorization in the application is not desirable, even though it would solve all problems!

1

1 Answers

1
votes

It is possible to get user email by which the user makes a purchase after purchase flow?

When a user purchases an in-app item, Google Wallet assigns the transaction a unique and permanent order number. Google Play provides that order number to you at the conclusion of the purchase flow, as the value of the orderId field of the PURCHASE_STATE_CHANGED intent.

In your app, you can use the order number as a general-purpose identifier for the in-app purchase transaction. After the purchase, you can use the order number as a means of tracking the transaction in reconciliation reports and for customer support.

see Working With Order Numbers for more information

My suggestion would be to link the user to the orderId.

I'm going to guess a few follow up questions you may have:

  • How to link the user to the orderId?

Probably a simple login / authentication. You could use their Google Account (every Android user has one) - see Android Account Manager. This is a nice approach since your application does not have to handle any passwords - yay!

  • I want the same user on another phone to get those purchases/user data...

Not really possible without a login - see above (or something to uniquely identify that user) that syncs user data from the cloud to the new/other device.

Or, it may be, there is another method for restoring consumable purchases?

You cannot restore a consumed purchase with Google IAP. Double check whether you want to be using non-consumable purchases instead :)

additional source: IAP v3 API documentation.