1

I would like to implement in-app billing in my android app, but I am not sure how should I create for a developer payload. I don't have any information about user, only unique identifier created in the app to recognize it.

Is it possible to restore the purchase when the user buy a product, then uninstall the app and install it again? How to test it, because I didn't get any events when I tried to test it?

1 Answer 1

3

Yes, you can check the completed purchase after uninstall app and install it again.

All purchased items stored on the Play Server and particularly in your installed Google Play app. So after item is purchased once the information about purchase is stored and you can request it at any time untill you "consume" this purchase. "Consume" means reset the information about purchase to allow make new purchase with same ID. This is only for v3 if Android Billing Library, because all purchases in v3 are one-off (you can buy it only once) and have to be "consumed" to be purchased again. The identifier of the purchase item is a simple string that you define in the Google Developer Console. You should login to the developer console, create new project for the future app, upload signed .apk (necessary), after that you have to select the project, move to "In-App products" section and there you can create necessary purchase items with purchase IDs. While purchase action in the application you should pass the matched purchaseID to the launchPurchaseFlow() method on the IabHelper object (these are all from v3 Billing Library). The information about purchased items can also be received by using matched purchaseID.

Official Google developer documentation has pretty decent amount of information about implementing and using Billing Library:

4
  • Thank you. The problem is that I consume my products at once after buy, so if I good understand I cannot then restore that purchase? Apr 24, 2013 at 7:03
  • So far as I can understand it - no, you cannot restore consumed purchase. But I'm not that familliar with android billing system - just implementing it in my first application at this moment :)
    – Allesad
    Apr 24, 2013 at 11:56
  • Ok. Thanks. Do you know what should I use as developer payload? Apr 24, 2013 at 13:34
  • 2
    Accordingly to the documentation you can use any string you want as a developer payload and that string will be returned to you on purchase response so you can validate the purchase. Google recommends to use your own secure sever for generating (or storing) this string and validating purchase but if you have no personal server you can use some constant string for that. Personally I use some sort of user identification by device owner email. Check here stackoverflow.com/questions/2556495/get-owners-email-address. Get email, add some constant string like "_item1" and use it as payload.
    – Allesad
    Apr 24, 2013 at 16:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.