As the title states, I am having trouble getting google play in app purchases to go and hope someone can have a look at my code and see if I am doing somthing wrong.
Also, does google play care what apk you have uploaded to their server? (Specificly, does Google want you to upload the exact binary you have installed on you device to test your app? I am copying my apk to the phone via Astro File Manager and installing it that way.)
The code makes it to the line “local box5 = sf.buildBoxAtPoint( 90,10 )” and never build another box. Ie, It is hanging on “elseif store.isActive() then” I believe.
Any ideas?
Thanks in advance!
My build.settings file has this:
plugins = { ["plugin.google.iap.v3"] = { publisherId = "com.coronalabs", }, },
and this in it
android = { versionCode = "1", usesPermissions = { "com.android.vending.BILLING", --"android.permission.INTERNET", }, },
My config.lua has this in it:
license = { google = { key = "the key that the google dev console gave me. It's quite long.", }, },
The composer scene has this at the top:
local storeToUse local store = require( "store" ) if store.target == "google" then storeToUse = "google" store = require("plugin.google.iap.v3") elseif store.target == "apple" then storeToUse = "apple" end
My Code is here:
local function initStoreAccess() local popupNoAccess local popupFetching local testPath = true --In game currency that can be used to purchase in game items. local listOfProducts = { "com.superultrahyper.lootraiders.platinumone", "com.superultrahyper.lootraiders.platinumfive", "com.superultrahyper.lootraiders.platinumten", "com.superultrahyper.lootraiders.platinumtwenty", "com.superultrahyper.lootraiders.platinumfifty", "com.superultrahyper.lootraiders.platinumonehundred", } local function transactionCallback( event ) local transaction = event.transaction if transaction.state == "purchased" then print("Transaction succuessful!") elseif transaction.state == "restored" then print("Transaction restored (from previous session)") elseif transaction.state == "cancelled" then print("User cancelled transaction") elseif transaction.state == "failed" then print("Transaction failed, type:", transaction.errorType, transaction.errorString) else print("unknown event") end -- Once we are done with a transaction, call this to tell the store -- we are done with the transaction. -- If you are providing downloadable content, wait to call this until -- after the download completes. store.finishTransaction( transaction ) end local function productCallback( event ) --print("showing valid products", #event.products) for i=1, #event.products do --print(event.products[i].title) -- This is a string. gameTuning.storePrices[event.products[i].productIdentifier].price = event.products[i].productIdentifier.localizedPrice end --print("showing invalidProducts", #event.invalidProducts) for i=1, #event.invalidProducts do --print(event.invalidProducts[i]) end end --Checks to ensure that the store is working local function checkStoreActive() local function storeLoadFailed( popupToLoad ) storeIsInitialized = "failed" buildPopup( "remove", popupFetching ) popupNoAccess = buildPopup(popupToLoad) end local box5 = sf.buildBoxAtPoint( 90,10 ) if systemOs == "Win" then local box21 = sf.buildBoxAtPoint( 30,30 ) storeIsInitialized = true buildBoards( "currency" ) showBoards( boardGroupsTable, scrollView ) --store.loadProducts( listOfProducts, productCallback ) buildPopup( "remove", popupFetching ) elseif (store.isActive) then local box6 = sf.buildBoxAtPoint( 110,10 ) --Store is accessable if store.canLoadProducts() then local box7 = sf.buildBoxAtPoint( 130,10 )--Can fetch products if store.canMakePurchases() then local box8 = sf.buildBoxAtPoint(150,10 ) storeIsInitialized = true store.loadProducts( listOfProducts, productCallback ) buildBoards( "currency" ) showBoards( boardGroupsTable, scrollView ) buildPopup( "remove", popupFetching ) else --Product load failed storeLoadFailed("purchasesDisabled") end else local box23 = sf.buildBoxAtPoint( 50,50 ) --Product load failed storeLoadFailed("noStoreAccess") end else local box22 = sf.buildBoxAtPoint( 70,70 ) --Store is not accessable storeLoadFailed("noStoreAccess") end end ----------------------- local box1 = sf.buildBoxAtPoint( 10,10 ) --if systemOs == "Android" then if storeToUse == "google" then ----------------------- local box2 = sf.buildBoxAtPoint( 30,10 ) popupFetching = buildPopup("fetchingItems") local box3 = sf.buildBoxAtPoint( 50,10 ) store.init( "google", transactionCallback ) local box4 = sf.buildBoxAtPoint( 70,10 ) timer.performWithDelay( 1500, checkStoreActive ) return popupFetching --elseif systemOs == "iPhone OS" then elseif storeToUse == "apple" then popupFetching = buildPopup("fetchingItems") store.init( "apple", transactionCallback ) timer.performWithDelay( 1500, checkStoreActive ) return popupFetching else ------------------------------ local box2 = sf.buildBoxAtPoint( 10,30 ) --Platform is Win so check and see if we should be testing the environment if testPath == false then popupNoAccess = buildPopup("noStoreAccess") return popupNoAccess elseif testPath == true then popupFetching = buildPopup("fetchingItems") timer.performWithDelay( 1500, checkStoreActive ) return popupFetching end end end