In-App Purchase Android,Buy same item over and over without consumption
<p>Good day.I am implementing in-app purchase into android.The only items which shall be bough are coins.And by idea coins can be bought over and over.But as we know the google play in-app purchase keeps the item as purchased,and you can buy it only after consumption.So what is an best practice for this situation?Like i want to let user buy same coin pack over and over.What is the code for it?
This is the code i am using for in-app purchase flow.</p>

<pre><code> private ServiceConnection serviceConnection = new ServiceConnection() {
    @Override
    public void onServiceDisconnected(ComponentName name) {
        mService = null;
    }

    @Override
    public void onServiceConnected(ComponentName name,
                                   IBinder service) {
        mService = IInAppBillingService.Stub.asInterface(service);

        try {
            Bundle ownedItems = mService.getPurchases(3, getPackageName(), "inapp", null);
            Log.d("Fasfsafasfasfa", "onServiceConnected: "+ownedItems);

            int response = ownedItems.getInt("RESPONSE_CODE");
            Log.d("Fasfsafasfasfa", "onServiceConnected: "+response);

            if (response == 0) {
                ArrayList&lt;String&gt; ownedSkus =
                        ownedItems.getStringArrayList("INAPP_PURCHASE_ITEM_LIST");
                ArrayList&lt;String&gt; purchaseDataList =
                        ownedItems.getStringArrayList("INAPP_PURCHASE_DATA_LIST");
                ArrayList&lt;String&gt; signatureList =
                        ownedItems.getStringArrayList("INAPP_DATA_SIGNATURE_LIST");
                String continuationToken =
                        ownedItems.getString("INAPP_CONTINUATION_TOKEN");


                Log.d("Fasfsafasfasfa", "onServiceConnected: "+ownedSkus.size());
                Log.d("Fasfsafasfasfa", "onServiceConnected: "+purchaseDataList.size());
                Log.d("Fasfsafasfasfa", "onServiceConnected: "+signatureList.size());
                Log.d("Fasfsafasfasfa", "onServiceConnected: "+continuationToken);

                for (int i = 0; i &lt; purchaseDataList.size(); ++i) {
                    String purchaseData = purchaseDataList.get(i);
                    String signature = signatureList.get(i);
                    String sku = ownedSkus.get(i);

                    // do something with this purchase information
                    // e.g. display the updated list of products owned by user
                    Log.d("Fasfsafasfasfa", "onServiceConnected: " + "purchased items are" + sku + " " + signature + " " + purchaseData);
                }

                // if continuationToken != null, call getPurchases again
                // and pass in the token to retrieve more items
            }


            Bundle buyIntentBundle = mService.getBuyIntent(3, getPackageName(),
                    "small_pack", "inapp", "bGoa+V7g/yqDXvKRqq+JTFn4uQZbPiQJo4pf9RzJ");
            PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT");
            startIntentSenderForResult(pendingIntent.getIntentSender(),
                    1001, new Intent(), Integer.valueOf(0), Integer.valueOf(0),
                    Integer.valueOf(0));
        } catch (RemoteException e) {
            e.printStackTrace();
        } catch (IntentSender.SendIntentException e) {
            e.printStackTrace();
        }
    }
};
</code></pre>

<p>I have noticed this issue because on very first purchase everything is going fine,and whenever i try to buy same sku named item again,i get the fatal exception like this</p>

<pre><code> java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.IntentSender android.app.PendingIntent.getIntentSender()' on a null object reference
                                                 at ink.va.activities.BuyCoins$1.onServiceConnected(BuyCoins.java:103)
</code></pre>

<p>Which i can reckon means that i must first consume purchase and only after that again let user buy it..Am i right?Anyway who have a suggestion of this issue please?</p>