且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Android In-App-Purchase,如何检查用户是否购买了一件商品

更新时间:2023-12-03 17:15:04

(1) 使用 Google Android IAP V3 时的***实践是什么?

(1) What is the best practice when I use Google Android IAP V3?

--> 官方文档说只有支付交易会由google play自己处理,但是在应用程序中你必须设置你的业务逻辑如何处理产品购买后的UI集成和其他事情.您还可以使用应用内购买 v3.

--> official document says that only payment transaction will be handle by google play itself, but in the application you have to set your business logic how you handle UI integration and other things after product purchase. You can also go with the in app purchase v3.

(2) 而且如果用户的设备没有安装 Google Play,我可能想使用 paypal 进行付款,但是如果我要求用户使用简单的 paypal 付款,如何跟踪购买并为用户解锁功能获取许可证密钥?我不想使用任何其他计费 SDK,如果使用 Paypal 网页购买许可证,如何实现?

(2) And also if user's device have no Google Play installed, I may want to use paypal to make the payment, but how to track the purchase and unlock the features for users if I ask user to use simple paypal payment to get a license key? I do not want to use any other billing SDK, if with Paypal web page to buy the license, How to implement this?

--> 您可以要求用户动态更新 google play 版本.Google 开发人员文档说 90% 以上的设备使用 2.2 操作系统并安装了 Google Play 商店.我不能说任何关于 paypal 交易的事情,因为我以前没有使用过它,但是在使用 v3 的应用程序购买中,实现和理解支付过程非常简单.

--> You can ask user to update google play version dynamically. Google developer doc says more than 90% device using 2.2 os with installed google play store. I could not say any thing about paypal transaction because I haven't use it before, but yes in app purchase using v3 is very simple to implement and understand the payment process.

如何在您的应用程序中使用

管理应用产品数据的三种方式.

Three way to manage your application's product data.

1) SharedPrefence:您可以使用共享优先值并检查它是否被购买.如果用户卸载了该应用程序然后重新安装该应用程序,则您可以检查用户是否已购买,此时您已购买该项目.并且您必须管理用户以访问您的应用程序数据.

1) SharedPrefrence: you can use the share prefrence value and check whether it is purchased or not. if in case user uninstalled the app and then re-install the app then you can check whether user has purchased or not, at this you get the item is already purchased. And you have to manage the user to access your application data.

2) 本地数据库:您还可以使用本地 sqlite 数据库来存储购买详细信息和购买状态.和上面一样,如果用户清除数据或卸载应用程序,然后再次请求购买商品并检查用户是否购买了商品.

2) local database: you can also use local sqlite database to store the purchase detail and purchase status. and same as above if user clear data or uninstall the app then request for the purchase item again and check whether user purchased item or not.

2) 服务器数据库:如果您使用 Web 服务器来存储用户数据,则与上述方法相比,这是更好的方法.在这种情况下,用户卸载应用程序或清除应用程序数据的情况下,您甚至不需要进行第二次管理.

2) Server database: It is the better way compare to above if you are using web server to store the user data. In this type, you doesn't even need to manage for the second time for the case if user uninstall the app or clear the application data.

3) 混淆:(与共享偏好相比最有效的方法)

在 SharedPreference 中设置一个值来标记用户已购买此项目是否可以且安全?如果用户在 SharedPreference 中修改此值会怎样.或者我每次都需要连接IAP服务来检查,然后用户才能使用它?

当我在互联网上搜索时,我发现 Nikolay Elenkov's 的答案如下:

While I am searching on internet I found Nikolay Elenkov's answer like below:

如果你只是在共享首选项中保存一个标志,任何具有 root 权限的用户设备可以随意翻转标志,无需付费即可订阅".所以你至少应该做一些混淆.这是一个示例方法它.此外,还有一个 API 来检查订阅状态,因此您应该定期检查以确保订阅有效.

If you just save a flag in shared preferences, any user with a rooted device can flip the flag at will and be 'subscribed' without paying. So you should at least do some obfuscation. Here's a sample way to do it. Additionally, there is an API to check for subscription state, so you should check periodically to make sure the subscription is valid.

更多信息查看尼古拉·埃伦科夫的回答

应用内购买或 Paypal 的***计费方式是什么?

这取决于产品类型,

--> 应用内结算:最适合谷歌应用内结算,

--> In app billing: Best for google in app billing,

对于包括可下载内容的数字产品,例如媒体文件或照片、游戏关卡或药水等虚拟内容、高级服务和功能等.

For the digital products including downloadable content such as media files or photos, virtual content such as game levels or potions, premium services and features, and more.

http://developer.android.com/google/play/billing/index.html

--> Paypal:最适合 Paypal 计费,

--> Paypal: Best for Paypal billing,

对于实体内容或产品,您想分享吗?你不是允许使用应用内购买"销售实物商品或服务由于通过这种方式购买的商品必须与商品直接相关使用它们的应用.

For physical content or product do you want to share. You are not permitted to sell physical goods or services using 'In-App Purchasing' since the goods purchased via this method must relate directly to the app using them.

购买实体产品来自 iPhone 应用程序,无需 Apple 应用程序内购买

希望能帮到你.