Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
Common In App Billing Interface — Gideros Forum

Common In App Billing Interface

ar2rsawseenar2rsawseen Maintainer
edited September 2013 in General questions
Since the promo from the Amazon, we decided to rush the common iab interface, which would include Amazon IAP.
So here is the first attempt available in the Gideros Labs
http://giderosmobile.com/labs/iab

The idea is to provide common In App Billing interface for most of available iap frameworks, so users could use in app purchases across platforms and iap frameworks with completely same or similar interface.

Currently it supports:
  • Ouya (stable)
  • Amazon IAP (beta code)
  • GoogleBilling v3 (beta code)
  • Samsung IAP (alpha code)
  • Fortumo IAP (alpha code)
Interface usage is quite simple
  • IAB.new(iabframework) -- initialize specified IAB framework
  • IAB:setUp(value1, value2, ..., valueN) -- provide all the keys/devids/appids/etc needed for the framework, which you will get in same order on Native part in Map object
  • IAB:setProducts({internalId1 = "storeId1", internalId2 = "storeId2", ..., internalIdn = "storeIdn"}) -- provide list of products you will be using (key is your internal products id, value is store specific product id)
  • IAB:setConsumables({"internalId1", "internalId2", ..., "internalIdn"}) -- which of your products are consumables, that people can buy many times (provide internal product ids)
  • IAB:isAvailable() --check if IAB is available, raises event:
    • Event.AVAILABLE --iab is available
  • IAB:requestProducts() --request information for products provided in setProducts method
    • Event.PRODUCT_COMPLETE
      • event.productId
      • event.title
      • event.description
      • event.price
    • Event.PRODUCT_ERROR
      • event.error
  • IAB:purchase(prodId) --purchase product by providing your internal product id, raises two events:
    • Event.PURCHASE_COMPLETE
      • event.productId
      • event.receiptId
    • Event.PURCHASE_ERROR
      • event.error
  • iab:restore() --raise purchase events for each previously purchases entitled (not consumed) items, raises two events:
    • Event.RESTORE_COMPLETE
    • Event.RESTORE_COMPLETE
      • event.error
Any comments feedback, suggestions, which more frameworks to add, etc, welcome ;)
Especially testing is welcomed, really, really, really welcomed :)

IAB Interface usage matrix and common scenario will come soon.
+1 -1 (+2 / -0 )Share on Facebook
«13456

