I'm getting started developing a channel w/ in app purchases. I have a demo private channel that has been published. I have 4 products associated with it, and the Roku UI indicates they have been approved.
The problem is when I go to retrieve the catalog in the app, it appears empty. When I test the channel as a side-loaded channel, the test products appear as expected, so I'm not sure there's an issue with the code.
Again, the channel is published, and all 4 products are also published and approved for sale.
I've attached the relevant code. Can anyone see any problems with it?
Function showDonateScreen()
port = CreateObject("roMessagePort")
screen = CreateObject("roParagraphScreen")
screen.setMessagePort(port)
screen.setTitle("Donate")
screen.addButton(0, "Select amount")
screen.addButton(1, "Cancel")
screen.setDefaultMenuItem(0)
screen.show()
while true
msg = wait(0, screen.getMessagePort())
if type(msg) = "roParagraphScreenEvent"
if msg.isButtonPressed()
if msg.getIndex() = 0
showDonationAmountScreen()
else
screen.close()
exit while
end if
else if msg.isScreenClosed() then
print "Poster Screen Closed!"
exit while
end if
end if
end while
End Function
Function showDonationAmountScreen()
port = CreateObject("roMessagePort")
screen = CreateObject("roListScreen")
screen.setMessagePort(port)
screen.setTitle("Select Donation Amount")
store = CreateObject("roChannelStore")
store.setMessagePort(port)
catalog = getCatalog(store)
if catalog = invalid
return -1
end if
items = createContentListFromProducts(catalog)
screen.SetContent(items)
screen.Show()
while true
msg = wait(0, screen.GetMessagePort())
if type(msg) = "roListScreenEvent" then
if msg.isListItemSelected() then
index = msg.GetIndex()
if makePurchase(store, catalog[index]) = true
' Close screen if completed transaction
screen.Close()
exit while
end if
else if msg.isScreenClosed() then
print "Poster Screen Closed!"
exit while
end if
end If
end while
End Function
Function getCatalog(store)
print "***** Catalog *****"
waitMsg = ShowPleaseWait()
store.GetCatalog()
while true
msg = wait(0, store.getMessagePort())
waitMsg.close()
if (type(msg) = "roChannelStoreEvent")
if (msg.isRequestSucceeded())
dumpResponse(msg.GetResponse())
return msg.GetResponse()
exit while
else if (msg.isRequestFailed())
ShowDialog1Button("Connection Failure", "There was a problem connecting to the server. Please try again lister.", "Ok")
print "***** Failure: " + msg.GetStatusMessage() + " Status Code: " + stri(msg.GetStatus()) + " *****"
return invalid
end if
end if
end while
End Function
Function createContentListFromProducts(items)
i = 0
list = []
for each item in items
i = i+1
list_item = {
Title: item.name
ID: stri(i)
code: item.code
cost: item.cost
}
list.Push(list_item)
end for
return list
End Function
Function makePurchase(store, product)
order = [{
code: product.code
qty: 1
}]
print "***** Placing Order, item code: " + toStr(order[0].code) + " quantity: " + toStr(order[0].qty)
val = store.SetOrder(order)
waitMsg = ShowPleaseWait()
res = store.DoOrder()
waitMsg.close()
if res = true
ShowDialog1Button("Transaction Complete", "Thank you!", "Continue")
return true
else
ShowDialog1Button("Transaction Failed", "Unable to complete transaction.", "Continue")
return false
end if
End Function
Function dumpResponse(list as object)
for each obj in list
for each element in obj
print toStr(element) + " = " + toStr(obj.lookup(element))
end for
end for
End Function