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: 
kooljay68
Visitor

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("http://allbabestv.com/mcams/roku/getCredits.php?deviceID=" + 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("http://allbabestv.com/mcams/roku/chargeCustomer.php?deviceID=" + sn + "&cost=" + cost + "&model=" + model)
response = xfer.GetToString()
end Function


Any help would be greatly appreciated ... Thank you.
0 Kudos
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.