Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Common In App Billing Interface - Page 2 — Gideros Forum

Common In App Billing Interface

2456

Comments

  • Updated IAB interface:

    version 0.4
    Added alpha code for IOS StoreKit
  • ar2rsawseenar2rsawseen Maintainer
    edited October 2013
    Specially for @moopf (inspired by his idea)

    version 0.5
    Added auto store detection with prioritization option

    IAB.detectStores(priority1, priority2, ... priorityN) -- returns table with stores, that are available on device in provided priority order

    example:
    local stores = IAB.detectStores("google") -- will return table with google 
    -- as first element if its available, 
    -- and other supported stores, which are installed on device
     
    local iab = IAB.new(stores[1])
     
    --etc
    So you can have single binary for all supported stores

    Likes: pie

    +1 -1 (+1 / -0 )Share on Facebook
  • @ar2rsawseen can you provide an example where we have 2 or 3 products with purchasing, please?
    From setContent till purchase.complete.
    And when you plan to finish with iOs in-apps?
    Thanks.
  • ar2rsawseenar2rsawseen Maintainer
    edited November 2013
    Sure, this should cover all the available stores:
    require "iab"
    local iaps = IAB.detectStores()
    iab = nil
    if iaps[1] == "google" then
    	iab = IAB.new(iaps[1])
    	iab:setUp("google-key")
    	--using google product identifiers
    	iab:setProducts({p1 = "googleprod1", p2 = "googleprod2", p3 = "googleprod3"})
    elseif iaps[1] == "amazon" then
    	iab = IAB.new(iaps[1])
    	--using amazon product identifiers
    	iab:setProducts({p1 = "amazonprod1", p2 = "amazonprod2", p3 = "amazonprod3"})
    elseif iaps[1] == "ios" then
    	iab = IAB.new(iaps[1])
    	--using ios product identifiers
    	iab:setProducts({p1 = "iosprod1", p2 = "iosprod2", p3 = "iosprod3"})
    end
     
    --load previous purchases
    purchases = dataSaver.loadValue("purchases")
    --if there were no purchases
    if not purchases then
    	--create and store empty table
    	purchases = {}
    	dataSaver.saveValue("purchases", purchases)
    end
     
    --if we have a supported store
    if iab then
    	--set which products are consumables
    	iab:setConsumables({"p1", "p2"})
     
    	--if purchase complete
    	iab:addEventListener(Event.PURCHASE_COMPLETE, function(e)
    		--if it was not previousle purchases
    		if not purchases[e.receiptId] then
    			--save purchase
    			purchases[e.receiptId] = true
    			dataSaver.saveValue("purchases", purchases)
     
    			if (e.productId == "p1") then
    				--p1 was purchased
    			elseif (e.productId == "p2") then
    				--p2 was purchased
    			elseif (e.productId == "p3") then
    				--p3 was purchased
    			end
    			AlertDialog.new("Purchase Completed", "Purchase successfully completed", "Ok"):show()
    		end
    	end)
     
    	--if there was an error
    	iab:addEventListener(Event.PURCHASE_ERROR, function(e)
    		AlertDialog.new("Purchase Canceled", e.error, "Ok"):show()
    	end)
     
    	--call restore on each app starts
    	--or make a button to allow users to restore purchases
    	iab:restore()
    end
     
    --some where in your code to make a purchase
    stage:addEventListener(Event.MOUSE_UP, function()
    	if iab then
    		iab:purchase("p1")
    	end
    end)

    Likes: boriskey

    +1 -1 (+1 / -0 )Share on Facebook
  • Oh and about IOS, I tested it with test account and it seems to work great, now I submitted Mashballs with ios inapps using Common iab interface to see how it works in real life environment (and also to test that other rejection you mentioned in other thread) and now waiting for approval or rejection from them
  • --using google product identifiers
    iab:setProducts({googleprod1 = "p1", googleprod2 = "p2", googleprod3 = "p3"})

    p1 - google product identifier

    --set which products are consumables
    iab:setConsumables({"p1", "p2"})

    p1 - also google product identifier?

    if (e.productId == "p1") then
    --p1 was purchased

    iab:purchase("p1")

    - everytime google product identifier?
  • ar2rsawseenar2rsawseen Maintainer
    edited April 2014
    @unlying I see
    in the table you pass to setProducts, key is the internal product identifier, while value is your in-app market specific product identifier.

    for example, you can have a 100 coin in-app purchase, which in GooglePlay is called:
    100ofCoins, in ios market its called com.yourdomain.yourapp.coins100, and in samsung market its called x0000000yvz.

    Inside your app you just want to refer to it as coins100

    Then for GooglePlay you provide:
    iab:setProducts({oins100 = "100ofCoins"})
    For IOS you provide:
    iab:setProducts({coins100 = "com.yourdomain.yourapp.coins100"})
    For samsung you provide:
    iab:setProducts({coins100 = "x0000000yvz"})
    And then in your app you use it as:
    iab:purchase("coins100")
    Hope that helps ;)

    Likes: chipster123

    +1 -1 (+1 / -0 )Share on Facebook
  • Khm. Gideros doesn't allow to use names like 100ofCoins. My google product has name 500coins. So i can't use this plugin for this product?
  • And on app start i have this crash:
    "11-13 23:10:57.785: E/IabHelper(18570): In-app billing error: Illegal state for operation (queryInventory): IAB helper is not set up"
    Do i miss something?
  • ar2rsawseenar2rsawseen Maintainer
    edited November 2013
    @unlying ah sorry, lua stuff, you can write it as:
    t = {}
    t["100Coins"] = "some other value"
    iab:setProducts(t)
    and about error, it seems that you query products, before you set up the iab, like first you need to provide key, then set products, then set consumables and only then you can use the other iab functionality
  • How is it possible? I'm using code that you provide without any changes except setting values for my project.

    11-14 07:42:50.632: D/IabHelper(25656): IAB helper created.
    11-14 07:42:50.632: D/IabHelper(25656): Starting in-app billing setup.
    11-14 07:42:51.480: I/Choreographer(25656): Skipped 42 frames! The application may be doing too much work on its main thread.
    11-14 07:42:51.507: D/IabHelper(25656): Ending async operation:
    11-14 07:42:51.511: E/IabHelper(25656): In-app billing error: Illegal state for operation (queryInventory): IAB helper is not set up.
    11-14 07:42:51.511: D/AndroidRuntime(25656): Shutting down VM
    11-14 07:42:51.511: W/dalvikvm(25656): threadid=1: thread exiting with uncaught exception (group=0x418dc700)
    11-14 07:42:51.523: E/AndroidRuntime(25656): FATAL EXCEPTION: main
    11-14 07:42:51.523: E/AndroidRuntime(25656): java.lang.IllegalStateException: IAB helper is not set up. Can't perform operation: queryInventory
  • Ok let me check, also, there seem to be an upgrade for the lib, so let me also upgrade and retest ;)
  • I've updated the lib and tested the code and can't reproduce the issue.

    Please retry with updated lib (you can also try out the example project provided with the IAB plugin in the Labs)

    But if issue still persists, might the reason be that you are using old version of Google Play?
    In-app billing V3 needs 3.9.16 or higher (http://developer.android.com/google/play/billing/versions.html).
  • No luck for me. Returned to standart...
  • Support for receipt verification on a remote server would be much appreciated. Mainly exposing the required data and supporting the ability to manually finalize the purchase.

    Thanks,
    bml
  • Sure, will check which frameworks support remote server verification and will think on how to integrate it in the API ;)
  • Sure, this should cover all the available stores:
    Thanks for this example helped a lot with initial setup on the in app billing process. I was having so many issues until I think it turned out to be Google's play store servers needed time to update. Was using the same code and getting issues until about 4-5hours in and everything was working smoothly.

    Likes: ar2rsawseen

    +1 -1 (+1 / -0 )Share on Facebook
  • SinisterSoftSinisterSoft Maintainer
    edited February 2014
    @ar2rsawseen On iOS when I add the iab folder to plugins then add it to the project, the app will crash - if I remove it it will work. Should I be removing some legacy storekit stuff if I use the iab plugin on ios?
    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
  • SinisterSoftSinisterSoft Maintainer
    edited March 2014
    On Kindle (not tried proper Android) I have tried the Amazon store, the auto detect works fine, the available event fires but the iab:restore doesn't work - neither do any purchase requests (I get no events).

    On Android the same program detects google play and all works great.

    Any ideas?

    Edit: Tried amazon on normal android and same result as Kindle.

    Edit:

    It looks like it's something to do with com.amazon.testclient.iap.purchase ???

    03-07 22:27:50.280: W/ActivityManager(2356): Unable to start service Intent { act=com.amazon.testclient.iap.purchase flg=0x10000000 (has extras) } U=0: not found
    03-07 22:27:53.035: W/ActivityManager(2356): Unable to start service Intent { act=com.amazon.testclient.iap.purchase flg=0x10000000 (has extras) } U=0: not found
    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
  • Ahhh.....

    "Amazon differs from Google's PlayStore in that you cannot test purchases with Amazon's servers at all, until your app has been approved and published:

    Only apps that have been approved and published through the Distribution Portal can communicate with the Amazon Client.
    https://developer.amazon.com/sdk/in-app-purchasing/documentation/testing-iap.html

    So until that point, your only option for debugging and testing purchases is to use the Amazon Tester app which emulates the Amazon store.

    This line means the Amazon API is requesting Amazon's SDK tester App but it is not installed on your device:

    11-26 11:16:29.033: W/ActivityManager(61): Unable to start service Intent{ act=com.amazon.testclient.iap.purchase flg=0x10000000 (has extras) }: not found"
    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
    @SinisterSoft yes, I have used that to test Amazon IAP interface, you simply install the tester app and prepare a json file with responses, that you put in the root of your Android.

    But I also have a published app with iaps on amazon through same interface and they work great :)

    Likes: SinisterSoft

    +1 -1 (+1 / -0 )Share on Facebook
  • zaniarzaniar Member
    edited April 2014
    I have played around with iab plugin and found this issue.

    This code doesn't work on iOS:
    iab:setProducts({p1 = "iosprod1", p2 = "iosprod2", p3 = "iosprod3"})
    But, this one works:
    iab:setProducts({"iosprod1" = p1, "iosprod2" = p2, "iosprod3" = p3})
    I think this issue should be fixed for the sake of consistency. Isn't it? :-?
  • ar2rsawseenar2rsawseen Maintainer
    @zaniar ah I was catching a bug and could not understand what happens wrong, and that could make sense. I mixed up them.
    Thank you so much :)
  • ar2rsawseenar2rsawseen Maintainer
    Hmm but again looking at the code I don't see anything reversed. Still thanks for the clue, now at least I have something to work with :)
  • I have got other issues on iOS.

    * event.productId is reversed. The value is com.something.coin1000 instead of coin1000. I believe this issue is related to previous issue I reported.

    * requestProduct called automatically. Is this the correct behaviour? Android doesn't behave this way though.

    I hope the update will come soon 8->

    I have workaround for the productId issue but not for the requestProduct issue.
  • Hello,
    I also have issues with iOS.

    * When I do a setProducts it calls requestProducts and does not retrieve any remote product.
    * The product Id also seem inverted when I debug the plugin in XCode.
    * When I requestProducts() and use the xCode debugger, I see that the request is sent, no product is received and then the app displays a popup requiring to log in. When I log in with my test user account no new event is raised and still no products are received.

    I used basically the example provided by @ar2rsawseen, my app is on iTunes connect in "waiting for upload" status and the in app products are "waiting for review".
    Did I make something wrong?
    Could somebody make IAB interface working on iOS?

    Thanks
  • ar2rsawseenar2rsawseen Maintainer
    Updated IAB interface:

    version 0.6
    Added initial version of Nokia Store
    Fixed IOS internal key and store key mix
    Fixed IOS requesting products upon setting
    +1 -1 (+2 / -0 )Share on Facebook
Sign In or Register to comment.