codeka / wwmmo

War Worlds MMO
MIT License
291 stars 201 forks source link

Upgrade to In-App billing library v3 #91

Closed codeka closed 9 years ago

codeka commented 9 years ago

Google is going to turn off v2 of the API on January 27th, and besides, the new API better handles the case where you purchance something, but something goes wrong when the effect is being applied. In v3, you'll still "own" the item and if you use it again you won't be charges again.

http://developer.android.com/google/play/billing/api.html

codeka commented 9 years ago

OK, turns out we were already using v3, but there was a problem related to the order things were happening. Basically, we were doing:

  1. issue purchase request
  2. consume purchase
  3. apply changes

So if there was an error in step 3 (which happened recently when the server ran out of disk space: uploads of new shield images were failing), then you lose your money. I've changed the order or operations to:

  1. issue purchase request
  2. apply changes
  3. consume purchase

This means there's a slight chance I can lose out in the "consume" fails (or if there is some kinds of fraud), but that's a risk I'm willing to take.