Hi, Ive been trying to get refunds working with the google play store and am not having any luck.
I run a restore everytime the game is loaded… I have not yet been able to get a refunded state… Actually what happens is I cancel the purchase by requesting a refund through my test account, which cancels the order in my google wallet merchant account… wait around 24 hours (Ive read you have may have to wait between 24-48 hours before google will send a refund notification). After 24 hours I no longer recieve a purchased state (or restore… or refunded)… I dont recieve anything from the transaction listener after google refunds (Im assuming) the item.
Is it possible to test for a refund with an app that is side loaded with a gmail account with license testing?
This is how I am calling the restore… It works for restoring purchases… but when I should be getting a refund state… I dont get anything at all from the transaction listener. I dont believe its an error with my code… since the restores/purchases work… just not getting anything back from google when the purchases are refunded.
[lua]
local function transactionCallback( event )
print(“In transactionCallback”, event.transaction.state)
local transaction = event.transaction
local tstate = event.transaction.state
print(tstate …“1st tstate, at top of callback”)
print( “product identifier”, transaction.productIdentifier )
print( “receipt”, transaction.receipt )
print( “transaction identifier”, transaction.identifier )
print( “date”, transaction.date )
print( “original receipt”, transaction.originalReceipt )
print( “original transaction identifier”, transaction.originalIdentifier )
print( “original date”, transaction.originalDate )
if tstate == “purchased” then
local timeStamp = transaction.date/1000
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”
end
end
if tstate == “purchased” then
print(tstate)
print( “product identifier”, transaction.productIdentifier )
print( “receipt”, transaction.receipt )
print( “transaction identifier”, transaction.identifier )
print( “date”, transaction.date )
print( “original receipt”, transaction.originalReceipt )
print( “original transaction identifier”, transaction.originalIdentifier )
print( “original date”, transaction.originalDate )
if transaction.productIdentifier == nonConsumable1 then – this can be canceled in the wallet
vault:set(“IAP1”, “unlocked”)
IAP1 = “unlocked”
print(“IAP1 unlocked”)
end
if transaction.productIdentifier == nonConsumable2 then
vault:set(“IAP2”, “unlocked”)
IAP2 = “unlocked”
print(“IAP2 unlocked”)
end
if transaction.productIdentifier == consumable1 then
print(“Consumable 1 was purchased”)
store.consumePurchase({consumable1}, transactionCallback)
end
if transaction.productIdentifier == consumable2 then
print(“Consumable 2 was purchased”)
store.consumePurchase({consumable2}, transactionCallback)
end
native.showAlert(“Thank you!”, “Your support is greatly appreciated!”, {“Okay”})
vault:save()
store.finishTransaction( transaction )
elseif tstate == “restored” then
print(tstate)
print(“Transaction restored (from previous session)”)
if transaction.productIdentifier == nonConsumable1 then – this can be canceled in the wallet
vault:set(“IAP1”, “unlocked”)
IAP1 = “unlocked”
print(“IAP1 was restored”)
end
if transaction.productIdentifier == nonConsumable2 then
vault:set(“IAP2”, “unlocked”)
IAP2 = “unlocked”
print(“IAP2 was restored”)
end
if IAPRestore == “unlocked” then
native.showAlert(“Thank you”, “Your purchases have been restored.”, {“Okay”})
end
vault:save()
store.finishTransaction( transaction )
elseif tstate == “refunded” then
print(tstate)
print( “product identifier”, transaction.productIdentifier )
print( “receipt”, transaction.receipt )
print( “transaction identifier”, transaction.identifier )
print( “date”, transaction.date )
print( “original receipt”, transaction.originalReceipt )
print( “original transaction identifier”, transaction.originalIdentifier )
print( “original date”, transaction.originalDate )
print(“User requested a refund – locking app back”)
if transaction.productIdentifier == nonConsumable1 then – this can be canceled in the wallet
vault:set(“IAP1”, “locked”)
IAP1 = “locked”
print(“IAP1 was locked for refund”)
end
if transaction.productIdentifier == nonConsumable2 then
vault:set(“IAP2”, “locked”)
IAP2 = “locked”
print(“IAP2 was locked for refund”)
end
if IAPRestore == “unlocked” then
native.showAlert(“Thank you”, “Your purchases have been refunded.”, {“Okay”})
end
vault:save()
store.finishTransaction( transaction )
elseif tstate == “cancelled” then
print(tstate)
print(“User cancelled transaction”)
store.finishTransaction( transaction )
elseif tstate == “failed” then
print(tstate)
print(“Transaction failed, type:”, transaction.errorType, transaction.errorString)
native.showAlert(“Transaction Failed”, " type:" …transaction.errorType …"String: " …transaction.errorString, {“Okay”})
store.finishTransaction( transaction )
elseif tstate == “consumed” then
if transaction.productIdentifier == consumable1 then
print(“Consumable 1 was consumed”)
end
if transaction.productIdentifier == consumable2 then
print(“Consumable 2 was consumed”)
end
store.finishTransaction( transaction )
else
print(“unknown event”)
store.finishTransaction( transaction )
end
vault:save()
print(“Finsihed with Store”)
end
timerStash.storeInit = timer.performWithDelay(1000, function() store.init( “google”, transactionCallback ) end, 1)
if (store.isActive) then
print(“Continuous Restore Check Fired”)
timerStash.storeRestoreTimer = timer.performWithDelay(15000, function() store.restore() end, 1)
end
[/lua]