Google In-app Billing v3

Social Media Widgets / In-App Purchases / HTTP

Moderators: ezraanderson, scottwb

Google In-app Billing v3

Postby alex1line » Sat Dec 13, 2014 6:50 am

Does Google In-app Billing v3 work for MOAI on Android? Where can I see sample lua code for using v3 API?
alex1line
 
Posts: 5
Joined: Fri May 23, 2014 12:59 pm

Re: Google In-app Billing v3

Postby alex1line » Sat Dec 13, 2014 9:44 am

Keep in mind the Google said:
We plan to turn off the In-app Billing Version 2 service on January 27, 2015, after which time users will no longer be able to purchase in-app items and subscriptions through the Version 2 API.
alex1line
 
Posts: 5
Joined: Fri May 23, 2014 12:59 pm

Re: Google In-app Billing v3

Postby ezraanderson » Sat Dec 13, 2014 4:57 pm

~
Not sure if it works by just changing the files, but should be relatively simple to get to work
Dead Dark: A roguelike, zombie apocalypse survival game
My Website | My Facebook | My Twitter | My Games on Itunes | My Games on Android
User avatar
ezraanderson
 
Posts: 1094
Joined: Wed Nov 21, 2012 2:24 pm
Location: Canada

Re: Google In-app Billing v3

Postby orkj » Sun Dec 14, 2014 3:21 pm

hm. nice reminder.

Looking at this commit a long time ago, things seems like it should be almost ready: https://github.com/moai/moai-dev/commit ... 08a5d3a12b

So I tried to just switch "google-billing" to "google-billingv3" in my settings-global.sh file and use the new functions. Specifically purchaseProduct instead of requestPurchase and using checkInAppSupported and manually calling the callback I had for support result before.

Now this was very smooth. I got my test purchases through and all is well, seemingly.

But the part with setPublicKey does not work. The method is not implemented. Should it be? Should I be doing something else here? Anyone that has this working (pseudo code or real code very welcome) ;p
orkj
 
Posts: 42
Joined: Mon Dec 31, 2012 12:24 pm

Re: Google In-app Billing v3

Postby alex1line » Sun Dec 14, 2014 3:33 pm

Unfortunately I get error "MOAIBillingAndroid: Unable to find static java method getPurchasedProducts" even after including "google-billingv3" in file settings-global.sh
I am on tag Version-1.5.2-binary-desktop
alex1line
 
Posts: 5
Joined: Fri May 23, 2014 12:59 pm

Re: Google In-app Billing v3

Postby orkj » Tue Dec 16, 2014 10:35 am

I got this working now.

I am on master built around 1.5.2 some time, with just one specific customization (not related).

Since the repo is private, i can not post the actual commit, but here is a summary.

- Changed google-billing to google-billingv3 in settings-global.sh
- Changed MOAIBilling.requestPurchase(product) to MOAIBilling.purchaseProduct(product, BILLINGV3_PRODUCT_INAPP)
- Removed MOAIBilling.setPublicKey(KEY)
- To get the supported callback as backward compatible as possible, just added this:
Code: Select all
  1.  

  2. local supported = MOAIBilling.checkInAppSupported()

  3. onBillingSupported(supported) -- This used to be a listener.

  4.  


- Changed the code about "if not MOAIBilling.checkBillingSupported () then" to "if not MOAIBilling.checkInAppSupported() then"

Then, the things I struggled with the most:
At first I was only allowed to make test purchases, which was strange, because when I used v2 I was only able to make "real" purchases. I then removed my account from the tests list (on https://play.google.com/apps/publish/?dev_acc=<NUMBER>#ProfilePlace) and waited a few hours. Then it worked.

Then the next problem. I was not able to buy any "non-managed" products I had test purchased before. First I thought this was related to them becoming subscriptions or something in v3, but seems that you have to "consume" the earlier purchases before you can buy some new ones.
So since all my products are consumables, I just consumed all of them with no effect in the game, and it worked. I suspect this would not be a problem for users just upgrading, but more of a problem if you install the app again with v3 in it.

Anyway, seems to work now. Just pushed a new version to the play store, so hopefully that will be fine now. Not that I actually sell anything of these IAP anyway ;)

Hope that helps someone!
orkj
 
Posts: 42
Joined: Mon Dec 31, 2012 12:24 pm

Re: Google In-app Billing v3

Postby alex1line » Thu Dec 18, 2014 1:48 am

Thank you! Your recipe look like working. At least it works for purchase test product "android.test.purchased"
alex1line
 
Posts: 5
Joined: Fri May 23, 2014 12:59 pm


Return to Advertising + Networking + IAPs

Who is online

Users browsing this forum: No registered users and 0 guests

cron

x