Connecting Website to Particle grabbing live data

Here is a quick overview of what I want: On my website the user purchases an activation code. With that code they enter it on the website and I check to see if that code is valid by seeing if its in my SQLDatabase, once it’s entered and validated it calls a function on the particle that then sends data back which I want to live grab (without refreshing the page). What is the best way to do this securely so that people cant just call the function to access the particle through developer console?

Would really appreciate some advise, maybe some example projects that do things like this. Thank you!!