WHEN I ADDED COMMENTED PART BELOW THE FIRST RESTORE BUTTON TO BE TOUCHED WILL TRIGGER BOTH RESTORES. IT DOESNT MATTER IN WHICH ORDER. WHEN RESTORE WORKED CORRECTLY I DIDNT INCLUDE “(trans.productIdentifier == productID[1])” BUT I ADDED IT LATER WHEN I ADDED THE 2ND RESTORE AND I FIGURED THAT WOULD DIFFERENTIATE BETWEEN RESTORES. I JUST COPIED THE CODE FROM “(trans.state == “purchased”)” WHICH HAS (trans.productIdentifier == productID[1]) AND productID[2]. THOSE WORK PERFECTLY.
<lua>
function transactionCallback(e)
local trans = e.transaction;
if (trans.state == “purchased”) then
if (trans.productIdentifier == productID[1]) then --item1
callTimer()
myIAP1:store(‘iap20’,4)
myIAP1:save()
native.showAlert(“Thank You!” , “IAP Purchased.” , {“OK”}, none);
elseif (trans.productIdentifier == productID[2]) then --item2
myIAP2:store(‘iap21’,4)
myIAP2:save()
hintpage()
native.showAlert(“Thank You!” , “IAP Purchased.” , {“OK”}, none);
print (“success buying product 2! Give the user the item here or in the callback (see comments above)”);
end
elseif (trans.state == “restored”) then
if (trans.productIdentifier == productID[1]) then
callTimer()
myIAP1:store(‘iap20’,4)
myIAP1:save()
native.showAlert(“Thank You!” , “IAP Restored.” , {“OK”}, none);
question repeated here:
--WHEN I ADDED COMMENTED PART BELOW THE FIRST RESTORE BUTTON TO BE TOUCHED WILL TRIGGER BOTH RESTORES (above and below).
--IT DOESNT MATTER IN WHICH ORDER. WHEN 1 RESTORE WORKED CORRECTLY I DIDNT INCLUDE “(trans.productIdentifier == productID[1])” (above)
--BUT I ADDED IT LATER WHEN I ADDED THE 2ND RESTORE(below commented part) AND I FIGURED THAT WOULD DIFFERENTIATE BETWEEN RESTORES. I JUST COPIED
--THE CODE FROM “(trans.state == “purchased”)” WHICH HAS (trans.productIdentifier == productID[1]) AND productID[2]. THOSE WORK PERFECTLY
--[[
elseif (trans.productIdentifier == productID[2]) then
myIAP2:store(‘iap21’,4)
myIAP2:save()
hintpage()
native.showAlert(“Thank You!” , “IAP Restored.” , {“OK”}, none);
--]]
end
elseif (trans.state == “cancelled”) then
print (“player cancelled; you may want to show an alert here”);
native.showAlert(“Oops!” , “Cancelled.” , {“Dismiss”}, none);
elseif (trans.state == “failed”) then
print (“transaction failed”);
native.showAlert(“Oops!” , “Please check your internet connection and try again.” , {“Dismiss”}, none);
end
end