Roku Developer Program

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

Check and Charge Customer - Where to call functions from

Hello ... I have two functions I need to call to see if a person has the correct amount of tokens to play something and if they do then charge them when they hit play. The functions are listed below:

This one just pulls the amount of tokens a customer has in their account and compares to item.cost in XML feed:

Function tokenValidation() As Integer
sn = GetDeviceESN()
xfer = CreateObject("roURLTransfer")
xfer.SetURL("" + sn)
response = xfer.GetToString()
xml = CreateObject("roXMLElement")
if xml.Parse(response)
if (strtoi(xml.tokens) > item.cost)
return 0
end if
end if
return 1
end Function

and it the first function passes I want the feed to play and then run the second function. If the first function fails I want the feed to not allow play:

Function chargeCustomer()
sn = GetDeviceESN()
cost = item.cost
model = item.modelId
xfer = CreateObject("roURLTransfer")
xfer.SetURL("" + sn + "&cost=" + cost + "&model=" + model)
response = xfer.GetToString()
end Function

Any help would be greatly appreciated ... Thank you.
0 Kudos