无法测试应用程序内订阅应用程序、测试

2023-09-13 23:59:04 作者:" 损坏的右键 °

我无法找到一个方法来测试 InApp订阅与=的productIDandroid.test.purchased由谷歌即私有最终字符串测试产品ID; //由谷歌测试产品编号

I couldn't find a way to test InApp Subscription with the test product ID by google i.e. private final String productID = "android.test.purchased"; // Test Product ID by Google

在文档不写任何地方InAPP订阅couldn '吨,试验产品进行测试,也不是任何地方提到,如何测试InApp订阅。

In the docs it is not written anywhere that InAPP subscription couldn't be tested with test product nor it is mentioned anywhere,how to test InApp subscription.

我已经实现了我的code以下文档(InAppV3)。

I have implemented my code following docs(InAppV3).

该医生说:

实现订阅: 发射用于订阅购买流程类似于发起对产品购买流,不同之处在于该产品类型必须设置为潜艇。本次收购结果被传递到你的活动的onActivityResult方法,正是因为在应用内产品的情况。的

Implementing Subscriptions: Launching a purchase flow for a subscription is similar to launching the purchase flow for a product, with the exception that the product type must be set to "subs". The purchase result is delivered to your Activity's onActivityResult method, exactly as in the case of in-app products.

和我也实现了正常。

我的应用程序工作,如果我取代inapp是潜艇,即这是工作完美的产品,而不是用于订阅。

My app is working if I replace "inapp" with "subs",i.e. it is working perfectly for products and not for subscriptions.

当我更改inapp为潜艇,然后购买的是返回:

When I change "inapp" to "subs" then the purchase is returning:

09-24 14:01:12.943: I/(16929): isBillingSupported() - success : return 0
09-24 14:01:12.943: D/Finsky(2598): [281] InAppBillingUtils.getPreferredAccount: com.kgandroid.inappsubscriptiondemo: Account from first account - [MOn42QuZgF98vxJi0p3wAN3rfzQ]
09-24 14:01:12.943: I/(16929): getPurchases() - success return Bundle
09-24 14:01:12.943: I/(16929): getPurchases() - "RESPONSE_CODE" return 0
09-24 14:01:12.943: I/(16929): getPurchases() - "INAPP_PURCHASE_ITEM_LIST" return []
09-24 14:01:12.943: I/(16929): getPurchases() - "INAPP_PURCHASE_DATA_LIST" return []
09-24 14:01:12.943: I/(16929): getPurchases() - "INAPP_DATA_SIGNATURE" return null
09-24 14:01:12.943: I/(16929): getPurchases() - "INAPP_CONTINUATION_TOKEN" return null

正如你所看到的任何细节 android.test.purchased 是returning.The测试inapp购买对话框也不开放

As you can see no details for android.test.purchased is returning.The test inapp purchase dialog is also not opening.

相关采购的 code (虽然这是不相关的问题,我猜):

The relevant purchase code(Though it is not related to the problem I guess):

