I have been adding In app purchases in my app and am having trouble getting it to work.
I call store.init() but it doesn’t activate the transactionCallback listener.
I’m running on Mac OSX 10.10.5 with Corona 2769. I have double checked my key in build.settings and its fine.
Does anybody have any ideas on why it wouldn’t work - I’ll post some code below.
local store = require( "plugin.google.iap.v3" ) local function transactionCallback( event ) native.showAlert("Store active", "Store active", {"ok"}); -- 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 ) ) if event.transaction.state == "purchased" then --storeUI.printToConsole( "Transaction successful!" ) print( "receipt: " .. tostring( event.transaction.receipt ) ) print( "signature: " .. tostring( event.transaction.signature ) ) elseif event.transaction.state == "restored" then -- Reminder: your app must store this information somewhere -- Here we just display some of it --storeUI.printToConsole( "Restoring transaction:" .. -- "\n Original ID: " .. tostring( event.transaction.originalTransactionIdentifier ) .. -- "\n Original date: " .. tostring( event.transaction.originalDate ) ) print( "productIdentifier: " .. tostring( event.transaction.productIdentifier ) ) print( "receipt: " .. tostring( event.transaction.receipt ) ) print( "transactionIdentifier: " .. tostring( event.transaction.transactionIdentifier ) ) print( "date: " .. tostring( event.transaction.date ) ) print( "originalReceipt: " .. tostring( event.transaction.originalReceipt ) ) elseif event.transaction.state == "consumed" then -- Consume notifications is only supported by the Google Android Marketplace. -- Apple's app store does not support this. -- This is your opportunity to note that this object is available for purchase again. --storeUI.printToConsole( "Consuming transaction:" .. -- "\n Original ID: " .. tostring( event.transaction.originalTransactionIdentifier ) .. -- "\n Original date: " .. tostring( event.transaction.originalDate ) ) print( "productIdentifier: " .. tostring( event.transaction.productIdentifier ) ) print( "receipt: " .. tostring( event.transaction.receipt ) ) print( "transactionIdentifier: " .. tostring( event.transaction.transactionIdentifier ) ) print( "date: " .. tostring( event.transaction.date ) ) print( "originalReceipt: " .. tostring( event.transaction.originalReceipt ) ) elseif event.transaction.state == "refunded" then -- Refunds notifications is only supported by the Google Android Marketplace. -- Apple's app store does not support this. -- This is your opportunity to remove the refunded feature/product if you want. --storeUI.printToConsole( "A previously purchased product was refunded by the store:" .. -- "\n For product ID = " .. tostring( event.transaction.productIdentifier ) ) elseif event.transaction.state == "cancelled" then --storeUI.printToConsole( "Transaction cancelled by user." ) elseif event.transaction.state == "failed" then --storeUI.printToConsole( "Transaction failed, type: " .. -- tostring( event.transaction.errorType ) .. " " .. tostring( event.transaction.errorString ) ) else --storeUI.printToConsole( "Unknown event" ) 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 ) -- Tell the user to select another option now that this transaction has finished --timer.performWithDelay( 2000, storeUI.printOptionPrompt ) end store.init("google", transactionCallback) if store.canLoadProducts and store.isActive then end

)