How I can purchase a Google Play product item multiple times?

Viewed 1825

I can buy only one item ("productitem1"). If I had purchase this item, I can't purchase it again. But I need it to buy it several times. In my Google Play Console, I can only choose between "Managed In-app Products" and "subs". I have setting it up to "Managed In-app Products".

@Override
protected void onActivityResult(int request, int response, Intent data) {
    if (request == 42) {
        int responseCode = data.getIntExtra("RESPONSE_CODE", 0);
        String purchaseData = data.getStringExtra("INAPP_PURCHASE_DATA");
        String dataSignature = data.getStringExtra("INAPP_DATE_SIGNATURE");
        if (response == RESULT_OK) {
            try {
                JSONObject jo = new JSONObject(purchaseData);
                String productId = jo.getString("productId");
                Toast.makeText(this, "OK", Toast.LENGTH_SHORT).show();
            } catch (JSONException e) {
                Log.e(getClass().getSimpleName(), "JSONException", e);
            }
        }
    }
}

btnBuy.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            final String name = "productitem1";
            try {
                Bundle buyIntentBundle = mService.getBuyIntent(3, getPackageName(), name, "inapp", "");
                if(buyIntentBundle.getInt("RESPONSE_CODE")==0) {
                    PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT");
                    startIntentSenderForResult(
                            pendingIntent.getIntentSender(), 42, new Intent(), Integer.valueOf(0), Integer.valueOf(0), Integer.valueOf(0));
                }
            } catch (Exception e) {
                Log.e(Start.this.getClass().getSimpleName(),"Exception:",e);
            }

        }
    });
2 Answers
IabHelper.OnConsumeFinishedListener onConsumeFinishedListener = new IabHelper.OnConsumeFinishedListener() {
        @Override
        public void onConsumeFinished(Purchase purchase, IabResult result) {
            try {
                Log.d("Tag", "this is onConsumeFinished - "+result.toString()+" and purchased"+purchase.toString());
                mHelper.consumeAsync(purchase,onConsumeFinishedListener);
            } catch (IabHelper.IabAsyncInProgressException e) {

                Log.d("Tag", "this is onConsumeFinished Error -  "+e.toString());
                e.printStackTrace();
            }
        }
    };
Related