In-app billing v3 test purchase not working across

2019-05-03 12:18发布

问题:

I have setup three Managed items in my developer account for in-app purchases, and my app is currently in the Beta channel on the Play Store.

I want to test the in-app purchase across two devices that use the same Google account -- but am finding that only the device that makes the purchase is correctly finding the purchase. The second device, using the same Google account, does not find the purchase.

Should test account billing work across any device that uses the same Google account?

I'm using the Billing helper libraries and here's my code at start-up to check for purchases:

ActivityStartUp.java

@Override
public void onIabSetupFinished(IabResult result) 
{
    if (!result.isSuccess()) 
    {
        LOGD(TAG, "In-app Billing setup failed: " + result);
        startApplication();
    } 
    else 
    {             
        LOGD(TAG, "In-app Billing is set up OK");

        // Query In-App billing for purchases
        mHelper.queryInventoryAsync(new QueryInventoryFinishedListener() 
        {
            @Override
            public void onQueryInventoryFinished(IabResult result, Inventory inv) 
            {
                if (inv.hasPurchase(Globals.ITEM1_SKU) || 
                    inv.hasPurchase(Globals.ITEM2_SKU) ||
                    inv.hasPurchase(Globals.ITEM3_SKU))
                {
                    // Store PRO purchase state
                    AccountUtils.setProVersion(ActivityStartUp.this, true);

                    LOGD(TAG, "Ad-free.  User has purchased the Upgrade :)");
                }
                else
                {
                    // Store PRO purchase state
                    AccountUtils.setProVersion(ActivityStartUp.this, false);

                    LOGD(TAG, "Using the free version, with Ads");
                }

                // Start the application
                startApplication();
            }
        });
    }
}