in app purchase android



  • I'm making built-in android purchases.

    Added to the code activates onCreate:

    String base64EncodedPublicKey;
            base64EncodedPublicKey = "ххх";
    
        // compute your public key and store it in base64EncodedPublicKey
        mHelper = new IabHelper(this, base64EncodedPublicKey);
    
        mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
            public void onIabSetupFinished(IabResult result) {
                if (!result.isSuccess()) {
                    // Oh noes, there was a problem.
                    Log.d("TEST", "Problem setting up In-app Billing: " + result);
                }
                Log.d("TEST", "ALL IS OK " + result);
                // Hooray, IAB is fully set up!
            }
        });
    

    And activate the class:

    IabHelper.OnIabPurchaseFinishedListener mPurchaseFinishedListener
    = new IabHelper.OnIabPurchaseFinishedListener() {
    public void onIabPurchaseFinished(IabResult result,
    Purchase purchase)
    {
    if (result.isFailure()) {
    // Handle error
    return;
    }
    else if (purchase.getSku().equals(ITEM_SKU)) {
    consumeItem();
    buybutton.setEnabled(false);
    }

        }
    };
    
    public void consumeItem() {
        mHelper.queryInventoryAsync(mReceivedInventoryListener);
    }
    
    IabHelper.QueryInventoryFinishedListener mReceivedInventoryListener
            = new IabHelper.QueryInventoryFinishedListener() {
        public void onQueryInventoryFinished(IabResult result,
                                             Inventory inventory) {
    
    
            if (result.isFailure()) {
                // Handle failure
            } else {
                mHelper.consumeAsync(inventory.getPurchase(ITEM_SKU),
                        mConsumeFinishedListener);
            }
        }
    };
    
    IabHelper.OnConsumeFinishedListener mConsumeFinishedListener =
            new IabHelper.OnConsumeFinishedListener() {
                public void onConsumeFinished(Purchase purchase,
                                              IabResult result) {
    
                    if (result.isSuccess()) {
                        //all is OK
                    } else {
                        // handle error
                    }
                }
            };
    
    
    public void buyClick(View view) {
        mHelper.launchPurchaseFlow(this, ITEM_SKU, 10001, mPurchaseFinishedListener, "mypurchasetoken");
    }
    

    I the release of the version signed by my key.
    Locked on a real device, added a test account in the console and the device.
    When you try to buy it, you're gonna have to google. What do we do?



  • We need to add testers in the alpha test, publish the APC (possibly in the alpha) and refer them to the application, they need to open it and accept it (which wants to become testers). Then switch to these scouts and set up an annex with a release signature. Try it, too.

    List<String> skuList = new ArrayList<String>();
    skuList.add("some_sku_001");
    mHelper.queryInventoryAsync(true, skuList, mGotInventoryListener);
    



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2