void purchase()
{
    if (!blnBind) return;
    if (mService == null) return;

    ArrayList<String> skuList = new ArrayList<String>();
    skuList.add(productID);
    Bundle querySkus = new Bundle();
    querySkus.putStringArrayList("ITEM_ID_LIST", skuList);

    Bundle skuDetails;
    try {
        skuDetails = mService.getSkuDetails(3, getPackageName(), "subs", querySkus);
        System.out.println(skuDetails);
        Toast.makeText(context, "getSkuDetails() - success return Bundle", Toast.LENGTH_SHORT).show();
        Log.i(tag, "getSkuDetails() - success return Bundle");
    } catch (RemoteException e) {
        e.printStackTrace();

        Toast.makeText(context, "getSkuDetails() - fail!", Toast.LENGTH_SHORT).show();
        Log.w(tag, "getSkuDetails() - fail!");
        return;
    }

    int response = skuDetails.getInt("RESPONSE_CODE");
    Toast.makeText(context, "getSkuDetails() - \"RESPONSE_CODE\" return " + String.valueOf(response), Toast.LENGTH_SHORT).show();
    Log.i(tag, "getSkuDetails() - \"RESPONSE_CODE\" return " + String.valueOf(response));

    if (response != 0) return;

    ArrayList<String> responseList = skuDetails.getStringArrayList("DETAILS_LIST");
    Log.i(tag, "getSkuDetails() - \"DETAILS_LIST\" return " + responseList.toString());

    if (responseList.size() == 0) return;

    for (String thisResponse : responseList) {
        try {
            JSONObject object = new JSONObject(thisResponse);

            String sku = object.getString("productId");
            String title = object.getString("title");
            String price = object.getString("price");

            Log.i(tag, "getSkuDetails() - \"DETAILS_LIST\":\"productId\" return " + sku);
            Log.i(tag, "getSkuDetails() - \"DETAILS_LIST\":\"title\" return " + title);
            Log.i(tag, "getSkuDetails() - \"DETAILS_LIST\":\"price\" return " + price);

            if (!sku.equals(productID)) continue;

            Bundle buyIntentBundle = mService.getBuyIntent(3, getPackageName(), sku, "subs", "bGoa+V7g/yqDXvKRqq+JTFn4uQZbPiQJo4pf9RzJ");

            Toast.makeText(context, "getBuyIntent() - success return Bundle", Toast.LENGTH_SHORT).show();
            Log.i(tag, "getBuyIntent() - success return Bundle");

            response = buyIntentBundle.getInt("RESPONSE_CODE");
            //Toast.makeText(context, "getBuyIntent() - \"RESPONSE_CODE\" return " + String.valueOf(response), Toast.LENGTH_SHORT).show();
            Log.i(tag, "getBuyIntent() - \"RESPONSE_CODE\" return " + String.valueOf(response));

            if (response != 0) continue;

            PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT");
            startIntentSenderForResult(pendingIntent.getIntentSender(), 1001, new Intent(), 0, 0, 0);
        } catch (JSONException e) {
            e.printStackTrace();
        } catch (RemoteException e) {
            e.printStackTrace();

            //Toast.makeText(context, "getSkuDetails() - fail!", Toast.LENGTH_SHORT).show();
            Log.w(tag, "getBuyIntent() - fail!");
        } catch (SendIntentException e) {
            e.printStackTrace();
        }
    } 
}

是否订阅了测试购买? 如果不是,如何测试订阅? 如果是的话,为什么谷歌将返回空值??

Does subscription supports test purchases?? If not,how to test subscription?? If yes,why google is returning null??

任何相关的文档或链接也将是有帮助的。

Any related docs or links will be also helpful.

推荐答案

我从来没有尝试过使用测试产品ID(android.test.purchased)测试潜艇,我不知道它会工作作为似乎是产品ID而不是订阅ID。我用实际认购的ID(即创建在谷歌Play开发者控制台),但我用一个帐户其他比我的开发人员帐户(例如:一个用于发布的应用程序)。

I've never tried testing subs using the Test Product ID ("android.test.purchased") and I'm not sure it would work as seems to be a Product ID not a Subscription ID. I use real subscription IDs (that I create on Google Play Developer Console), but I use an account other than my developer account (i.e. the one you use to publish the app).

如果你去 https://play.google.com/apps/publish/然后点击设置,你会看到一个名为Gmail帐户与测试接入领域。您可以键入与您要测试您的购买帐户的一个或多个的Gmail地址。任何帐户添加那里购买了认购将不收取和订阅将持续24小时。 (来源: http://developer.android.com/google/play/billing/ billing_testing.html 和我自己的经验)

If you go to https://play.google.com/apps/publish/ then click on Settings, you'll see a field called "Gmail accounts with testing access". You can type one or more gmail addresses for accounts with which you want to test your purchases. Any account added there that purchases a subscription will not be charged and subscriptions will last for 24 hours. (source: http://developer.android.com/google/play/billing/billing_testing.html and my own experience)

这是我的作品。虽然我做似乎已经发现了一个错误:Trying取消一个Android测试订阅给了我一个500的响应code

That works for me. Although I did seem to have found a bug: Trying to cancel an Android test subscription gives me a 500 response code

祝您的应用程序!

编辑:

从谷歌文档(的http://developer.android.com/google/play/billing/billing_testing.html#billing-testing-test)

您不能使用你的开发者账户,以测试完全在应用程序   因为谷歌支付的购买过程中不会让你买的物品   从你自己。

You cannot use your developer account to test the complete in-app purchase process because Google payments does not let you buy items from yourself.

您是否尝试过用其他帐户?

Have you tried using another account?