I am making a Web app that will be available in free and paid forms. I want to make it detect whether the user has paid for paid version using Google Checkout, and enable paid features if they have.
How would I do this in PHP?
Update I already have a user table in my database, and the user is required to log in to use the app. I will also create a table called purchases which will have the following:
Then when I need to detect if the user has bought it I would use
$userid=esc($_SESSION["id"]); // esc is a function that returns the SQL escaped string
if($query=mysqli_query($link,"SELECT * FROM purchases WHERE userid='$userid'")&&mysqli_num_rows($query)>0){
// The user has bought the paid version
}
But then, in case my server is hacked, how would I confirm the order id with Google?
Given the fact that you've shared very little information about your web app, it's difficult to answer with a precise answer but here are some pointers: