Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
ionatan
Roku Guru

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#getpurchas... 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

 

0 Kudos
3 REPLIES 3
EnTerr
Roku Guru

Re: getPurchases returns Unknown Error when is called before screen.show

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
Community Streaming Expert

Re: getPurchases returns Unknown Error when is called before screen.show

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

Roku Community Streaming Expert

Help others find this answer and click "Accept as Solution."
If you appreciate my answer, maybe give me a Kudo.

I am not a Roku employee.
0 Kudos
EnTerr
Roku Guru

Re: getPurchases returns Unknown Error when is called before screen.show


@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 

Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.