Android的应用内结算:购买状态将保持"购买"为了取消后,状态、Android、QUOT

2023-09-05 09:59:17 作者:一個比蒙牛还有猛的男人

我目前正在测试我InApp结算机制(使用InApp帐单3版的API,因此采取TrivialDrive例子作为参考)。

I'm currently testing my InApp billing mechanism (using the InApp Billing version 3 API, therefore taking the TrivialDrive example as reference).

我有一个管理项目,这是升级到premium版本。

I have one managed item, which is upgrade to premium version.

现在,购买该项目与我的测试帐户的作品,但是当我做了取消在谷歌结帐整个订单的事后,我的code还告诉我说,该项目是购买的,因此授予premium特色:

Now, purchasing the item with my test account works, but when I do a cancellation of the entire order in Google checkout afterwards, my code still tells me that the item is purchased an therefore grants the premium features.

下面是我如何检查是否购买我MainActivity。我不保存购买国家当地的地方,我的理解是,与计费API第3版,您可以购买专门为需要查询。

Here is how I check for the purchase in my MainActivity. I do not save the purchase state locally somewhere, as I understood that the with the billing API v3, you can query for purchases ad hoc as needed.

@Override
    protected void onStart() {
        // TODO Auto-generated method stub
        super.onStart();

        iabHelper = new IabHelper(this, Helper.getPKey());
        iabHelper.enableDebugLogging(true);

        iabHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {

            @Override
            public void onIabSetupFinished(IabResult result) {
                Log.d("IAB", "SETUP FINISHED");

                if(!result.isSuccess())
                {
                    Log.d("IAB", "SETUP NOT OK");
                    return;
                }
                else
                    Log.d("IAB", "SETUP OK");

                iabHelper.queryInventoryAsync(
                    new QueryInventoryFinishedListener() {

                        @Override
                        public void onQueryInventoryFinished(IabResult result, Inventory inv) {
                            Log.d("IAB", "Query inventory finished.");
                            if (result.isFailure()) {
                                Log.d("IAB","Failed to query inventory: " + result);
                                return;
                            }

                            Log.d("IAB", "Query inventory was successful.");

                            // Do we have the premium upgrade?
                            boolean mIsPremium = inv.hasPurchase(Helper.premiumSku);
                            Purchase p = inv.getPurchase(Helper.premiumSku);
                            if(p != null)
                                Log.d("IAB PURCHASE STATE", IabHelper.getResponseDesc(p.getPurchaseState()));
                            else
                                Log.d("IAB PURCHASE STATE", "Purchase is null");

                            Log.d("IAB", "User is " + (mIsPremium ? "PREMIUM" : "NOT PREMIUM"));


                        }
                    }                       

                );              
            }
        });       
    }

我不断收到getPurchaseState = 0,这意味着采购,甚至一小时后我取消了订单。为什么呢?

I keep getting getPurchaseState = 0, which means is Purchased, even one hour after I cancelled the order. Why?

推荐答案

第1步:等待约10分钟;直到你看到取消订单交付。在谷歌钱包。

Step 1. Wait approximately 10 minutes; Until you see the "cancelled order" was delivered. in your google wallet.

09月15日上午11时28分取消订单交付。

Sep 15 11:28 AM Cancelled The order was delivered.

09月15日11:18已取消您取消了此订单。原因:客户要求取消

Sep 15 11:18 AM Cancelled You cancelled this order. Reason: Customer request to cancel.

第2步:注销的设备上测试谷歌帐户,然后重新登录。

Step 2. Logout your test google account on the device and then re-login.

至少这解决了我的问题。

At least that solved my problem.