Hi,
i want to implement In App Purchasing but it does not work. In the simulator there is the error “This library is not available on this platform”, that understandable because of the simulator. Now I uploaded a Alpha Test in Google Play Store and test it there. But when i klick on my checkbox nothing happend. Why?
build.settings
settings = { plugins = { ["plugin.google.play.services"] = { publisherId = "com.coronalabs", supportedPlatforms = { android=true } }, ["CoronaProvider.native.popup.social"] = { -- required publisherId = "com.coronalabs", }, ["plugin.google.iap.v3"] = { publisherId = "com.coronalabs", supportedPlatforms = { android=true } }, }, android = { usesPermissions = { "android.permission.INTERNET", "android.permission.ACCESS\_NETWORK\_STATE", "com.android.vending.BILLING", }, }, }
config.lua
application = { content = { width = 720, height = 1280, scale = "letterbox", xAlign = "left", yAlign = "top" }, license = { google = { key = "my64 Bit code from Google", }, }, }
start.lua
function transactionCallback( event ) -- Log transaction info. print("transactionCallback: Received event " .. tostring(event.name)) print("state: " .. tostring(event.transaction.state)) print("errorType: " .. tostring(event.transaction.errorType)) print("errorString: " .. tostring(event.transaction.errorString)) local productID= event.transaction.productIdentifier; if event.transaction.state == "purchased" then print("Product Purchased: ", productID) checkbox:setState( { isOn= false }) preference.save{adsOnOff = false} elseif event.transaction.state == "restored" then print("Product Restored", productID) elseif event.transaction.state == "refunded" then print("Product Refunded") elseif event.transaction.state == "cancelled" then print("Transaction cancelled") elseif event.transaction.state == "failed" then print("Transaction Failed") else print("Some unknown event occured. This should never happen.") end -- Tell the store we are done with the transaction. -- If you are providing downloadable content, do not call this until -- the download has completed. store.finishTransaction( event.transaction ) end local function purchaseItem(event) --make sure you add { } around your product id as you need to send a table value... not a string! store.purchase( {"packagename + name/Id from Developer Console"}) end local function restorePurchases(event) --no need to sepcify a product store.restore() end function scene:create( event ) local sceneGroup = self.view store.init("google", transactionCallback) print("Using Google's Android In-App Billing system.") local checkboxSheet = graphics.newImageSheet( "checkbox.png", options ) -- Create the widget checkbox = widget.newSwitch( { left = display.contentCenterX \* 1.3, top = display.contentCenterY \* 1.55, style = "checkbox", id = "Checkbox", width = 50, height = 50, onPress = purchaseItem, sheet = checkboxSheet, frameOff = 1, frameOn = 2 } ) checkbox:setState( { isOn= adsOnOff} ) sceneGroup:insert(checkbox ) end