Hi, I am alpha-testing an app which contains in-app purchases and get an error from google (Authentication required).
I have seen a this is not a new problem, but what I found has not helped me
this is my build setting:
android =
{
googlePlayGamesAppId=“40XXX65XX9XX”,
– usesExpantionsFile=true
usesPermissions =
{
“android.permission.INTERNET”,
“android.permission.ACCESS_NETWORK_STATE”,
“android.permission.RECEIVE_BOOT_COMPLETED”,
“android.permission.WRITE_EXTERNAL_STORAGE”,
“com.android.vending.CHECK_LICENSE”,
“com.android.vending.BILLING”
},
},
and this is the code section that deals with purchases:
local function transactionCallback( event )
print(“In transactionCallback”, event.transaction.state)
local transaction = event.transaction
local tstate = event.transaction.state
–
--Google does not return a “restored” state when you call store.restore()
--You’re only going to get “purchased” with Google. This is a work around
--to the problem.
–
--The assumption here is that any real purchase should happen reasonably
--quick while restores will have a transaction date sometime in the past.
--5 minutes seems sufficient to separate a purchase from a restore.
–
if store.availableStores.google and tstate == “purchased” then
local timeStamp = utility.makeTimeStamp(transaction.date,“ctime”)
if timeStamp + 360 > os.time() then – if the time stamp is older than 5 minutes, we will assume a restore.
print(“map this purchase to a restore”)
tstate = “restored”
print("I think tstate is ", tstate)
restoring = false
end
end
if tstate == “purchased” then
print(“Transaction succuessful!”)
mySettings.isPaid = true
utility.saveTable(mySettings, “settings.json”)
native.showAlert(“Thank you!”, “Your support is greatly appreciated!”, “Okay”)
store.finishTransaction( transaction )
elseif tstate == “restored” then
print(“Transaction restored (from previous session)”)
mySettings.isPaid = true
utility.saveTable(mySettings, “settings.json”)
store.finishTransaction( transaction )
elseif tstate == “refunded” then
print(“User requested a refund – locking app back”)
mySettings.isPaid = false
utility.saveTable(mySettings, “settings.json”)
store.finishTransaction( transaction )
elseif tstate == “revoked” then – Amazon feature
print (“The user who has a revoked purchase is”, transaction.userId)
--Revoke this SKU here:
mySettings.isPaid = false
utility.saveTable(mySettings, “settings.json”)
elseif tstate == “cancelled” then
print(“User cancelled transaction”)
store.finishTransaction( transaction )
elseif tstate == “failed” then
print(“Transaction failed, type:”, transaction.errorType, transaction.errorString)
store.finishTransaction( transaction )
else
print(“unknown event”)
store.finishTransaction( transaction )
end
print(“done with store business for now”)
end
local function loadProductsListener( event )
print(“In loadProductsListener”)
local products = event.products
for i=1, #event.products do
print(event.products[i].title)
print(event.products[i].description)
print(event.products[i].localizedPrice)
print(event.products[i].productIdentifier)
end
for i=1, #event.invalidProducts do
print(event.invalidProducts[i])
end
end
local function appPurchase( event )
print(“Now in appPurchase”)
if event.phase == “began” then
event.target.xScale=0.95
event.target.yScale=0.95
elseif event.phase == “ended” then
event.target.xScale=1
event.target.yScale=1
if system.getInfo(“targetAppStore”) == “amazon” then
store.purchase( “com.gmail.lcazzulani.xxxxx.yyyy” )
else
store.purchase( “com.gmail.lcazzulani.xxxxx.yyyy” )
end
event.target.x=5000
buyInProgress=false
end
return true
end
local function purchaseButtonHandler()
local buyBtn = display.newImage(“buyButton.png”)
buyBtn.x = W
buyBtn.y = H
buyInProgress=true
buyBtn:addEventListener( “touch”, appPurchase )
end
the app is published regularly (in alpa)
I am logged inn google with an account different from my own, which I have also enabled as a tester in the developer console.
what are the possible reasons for the error message?
many thanks
Luca