So I am a fairly new at developing apps with Corona SDK and I am a little confused on how the In app purchase works and need some guidance.
I have an app with admob ads, and basically the aim is once the remove ads IAP has been purchased the ads will disappear. What i have done is created a text file that reads: iapBought = “locked”. So the code reads the file and if iapBought = “locked”, ads show.
e.g.
if iapBought == "locked then
ad.show(etc…)
end
The app is all working and I appear to have everything working just want to know if the way I am calling the store functions is correct.
This is how my store transaction function looks:
function storeTransaction( event )
local transaction = event.transaction
if ( transaction.state == “purchased” ) then
--handle a successful transaction here
print( “productIdentifier”, transaction.productIdentifier )
print( “receipt”, transaction.receipt )
print( “signature:”, transaction.signature )
print( “transactionIdentifier”, transaction.identifier )
print( “date”, transaction.date )
iapBought = "unlocked"
saveSettings()
ads.hide()
composer.gotoScene(“splash”)
elseif ( transaction.state == “cancelled” ) then
handle a cancelled transaction here
elseif ( transaction.state == “failed” ) then
--handle a failed transaction here
end
--tell the store that the transaction is complete!
--if you’re providing downloadable content, do not call this until the download has completed
store.finishTransaction( event.transaction )
end
store.init( “google”, storeTransaction )
The text in bold is how i have changed the file to unlocked so the ads don’t show. Is this the normal or correct way to give the buyer the IAP goods? Is it right what i have done in the transaction.state == purchase code? Also what am I supposed to do with the receipts and signatures?
Would really appreciate the guidance.
Thank You