Comments

  • Will you be adding an iOS interface too?
    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
  • and Samsung...
    +1 -1 (+2 / -0 )Share on Facebook
  • @SinisterSoft only if you request :)
    I don't quite understand why iOS wouldn't be included without requesting it if you're developing a common in app billing interface???

    One thing I have wondered, however, is how your app knows whether it's running on Google, Amazon, Ouya etc. Haven't looked into this in detail - is there already a way of determining this?
  • @moopf that was just kidding around to initiate users into conversation, provide feedback/requests/etc

    and about your second question, it won't know, you will have to do that on your own. Like'in ideal case it would be
    local iab
    if application:getDeviceInfo() == "Android" then
        iab = IAB.new("google")
        iab:setUp("keys")
    elseif application:getDeviceInfo() == "iOS" then
        iab = IAB.new("storekit")
        iab:setUp("keys")
    end
     
    --and here comes completely same code for both frameworks to request products/buy stuff etc
    Alternatively you might have config file in which to check which version to load, and make separate builds for different markets by only changing config file
  • @ar2rsawseen Interesting, so there is nothing that could be exposed through Gideros to actually tell us the platform then? Would it not make sense to split the Android export in Gideros to make it more store-centric, e.g. Android Google, Android Amazon etc. for separate builds.

    To be honest I thought the common billing interface would internally know which one to invoke, otherwise it gets really messy on Android.
  • It would be better if there was some way to programmatically discover what AppStore the apk was installed from. There is an open source IAP lib that uses different methods dependant on the install source - maybe that might help?

    This way you could possibly have a single APK that dealt with all stores.

    Likes: moopf

    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
    +1 -1 (+1 / -0 )Share on Facebook
  • ar2rsawseenar2rsawseen Maintainer
    edited August 2013
    @SinisterSoft you are talking about open IAB and no it still won't work with single .apk file, as there it tries to determine in runtime which libraries are installed with priorities to some frameworks, so even if you install all libraries it would always choose the first one by priority. You still would have to make separate apk files for different stores

    And there is completely no way to determine from which store the apk was installed on android. It might as well not come from any store.
    And besides some frameworks are store independent, like I think Distimo is.

    Still I'd say going from completely different code for each store to only different configuration file is a huge step.
  • Omg. To much pain to use amazon billing for me. Not from gideros side. From Amazon taxes requirements.
  • ar2rsawseenar2rsawseen Maintainer
    edited August 2013
    Quite similar for OUYA. And it seems USA enforces these forms and may soon come to every market based in US.
  • SinisterSoftSinisterSoft Maintainer
    edited August 2013
    @unlying You have to just get a US employer number for a foreign person/company (a single call to the US tax office). Then you put this number on the w8-ben form. You only need to do this once for each store that requires it. It's not really complicated and I think there should be at least one thread on this forum about it somewhere.
    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
  • Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
  • @unlying You have to just get a US employer number for a foreign person/company (a single call to the US tax office). Then you put this number on the w8-ben form. You only need to do this once for each store that requires it. It's not really complicated and I think there should be at least one thread on this forum about it somewhere.
    You don't actually need the US employer number either - I've filled in lots of w8-ben forms over the years and it's not actually a requirement to have that in order to correctly complete it. The one I gave to Apple years back never had one on.

    Not sure if that requirement has changed since I last filled one in (last year I think) though.

  • SinisterSoftSinisterSoft Maintainer
    edited August 2013
    @moopf Yes, some places seem to do their own check to confirm your identity and that you're outside the US. I don't know how the US Tax office feels about this, but I think it's a requirement from them to have a W8BEN else they should keep about 30% back from you and pay it directly as tax on your behalf.

    Apple (Europe) are based outside the US. No W8BEN to enter. Maybe you filled in the form before they started the EU version of Apple.
    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
  • Oh yes, you need a w8-ben, you just don't *need* an EIN (or ITIN, can't remember exactly what it's called) for the form. Having said that it's a 5 minute job to get one anyway.
  • Amazon says that i have to send them hard copy of w8-ben. It is too much for me.
  • Amazon says that i have to send them hard copy of w8-ben. It is too much for me.
    Posting something is too much for you?
  • You never use Russian Post service.
  • You upload the hardcopy - you print the form out then sign, then upload a scanned version.
    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
  • No options to upload:

    Please print, sign with a black or blue pen, then mail your completed W-8BEN form to the following address:

    Amazon
    Attn: Vendor Maintenance
    PO Box 80683
    Seattle, WA, 98108-0683
    U.S.A.
  • You may have picked the wrong option just before that - there should be an option somewhere to fill it in then print and upload. It was there a month ago 'cause I helped someone else do it.
    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
  • ar2rsawseenar2rsawseen Maintainer
    edited September 2013
    Updated common IAB interface:
    Refined common interface api to match all stores
    Amazon Iap passed initial tests
    GoogleBilling v3 passed initial tests
    Ouya passed initial tests
    Updated example and docs to display new api
    Added initial support for Samsung IAP
    Added initial support for Fortumo IAP

    Basically except creating instance, calling setUp to provided needed keys and setProducts to match in app internal product IDs with store specific ids, all other methods are compeltely cross framework compatible and can be used as same code for all stores.

    Refer more to provided example with the Gideros Labs download

    I currently wait for account aproval on Samsung and Fortumo to test them.

    But after that I may even try to develop an auto version discussed before, which would allow to use single apk file for all the stores, based on what is installed on the device it runs (but thats just a theory, and will have a long way of testing to go to that ;) )
  • @ar2rsawseen thankyou so much :D!!
    have fun with our games~
    http://www.nightspade.com
  • A question, what if we only wish to use google billing v3?

    there are many jar on the plugin:
    commons-lang-2.6.jar
    FortumoInApp-android-9.0.41.jar
    guava-r09.jar
    in-app-purchasing-1.0.3.jar
    jackson-core-asl-1.8.4.jar
    jackson-mapper-asl-1.8.4.jar
    ouya-sdk.jar

    i think it is safe to remove ouya-sdk.jar and Fortumo, how about the others?
    have fun with our games~
    http://www.nightspade.com
  • Aha, I need to mention file dependencies somewhere.
    Well basically you can remove all of them

    FortumoInApp-android-9.0.41.jar is for Fortumo

    in-app-purchasing-1.0.3.jar is for Amazon

    commons-lang-2.6.jar
    guava-r09.jar
    jackson-core-asl-1.8.4.jar
    jackson-mapper-asl-1.8.4.jar
    ouya-sdk.jar are for OUYA

    Both Google and Samsung does not have internal libs
    Samsung has src\com\sec\android package and src\com\giderosmobile\android\plugins\iab\samsung package

    Google Billing has src\com\android\vending\billing package and src\com\giderosmobile\android\plugins\iab\google package

    And you can also remove the corresponding interfaces, as IabSamsung, IabAmazon, etc, if you are not going to use them ;)
  • Hi @ar2rsawseen

    Played with latest plugin, everything is a breeze

    Except there is a bug on Google Billing restore method

    on Line 186 of IabGoogle.java
    Iab.purchaseComplete(this, products.get(prodName), info.getOrderId());
    it should be
    Iab.purchaseComplete(caller, products.get(prodName), info.getOrderId());
    Otherwise it would crash on every restore :)
    have fun with our games~
    http://www.nightspade.com
  • Whoops, you are right, fixed it internally, will upload fixed version soon, thanks ;)
  • iOS would be great.
    Loon Games LinkedIn Facebook Twitter - "Something bit me, gaah!"
Sign In or Register to comment.