Project Glbasic StoreKit (iOS, OUYA, OPENIAP)

Previous topic - Next topic

spacefractal

#15
today im just got Google Play version to work  :good:.

Im update this very soon to the first post (edit: just added and also added link to the ANDROID EXTRAS link as well, which got updated as well).

Now im need to add a example how to yse the Project GlBasic Storekit. Its can been a little bit compliced due all those keys and setup. the implementation should been pretty easy.

Howove on Google Play, you can only test it with signed binary.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

spacefractal

[ADDITIONAL INFO BEFORE STARTING THE TUTORIAL]

For OUYA IAP you need to have an OUYA developer ID (or UUID). This can be found here - https://devs.ouya.tv/developers   

Look under the text that says -
QuoteDeveloper UUID (used for configuring in-app purchases):
It's a series of alphanumeric characters in the format - XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX (8-4-4-4-12 chars). You need to place this into the inapp.gbas file (see (2b) later).

You will also need to attach the following .gbas files to your main project -

- AndroidExtras.gbas
- inapp.bgas
- hashnumber.gbas
- Funcs_General.gbas

These are all found within SpaceFractal's/FiveSprites' Android Extras folders. Ensure that you have the latest updates of all files within.

You will also need a another Developer Application Signed Key - you get this from the OUYA dev portal when you create a new GAME (Edit: NOT Product). I don't know if it's my browser (FF) or what but clicking the "download" Signing Key button doesn't download the key for me - I had to right click and Save Target. This will then create a nice little certificate called "key.der" you need that for later.

OK. Now you have everything you need to make a start. You do have an OUYA and a GLB program that works on Android/BlueStacks right? Well, now you can begin... :)

This above have wrote by Ian, before my Tutorial to explain extra ting.




Im have still not wiped up a example and have first time in the next week. So im thinks im will try to explain how the OUYA shop work, which is a good start.

So here we go:

Im do have to say its can been a quite tricks, due inapp purchases uses callbacks and might first checked correctly after a little while (its asyncron).

1a. For all shops, you need to setup your sku, so the shops known which id people tryting to get. For OUYA, you doing that for this url (after login):
https://devs.ouya.tv/developers/products

*NOTE* The SKU will take the form of "com.yourname.gametitle" - this information is found in the AndroidManifest.xml file when you create your Android app. The product name MUST match this, otherwise the OUYA store will not accept any upload.


1b. Here you setup your product and only Entitlement type product is supported. Price there can been changed, which will reflect for your game (and you dont get changed for testing your own inapps).

1c. For config skus for glbasic, its done in InAppConfig_SkuNames$ function in inapp.gbas. that sku might been named different (which is required for all Android shops), which is checked by IF iID$="0" OR iID$="internal.sku" line (so im only need to uses one sku name internal).

2a. Tthere is Signing Key for each game, which is required too. That need to been put in distribute\Android\assets\Keys, and NOT in  the Media folder.

2b. There is a dev key as well. That dev key need to been put in the InAppConfig_PublicKeys$ in the com.ouya.shop line (in the RETURN statement).

2c. You need to add a line to AndroidManifest.xml, which is  <uses-permission android:name="com.android.vending.BILLING" />. Without that, you cant uses the paymant screen.

That was the setup stuff, which can take a quite of time to understand.

Here is how the various functions should been used:

3. You need put a InAppPurchase_Update() in every loop. That control anything when something happens and need to checks callbacks under purchases.

4. To check if the user have purchased a product, you can uses a InAppPurchase_isAvailable$("internal.sku"). You dont need to do a internal variable, its should works offline too (but not checked). On that function, you should also do a fake purchase as well, if java have been temped.

5. To check a price of a purchase, do a InAppPurchase_Price$("internal.sku") name (you can also check shop online at InAppPurchase_isOnline()). its might take a while, due this is a asyncron function and uses a callback.

6. When the user press on the Purchase button, you will send a InAppPurchase_Activate("internal.sku"). That should send the paymant box to the screen.

7. If the purchases is a succes, you will see the sku name in INAPP_PURCHASE$. Its will contain a string when users purchases is a succes.

8. If something failed, you will see INAPP_ERROR$.

Please Note:
A. When user is on the purchase screen, your app would been sent a GLB_ON_PAUSE, and GLB_ON_RESUME when the screen is gone. That because the payment screen is using its own intent (which is same sort of a new Window on Windows). Here you might need to make sure the pause dont popup here when that happens. That is up to you to implemented, and is not checked by storekit.

On Android, restore purchases is NOT required, that is for iOS only. Apple will reject if you not doing that. This is what InAppPurchase_Restore() do. When succes a INAPP_PURCHASE$="restored" (or a INAPP_ERROR$ if failed) would been set and then recheck for items using InAppPurchase_isAvailable$().
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

