Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
iab:restore() issue — Gideros Forum

iab:restore() issue

I can't seem to restore previously purchased items. The items are not consumable and when I call iab:restore() I receive a RESTORE_COMPLETE event. However no purchase events are being raised for previously purchased items as described in the example code..

--[[ RESTORING PURCHASES ]]--
-- we can either provide button to restore purchases or launch it on every app start
-- this will simply launch purchase event for every unconsumable item
Here is my code...
-- in app purchasing
if DEBUGGING then
  iab = {}
  iab.addEventListener          = function() print('IAB addEventListener') end
  iab.setUp                     = function() print('IAB setup') end
  iab.isAvailable               = function() print('IAB isAvailable') end
  iab.requestProducts           = function() print('IAB requestProducts') end
  iab.restore                   = function() print('IAB restore') end
  iab.purchase                  = function() print('IAB purchase') end
  iab.setConsumables            = function() print('IAB setConsumables') end
  iab.setProducts               = function() print('IAB setProducts') end
else
  require 'iab'
  iab = IAB.new('google')
end
 
iab:setUp(IAB_KEY)
 
iab:setProducts({remove_adverts = "remove_adverts"})
 
iab:addEventListener(Event.AVAILABLE, function(e)
	print("IAB_AVAILABLE")
  SHOP_READY = true
 
	iab:addEventListener(Event.PRODUCTS_COMPLETE, function(e)
		for i = 1, #e.products do
			local p = e.products[i]
      print("IAB_PRODUCTS_COMPLETE")
			print(p.productId..", "..p.title..", "..p.description..", "..p.price)
		end
	end)
 
	iab:addEventListener(Event.PRODUCTS_ERROR, function(e)
    print("IAB_PRODUCTS_ERROR")
		print(e:getType()..", "..e.error)
	end)
 
  iab:requestProducts()
 
	iab:addEventListener(Event.PURCHASE_COMPLETE, function(e)
    local prefs = PREFS
    local game = GAME
    game.purchaseInProgress = false
    print("IAB PURCHASE_COMPLETE. " .. e.productId .. ', '.. e.receiptId)
    local product = e.productId
    if product == 'remove_adverts' then
      prefs.noAds = true
      prefs:savePrefs()
      admob:hideAdd('banner')
    end
	end)
 
	iab:addEventListener(Event.PURCHASE_ERROR, function(e)
    local game = GAME
    game.purchaseInProgress = false
    print("IAB PURCHASE_ERROR. " .. e.error)
	end)
 
  iab:addEventListener(Event.RESTORE_COMPLETE, function(e)
    print('IAB_RESTORE_COMPLETE. ' .. e:getType())
  end)
 
	--[[ RESTORING PURCHASES ]]--
	-- we can either provide button to restore purchases or launch it on every app start
	-- this will simply launch purchase event for every unconsumable item
	iab:restore()
end)
iab:isAvailable()

Likes: totebo, Apollo14

Tagged:
+1 -1 (+2 / -0 )Share on Facebook

Comments

Sign In or Register to comment.