如何使用 PHP 检测是否从 Google Checkout 购买了商品?
我正在制作一个网络应用程序,该应用程序将以免费和付费形式提供。我想让它检测用户是否已使用 Google Checkout 支付付费版本的费用,并启用付费功能(如果有)。
我将如何在 PHP 中执行此操作?
更新 我的数据库中已经有一个用户表,并且用户需要登录才能使用该应用程序。我还将创建一个名为 purchases 的表,其中包含以下内容:
- userid 内部使用的帐户 ID
- chitchat (应用程序的名称) NULL或 Google 订单 id
然后,当我需要检测用户是否购买了它时,我会使用
$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
}
但是,如果我的服务器被黑客攻击,我将如何向 Google 确认订单 id?
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:
- userid An internally used account id
- chitchat (the name of the app) NULL or a Google order id
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
鉴于您分享的有关网络应用程序的信息非常少,因此很难给出准确的答案,但这里有一些提示:
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: