且构网

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

如何在没有打开购买对话框的情况下在我的Android应用程序中验证用户已完成购买?

更新时间:2022-11-03 16:18:56

您应该查询购买商品而不是launchPurchaseFlow。

You should query for purchased items instead of launchPurchaseFlow.


要检索用户从您的应用购买的信息,请拨打
应用内结算版本3服务中的getPurchases方法。
传入应用内结算API版本(3),您的通话应用的
套餐名称以及购买类型(inapp或
subs)的方法)。

To retrieve information about purchases made by a user from your app, call the getPurchases method on the In-app Billing Version 3 service. Pass in to the method the In-app Billing API version ("3"), the package name of your calling app, and the purchase type ("inapp" or "subs").



Bundle ownedItems = mService.getPurchases(3, getPackageName(),
"inapp", null); 




Google Play服务仅返回购买
当前登录到设备的用户帐户。

The Google Play service returns only the purchases made by the user account that is currently logged in to the device.

要查询活动订阅,请使用getPurchases方法,再次使用产品类型参数设置为
subs。

To query for active subscriptions, use the getPurchases method, again with the product type parameter set to "subs".



Bundle activeSubs = mService.getPurchases(3, "com.example.myapp",
                   "subs", continueToken);