简体   繁体   English

Google Play应用内结算:测试购买无效+没有可用的产品详细信息

[英]Google Play In-App Billing: Test purchase does not work + No product details available

I am trying to add Googles In-App Billing to my Android 4+ app. 我正在尝试将Googles应用内结算添加到我的Android 4+应用中。 I have set up everything as described in " Preparing Your In-app Billing Application ". 我已经按照“ 准备应用内结算应用程序 ”中所述进行了所有设置。 Now I have uploaded the app to the Alpha testing channel in the Developer console. 现在,我已将该应用程序上载到开发人员控制台中的Alpha测试频道。

Additionally I have set up a test account ( described here ) to be able purchase the items without triggering a real payment. 另外,我已经建立了一个测试帐户( 在此描述 ),可以在不触发实际付款的情况下购买商品。

After installing the alpha version from the Play Store on my test device (using the test account of course) there a two problems: 在我的测试设备上通过Play商店安装Alpha版本(当然使用测试帐户)后,出现两个问题:

  1. No product information is fetched from the Play Store. 没有从Play商店获取产品信息。 Thus I cannot show any price information, etc. 因此,我无法显示任何价格信息等。

  2. When I start a purchase there is absolutly no hint, that this will be a free test purchase. 当我开始购买时,没有任何暗示,这将是一次免费的测试购买。 Everything looks exactly like a real purchase. 一切看起来都像是真正的购买。

This is the code I use: 这是我使用的代码:

String publicKey = MyApp.getPublicKey(); // de-code and get the public key
final IabHelper googlePlayHelper = new IabHelper(context, publicKey);

Log.d("TAG", "IabHelber Init");

googlePlayHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
    public void onIabSetupFinished(IabResult result) {
        if (!result.isSuccess()) {
            Log.d("TAG", "IabHelber Init - Non Success: " + result);
        } else {
            Log.d("TAG", "IabHelber Init - SUCCESS");
            try {
                googlePlayHelper.queryInventoryAsync(true, new IabHelper.QueryInventoryFinishedListener() {
                    public void onQueryInventoryFinished(IabResult result, Inventory inventory) {
                        if (result.isFailure()) {
                            Log.d("TAG", "query Inventory - Non Success: " + result);
                        } else {
                            Log.d("TAG", "query Inventory - SUCCESS");

                            if (inventory.hasDetails(2my.product.id")) {
                                Log.d("TAG", "NO DETAILS");
                            } else {
                                Log.d("TAG", "Has Details");
                            }
                        }
                    }
                }      
            } catch (Exception e) { 
                Log.d("TAG", "EXCEPTION: " + e.getMessage());
            }
        }
    }
});

The Log shows the following: 日志显示以下内容:

D/TAG (25995): IabHelber Init
D/TAG (25995): IabHelber Init - SUCCESS
D/TAG (25995): query Inventory - SUCCESS
D/TAG (25995): NO DETAILS

What could be the reason that now details are fetched? 现在获取详细信息的原因可能是什么? The docs that that there should be an hint when performing a test purchase. 在进行测试购买时应该有提示的文档。 Why am I runnig a "real" purchase instead? 为什么我会选择“真实”购买?

I have not been able to find out why purchases by test users are not handled as test purchases. 我无法找出为什么测试用户的购买不作为测试购买处理的原因。 But the problem with the missing product details is solved: 但是解决了缺少产品详细信息的问题:

I used the following call to query the inventory: 我使用以下调用查询库存:

googlePlayHelper.queryInventoryAsync(true, new IabHelper.QueryInventoryFinishedListener() { ... });

This is totally valid code and the first parameters (true in this example) states, that the query should fetch the product details. 这是完全有效的代码,第一个参数(在此示例中为true)指出查询应获取产品详细信息。 But it seems, that this parameter does not have any effect until a further parameter is given: One has to explicitly specify the IDs of the product one would like to fetch: 但是似乎该参数在给出另一个参数之前没有任何作用:必须明确指定要获取的产品的ID:

List<String> productIDs = new ArrayList<String>();
productIDs.add(IAP_ID_1);
productIDs.add(IAP_ID_2);
productIDs.add(IAP_ID_3); 

googlePlayHelper.queryInventoryAsync(true, productIDs, new IabHelper.QueryInventoryFinishedListener() { ... });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Google应用内结算取消测试购买 - Google in-app billing cancel test purchase 使用 google play 计费库的不同语言的应用内产品详细信息 - In-app product details in different languages using the google play billing library 应用内结算 - 无法购买请求的项目 - In-app Billing - Item requested not available for purchase 应用内结算响应的唯一产品ID。 Google Play - Unique product ID for in-app billing resp. Google Play 使用 Google Play 结算,是否可以等到确认购买后才授予应用内购买的权利? - With Google Play Billing, is it okay to wait with granting entitlement to an in-app purchase until after the purchase has been acknowledged? 将APK的草稿上传到Google Play中以测试应用内结算 - Uploading draft of APK into Google Play to test In-App Billing Google Play应用内结算第3版是否支持退款? - Does Google Play In-App Billing Version 3 support refunds? Google Play In-app billing version 3 购买的服务器端验证 - Server-side verification of Google Play In-app billing version 3 purchase Google Play应用内结算版本3购买的服务器端验证(第2部分) - Server side verification of Google Play in-app billing version 3 purchase (part 2) 如何使用Google Play应用内结算购买多个商品 - How to make Multiple items purchase using Google Play in-app billing
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM