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 devicelocal iab = IAB.new(stores[1])--etc
So you can have single binary for all supported stores
@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.
require"iab"local iaps = IAB.detectStores()
iab =nilif 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 purchasesifnot purchases then--create and store empty table
purchases ={}
dataSaver.saveValue("purchases", purchases)end--if we have a supported storeif 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 purchasesifnot purchases[e.receiptId]then--save purchase
purchases[e.receiptId]=true
dataSaver.saveValue("purchases", purchases)if(e.productId =="p1")then--p1 was purchasedelseif(e.productId =="p2")then--p2 was purchasedelseif(e.productId =="p3")then--p3 was purchasedend
AlertDialog.new("Purchase Completed", "Purchase successfully completed", "Ok"):show()endend)--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")endend)
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
@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
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?
@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
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 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.
@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
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
"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:
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
@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
* 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?
Comments
version 0.4
Added alpha code for IOS StoreKit
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:
Likes: pie
From setContent till purchase.complete.
And when you plan to finish with iOs in-apps?
Thanks.
Likes: boriskey
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?
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:
Likes: chipster123
"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?
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
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).
Thanks,
bml
Google Play: https://play.google.com/store/apps/details?id=com.Mithrilsoft.Fourfold
Google Plus: https://plus.google.com/117851645612711931372
Twitter: https://twitter.com/mithrilsoft
Likes: ar2rsawseen
https://deluxepixel.com
Likes: SinisterSoft
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
https://deluxepixel.com
"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"
https://deluxepixel.com
But I also have a published app with iaps on amazon through same interface and they work great
Likes: SinisterSoft
This code doesn't work on iOS:
Thank you so much
* 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.
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
Likes: SinisterSoft
version 0.6
Added initial version of Nokia Store
Fixed IOS internal key and store key mix
Fixed IOS requesting products upon setting
Likes: SinisterSoft, zaniar