Forum Discussion

ionatan's avatar
ionatan
Roku Guru
12 months ago

getPurchases returns Unknown Error when is called before screen.show

Hello,

We are using getPurchases https://developer.roku.com/en-gb/docs/references/scenegraph/control-nodes/channelstore.md#getpurchases in order to get Subscription Purchases.

We are calling that before Channel content is loaded in order to find out if the user is a subscriber and to load content within different API parameters if that's the case.

Recently we noticed that getPurchases returns "-3: Unknown Error" status if it is called before screen.show(). In order to fix this we need to move getPurchases call after screen.show(), but if we do that the content is already loaded when Channel gets the purchases.

Did you experienced similar behaviors? Any solution for this?

This is the code used to get purchases:

store = CreateObject("roChannelStore")
port = CreateObject("roMessagePort")
store.SetMessagePort(port)
store.GetPurchases()

while (true)
	msg = wait(0, port)
	if (type(msg) = "roChannelStoreEvent")
		if (msg.isRequestSucceeded())
			for each item in msg.GetResponse()
				result.validPurchased.map[item.code] = item
			end for
			exit while
		else if (msg.isRequestFailed())
			print "***** Failure: " + msg.GetStatusMessage() + " Status Code: " + stri(msg.GetStatus()) + " *****"
			exit while
		end if
	end if
end while

 

  • Sounds like a bug in `roChannelStore` implementation, since it should not need RSG for non-UI calls like `getPurchases()`. This may have regressed in recent change since a case that likely is rare (most apps first prop-up the UI) and not tested 

    • renojim's avatar
      renojim
      Community Streaming Expert

      EnTerr, a voice from the distant past!  I thought you were supposed to take care of all of Roku's failings.  😜

      • EnTerr's avatar
        EnTerr
        Roku Guru

        renojim wrote:

        EnTerr, a voice from the distant past!  I thought you were supposed to take care of all of Roku's failings.  😜


        i did all i could (and then some πŸ˜‰) for a few years, as a cog in the belly of the beast. And now i am back to my OG self, as you can see