Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Search instead for 
Did you mean: 
ov2015
Level 7

how to stop roChannelStoreEvent when the screen is closed

Hi

I have used sample application for in app purchases in ROKU channels from the link https://blog.roku.com/developer/2013/06/06/supporting-in-app-purchases-in-your-roku-brightscript-cha.... Three screens used
1. main screen, which displays the option for the user to choose to go to purchase page.
2. purchase screen, it takes some time to display the products but purchase flow works without any errors
3. success screen, displays this paragraph screen once the payment is valid

While the user is in purchase screen and before the products load, if the user hits the back button, the user is taken back to Main screen but after few seconds redirects to success page. The user did not even started the purchase but they are taken to the success page.

The issue here is once the back button is clicked before the products are loaded, screen is closed for roListScreenEvent but roChannelStoreEvent still continues to go forward with its task which results in redirecting the screen to purchase page.


if (type(msg) = "roListScreenEvent")
if (msg.isListItemSelected())
index = msg.GetIndex()
this.MakePurchase(index)
else if msg.isScreenClosed() then ' takes the user back to main screen
return
endif
else if (type(msg) = "roChannelStoreEvent")
if msg.IsRequestSucceeded() then
print msg.GetResponse()
ShowParagraphScreen() 'displays the success screen
else if msg.IsRequestFailed() then
print msg.isRequestFailed(); "------------"
else if msg.isRequestInterrupted() then
print "interrupted"
end if
end if


Is there any option to stop roChannelStoreEvent along side roListScreenEvent once the screen is closed or back button is pressed?
Or am I doing something wrong here?
Let me know if you need the whole code sample to test.
0 Kudos