I have seven virtual products in my game and would like to give one away each day or so to people who visit my website.
-
Are you asking if you can do this using Google Play's in-app billing service or simply asking how to implement this on your own? The question is quite broad. – Tyler Treat Aug 17 '12 at 20:50
-
Yes, does google play's billing service have this built in? – user1607870 Aug 18 '12 at 00:17
-
Not that I know of, no. I'm thinking you'll have to roll your own as others have suggested. – Tyler Treat Aug 18 '12 at 00:26
2 Answers
Bob Smith is correct that this will work, but depending on the value of these in-app-purchases you may want to err towards something more complex.
If there's nothing generated about these codes, i.e. my code is the same as yours, then any one person can just give this code away and it will work for everyone. Another suggestion to keep in mind is to make the code a hash of some predetermined secret value, and the unique identifier of the app.
For example, if every app has in it an ID, your code might be:
md5(userId.toString + mySecret);
Because a hash is one way, nobody can get your secret back out and compute their own codes. They have to submit their app code through your service to get a code specific for them.
You can continue to layer in features too. You could include secret identifiers for each purchase, so that one algorithm generates unique codes for each purchase.
Of course, if there is only one secret, it would also have to be hard coded into the app, which is not utterly secure. This is a problem for both Bob's system and mine, and should that secret get public the entire system falls apart. You could look into all sorts of different encryption techniques to come up with more and more clever systems, if you need that level of security.

- 8,964
- 4
- 26
- 37
-
i was hoping for a simple "coupon code" solutions like they have at estores. For example nike.com has a 20% off coupon if you enter in "victorious" at the check out. Anyone who knows the code can simply enter in the code to get 20% off their purchase. I wanted to give my customers 100% off their purchase of my items using googles in-app billing service. – user1607870 Aug 18 '12 at 00:37
Yes you can do that, what you should do is send the recipient of the code the code via email or someway, then in the app have a spot where the person can enter the code in. Similar to entering in cheat codes in a videogame. If their code they enter matches one that you made valid, you should grant them access to the virtual product.

- 505
- 3
- 10
- 27