I just checked an app of mine that I’m getting ready to release. I hit the buy button. It popped up the purchase. The only way I could see to cancel was to hit the device’s back button and this appeared in my console log:
Hrrmmm, just realized that I have not been uploading the same APK to the store as the one I have on my device. Even so, the testing IAP ID’s such as “android.test.purchased” should always fire a “succesful” to the listener shouldn’t it? I will try getting the correct APK in both places.
I had to upload an alpha build of my app the first time since you can’t even setup products until the right permissions are in the APK. I’ve not uploaded a version since. Can you post your purchase code and your init code?
--Function to handle store transactions function transactionCallback( event ) local transaction = event.transaction if transaction.state == "purchased" then print("Transaction succuessful!") --Save the volume(s) as purchased if global.isBundlePurchase == false then purchaseData:set(tostring(global.volumeToPurchase), true) volumeLocks[global.volumeToPurchase]:removeSelf() volumeLocks[global.volumeToPurchase]=nil global.volumeDownloadQueue[1] = global.volumeToPurchase else for i=1, #iapData:get("offerVolumes"), 1 do purchaseData:set(tostring(i), true) volumeLocks[i]:removeSelf() volumeLocks[i]=nil if i ~= 1 then global.volumeDownloadQueue[#global.volumeDownloadQueue + 1] = i end end --Remove the "deal pane" from the volume scroller require("scripts.logic").dealPane.isVisible = false require("scripts.logic").volumeScroller:scrollToPosition{ x = 300, y = 0, time = 100 } end purchaseData:save() ---[[if global.volumeToPurchase ~= 1 then native.showAlert("Success", "Purchase successful! Your new content will be downloaded automatically.", {"Okay"}) if fileMan.doesFileExist( "volume".. global.volumeToPurchase .."/images/story1/page1/page1.png", system.DocumentsDirectory ) == false then global.volumeToDownload = global.volumeDownloadQueue[1] local downloadEvent = { action="clicked", index = 1 } require("scripts.logic").downloadChoice( downloadEvent ) end else native.showAlert("Success", "Purchase successful, thank you!", {"You're welcome"}) end --]] local closeEvent = { phase="ended" } global.canTouch = true require("scripts.logic").closePurchasePane( closeEvent ) 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) elseif transaction.state == "cancelled" then print("User cancelled transaction") native.showAlert("Alert", "Purchase was cancelled.", {"Okay"}) global.canTouch = true elseif transaction.state == "failed" then print("Transaction failed, type:", transaction.errorType, transaction.errorString) native.showAlert(transaction.errorType, transaction.errorString, {"Okay"}) native.showAlert("Alert", "Purchase failed, please try again.", {"Okay"}) global.canTouch = true else native.showAlert("Alert", "An unknown error occured, purchase failed.", {"Okay"}) print("unknown event") global.canTouch = true 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 --utilize 'store.availableStores' function: if ( store.availableStores.apple ) then --currentProductList = appleProductList store.init( "apple", storeTransaction ) elseif ( store.availableStores.google ) then --currentProductList = googleProductList store.init( "google", storeTransaction ) else print( "In-app purchases are not supported on this system/device." ) end --Restore any purchases the user has made M.restorePurchases = function() store.restore() end --Purchase a volume from the store M.purchaseVolume = function( event ) local target = event.target if event.phase == "ended" and global.canTouch == true then global.canTouch = false --store.purchase( {iapData:get("volumeID"..target.id)} ) store.purchase( {"android.test.purchased"} ) end end
OOOOOOOh maaan, I am soooo dumb, I just noticed posting this that what I set up in my store.init is the wrong function name… “face palm”.
Thats what I get for copying and pasting code from 1 place and not checking function names…
My store.lua file was a bit of a frankenstein, looks like I copied code from the Corona documents for the “store.init” area and forgot to change the function name it was calling. thanks and sorry Rob =s
I just checked an app of mine that I’m getting ready to release. I hit the buy button. It popped up the purchase. The only way I could see to cancel was to hit the device’s back button and this appeared in my console log:
Hrrmmm, just realized that I have not been uploading the same APK to the store as the one I have on my device. Even so, the testing IAP ID’s such as “android.test.purchased” should always fire a “succesful” to the listener shouldn’t it? I will try getting the correct APK in both places.
I had to upload an alpha build of my app the first time since you can’t even setup products until the right permissions are in the APK. I’ve not uploaded a version since. Can you post your purchase code and your init code?
--Function to handle store transactions function transactionCallback( event ) local transaction = event.transaction if transaction.state == "purchased" then print("Transaction succuessful!") --Save the volume(s) as purchased if global.isBundlePurchase == false then purchaseData:set(tostring(global.volumeToPurchase), true) volumeLocks[global.volumeToPurchase]:removeSelf() volumeLocks[global.volumeToPurchase]=nil global.volumeDownloadQueue[1] = global.volumeToPurchase else for i=1, #iapData:get("offerVolumes"), 1 do purchaseData:set(tostring(i), true) volumeLocks[i]:removeSelf() volumeLocks[i]=nil if i ~= 1 then global.volumeDownloadQueue[#global.volumeDownloadQueue + 1] = i end end --Remove the "deal pane" from the volume scroller require("scripts.logic").dealPane.isVisible = false require("scripts.logic").volumeScroller:scrollToPosition{ x = 300, y = 0, time = 100 } end purchaseData:save() ---[[if global.volumeToPurchase ~= 1 then native.showAlert("Success", "Purchase successful! Your new content will be downloaded automatically.", {"Okay"}) if fileMan.doesFileExist( "volume".. global.volumeToPurchase .."/images/story1/page1/page1.png", system.DocumentsDirectory ) == false then global.volumeToDownload = global.volumeDownloadQueue[1] local downloadEvent = { action="clicked", index = 1 } require("scripts.logic").downloadChoice( downloadEvent ) end else native.showAlert("Success", "Purchase successful, thank you!", {"You're welcome"}) end --]] local closeEvent = { phase="ended" } global.canTouch = true require("scripts.logic").closePurchasePane( closeEvent ) 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) elseif transaction.state == "cancelled" then print("User cancelled transaction") native.showAlert("Alert", "Purchase was cancelled.", {"Okay"}) global.canTouch = true elseif transaction.state == "failed" then print("Transaction failed, type:", transaction.errorType, transaction.errorString) native.showAlert(transaction.errorType, transaction.errorString, {"Okay"}) native.showAlert("Alert", "Purchase failed, please try again.", {"Okay"}) global.canTouch = true else native.showAlert("Alert", "An unknown error occured, purchase failed.", {"Okay"}) print("unknown event") global.canTouch = true 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 --utilize 'store.availableStores' function: if ( store.availableStores.apple ) then --currentProductList = appleProductList store.init( "apple", storeTransaction ) elseif ( store.availableStores.google ) then --currentProductList = googleProductList store.init( "google", storeTransaction ) else print( "In-app purchases are not supported on this system/device." ) end --Restore any purchases the user has made M.restorePurchases = function() store.restore() end --Purchase a volume from the store M.purchaseVolume = function( event ) local target = event.target if event.phase == "ended" and global.canTouch == true then global.canTouch = false --store.purchase( {iapData:get("volumeID"..target.id)} ) store.purchase( {"android.test.purchased"} ) end end
OOOOOOOh maaan, I am soooo dumb, I just noticed posting this that what I set up in my store.init is the wrong function name… “face palm”.
Thats what I get for copying and pasting code from 1 place and not checking function names…
My store.lua file was a bit of a frankenstein, looks like I copied code from the Corona documents for the “store.init” area and forgot to change the function name it was calling. thanks and sorry Rob =s