Hi,
Hopefully by the time I’ve finished writing this thread I would have solved the problem myself. But I’ll do my thinking out loud in case someone can help me at the end.
I’ve setup an IAP for the google play store, v3.
Here’s how I init the store:
store = require(“store”)
if androidBuild then
print (“get store v3”)
store = require(“plugin.google.iap.v3”)
…
the print(“get store v3”) is in my adb output.
I call this in a line in my iap script file, outside of any function:
store.init(transactionCallback)
This is my transaction callback procedure:
function transactionCallback( event )
local transaction = event.transaction
print("Got Store transaction callback event : ")
print("Event is " … json.encode(event))
if transaction.state == “purchased” then
print(“Transaction succuessful!”)
print(“productIdentifier”, transaction.productIdentifier)
print(“receipt”, transaction.receipt)
print(“transactionIdentifier”, transaction.identifier)
print(“date”, transaction.date)
if transaction.productIdentifier == “adremover” then
buyAdsRemoverSuccess()
end
elseif transaction.state == “restored” then
print(“Transaction restored (from previous session)”)
print(“productIdentifier”, transaction.productIdentifier)
print(“receipt”, transaction.receipt)
print(“transactionIdentifier”, transaction.identifier)
print(“date”, transaction.date)
print(“originalReceipt”, transaction.originalReceipt)
print(“originalTransactionIdentifier”, transaction.originalIdentifier)
print(“originalDate”, transaction.originalDate)
if transaction.productIdentifier == “adremover” then
buyAdsRemoverSuccess()
end
elseif transaction.state == “cancelled” then
print(“User cancelled transaction”)
native.showAlert(“Purchase Cancelled”, “Your attempt to purchase the ‘Ads Remover’ was cancelled”, {“Ok”})
elseif transaction.state == “failed” then
print(“Transaction failed, type:”, transaction.errorType, transaction.errorString)
native.showAlert(“Purchase Fail”, “Your attempt to purchase the ‘Ads Remover’ failed”, {“Ok”})
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
Nothing in here gets printed when I buy the ‘ads remover’. The purchase is successful, with no errors from google play. But I get nothing in my adb log to suggest that I got a callback.
I do get product call back events, eg this is in my iap script file:
function loadProducts()
print("in load products, store is active : " … tostring(store.isActive))
if store and store.isActive then
print("store load products? " … tostring(store.canLoadProducts))
if store.canLoadProducts then
store.loadProducts( listOfProducts, productCallback )
showGooglePlayStore()
end
end
end
loadProducts()
local function productCallback( event )
print("got product callback event : " … json.encode(event))
storeProducts = event.products
end
and I get this in my adb output:
I/Corona (23285): got product callback event : {“products”:[{“type”:“inapp”,“title”:“Ratings Booster - Pack of 50 (The Best Cricket Game Ever)”,“productIdentifier”:“ratingsbooster”,“localizedPrice”:"$0.99",“description”:“Boost your ratings by 20 points for the next 6 deliveries. Max 1 every 5 overs.”},{“type”:“inapp”,“title”:“Six Guarantee - Pack of 50 (The Best Cricket Game Ever)”,“productIdentifier”:“sixbooster”,“localizedPrice”:"$0.99",“description”:“Hit a guaranteed six off your next ball. Max use 1 every 5 overs. “},{“type”:“inapp”,“title”:“Invincible Batter - 50 Pack (The Best Cricket G
ame Ever)”,“productIdentifier”:“invinciblebatter”,“localizedPrice”:”$0.99”,“description”:“The batter on strike won’t get out in the next 3 balls he faces.”},{“type”:“inapp”,“title”:“Dot Ball Guarantee - Pack of 50 (The Best Cricket Game Ever)”,“productIdentifier”:“dotballbooster”,“localizedPrice”:"$0.99",“description”:“Get a dot ball (10% chance of wicket) on your next ball. Max 1 every 5 overs.”},{“type”:“inapp”,“title”:“Ad Remover (The Best Cricket Game Ever)”,“productIdentifier”:“adremover”,“localizedPrice”:"$1.99",“description”:“Remove ads from the game to increase your enjoyment”}],“name”
:“productList”,“invalidProducts”:[]}
I/Corona (23285): in licensing listener
I/Corona (23285): got licensing event : {“isVerified”:true,“name”:“licensing”,“provider”:“google”,“expiration”:1396881677405,“expansionFiles”:[],“response”:“Error contacting server”}
I/Corona (23285): is verified : true
This is how I make a purchase:
function buyAdsRemover(event)
print("got bar event : phase " … event.phase)
if event and event.phase ~= “ended” then return true end
print(“calling store.purchase”)
store.purchase(“adremover”)
return true
end
which as expected lets me buy the ‘adremover’ from the play store… just with no callback event?
relevant parts of build.settings: androidPermissions =
{
“android.permission.READ_PHONE_STATE”,
“android.permission.ACCESS_NETWORK_STATE”,
“android.permission.VIBRATE”,
“android.permission.INTERNET”,
“android.permission.ACCESS_WIFI_STATE”,
“android.permission.ACCESS_FINE_LOCATION”,
“android.permission.ACCESS_COARSE_LOCATION”,
“com.android.vending.CHECK_LICENSE”,
“com.android.vending.BILLING”,
},
plugins =
{
– key is the name passed to Lua’s ‘require()’
[“plugin.google.iap.v3”] =
{
– required
publisherId = “com.coronalabs”,
supportedPlatforms = { android = true },
},
and config.lua
license = {
google = {
key = “MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8Aetc etc etc”,
},
},
thanks for any help…