spicypixel

We need a straightforward guide for Android Extras, or a one click install :) Also concerning this StoreKit, you mention OUYA a lot, what is the procedure for GooglePlay Store?
http://www.spicypixel.net | http://www.facebook.com/SpicyPixel.NET

Comps Owned - ZX.81, ZX.48K, ZX.128K+2, Vic20, C64, Atari-ST, A500.600.1200, PC, Apple Mini-Mac.

spacefractal

Pretty similar for doing the OUYA. Its pretty much only sku details as well the key setup that is different, rest for implemented is the same thing. The Java api auto detect the correct shop, so its only sku and key setup, that is different.

1. Here you setup the sku details in google Console / Your App Title / In-app Products instead. Here its only Managed Product type product its supports. Make sure the sku id which is the unique id for your items is not the same as on OUYA shop (which is why you uses a "internal sku" ingame). its could been com.spacefractal.greedymouse.gplay_premiumkey example.

2. There is a license key for each app which is in Google Console / Your App Title / Services & Apis. That key is to been put in InAppConfig_PublicKeys$() function for "com.google.play" line. Its a pretty long key.

Rest implentation is pretty much the same as for OUYA. The only different is the testing part is much easier on ouya. Here you can uses own test account for testing inapps purchases, whole on Google Play, you need external accounts for doing that, and you cant purchases your own product (which could been handy for testing)

PS. The SDK Upgrade as well AndroidExtras is included Java Inapps apis, but did not include the example. so if you have installed that, then you should could uses that download from the first post (the inapp.gbas file).
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

Jonás Perusquía

Thank you for all this :D

Would be awesome if you could expand a bit the information about OUYA :)
<HTML><BASIC><EC>
Be free and do good things

Ian Price

What help do you need with the OUYA storekit?
I came. I saw. I played.

Jonás Perusquía

I did not understand how to add IAP and Controller support to an existing GLBasic project :(
<HTML><BASIC><EC>
Be free and do good things

Ian Price

For controllers and IAP you will need to add a number of extra files to your project. These files are -

- AnroidExtras.gbas
- inapp.gbas
- Funcs_General.gbas
- hashnumber.gbas

Go into the jump-bar on the right of the GLBasic IDE and click "files", right click on "sources" and "add file" - you can find these files in the Android Extras/IAP folders. Also goto "Source code file" in "File" and "Open" the selected files. Make sure you use "Save all opened files"  - this should ensure that your files all stay together and help to compile without problem.

The controllers only need the AndroidExtras, but the IAP needs everything else.






For controllers you must ensure that you use something like this -

Code (glbasic) Select

WHILE TRUE

//                          Analogues                                D-Pad
IF (GameControllers("Up", 0)>600 OR GameControllers("PadL_Up", 0)) THEN ...
IF (GameControllers("Down", 0)>600 OR GameControllers("PadL_Down", 0)) THEN ...
IF (GameControllers("Left", 0)>600 OR GameControllers("PadL_Up_Left", 0)) THEN ...
IF (GameControllers("Right", 0)>600 OR GameControllers("PadL_Right", 0)) THEN ...

SHOWSCREEN

GameControllers("Update")

WEND


You need to ensure that the analogues have a value of 600+ as otherwise they are too sensitive.

hope that helps for now.

IAP takes a bit more to work out, but you'll need the controllers to work first...
I came. I saw. I played.

Jonás Perusquía

Thank you Ian Prince for your help! really useful :D
<HTML><BASIC><EC>
Be free and do good things

Ian Price

I may be a "prince" among men ;) (LOL), but my name is Price :D

Glad it helped. BTW.
I came. I saw. I played.

spacefractal

yes inapp take quite more work with the sku setup and details. Now Ian also got the thing to work too (and im faced also my own bugs too, hehe later). Its should been easier now.

In the recent beta of Storekit....

inapp.gbas have been splitted to inapp_config.gbas and inapp_functions.gbas. That will been easier for me to update to functions without reconfig again.

PS. You could do anything >600 for both analog and digital. On some joypads those mightbeen swapped. But no issue on OUYA doing that.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

msx

We appreciate you publish your work to serve the community.  :nw:

Are you considering implementing Android ads in StoreKit?.

spacefractal

I'm have not a plan for ads yet. More important is expandsion support for google play and skillz for iOS end of this month.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

spacefractal

can somebody move this in a better forum than a beta? Even its still a better, its property never go out of beta in the end really. Im have not plans to add consumable items support right now.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

Ian Price

Where do you want it? Bonus/Code Snippets or GLBasic - English?
I came. I saw. I played.