[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 -
Developer 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$().