The In-app Billing Version 3 API makes it easy to integrate In-app Billing into your applications. Features in this release include improved synchronized shopping flow, an API that allows you to easily track ownership of consumer products and local caching of purchase data in the app.
1. Check your code if you used supplies or not
If you used consumables, the user can purchase the product several times, Google stores only one purchase item and again receives an empty answer, so remove the consumption-related code from your application.
2. Check the goods already purchased or not, using the code below
private IInAppBillingService mService = null; //onCreare try { Intent serviceIntent = new Intent("com.android.vending.billing.InAppBillingService.BIND"); serviceIntent.setPackage("com.android.vending"); bindService(serviceIntent, mServiceConn, Context.BIND_AUTO_CREATE); // bindService(new Intent("com.android.vending.billing.InAppBillingService.BIND"), mServiceConn, Context.BIND_AUTO_CREATE); } catch (Exception e) { e.printStackTrace(); } // Method ServiceConnection mServiceConn = new ServiceConnection() { @Override public void onServiceConnected(ComponentName name, IBinder service) { mService = IInAppBillingService.Stub.asInterface(service); Log.d("TEST", "mService ready to go!"); checkownedItems(); } @Override public void onServiceDisconnected(ComponentName name) { mService = null; } }; private void checkownedItems() { try { Bundle ownedItems = mService.getPurchases(3, getPackageName(), "inapp", null); if (ownedItems.getInt("RESPONSE_CODE") == 0) { ArrayList<String> ownedSkus = ownedItems.getStringArrayList("INAPP_PURCHASE_ITEM_LIST"); ArrayList<String> purchaseDataList = ownedItems.getStringArrayList("INAPP_PURCHASE_DATA_LIST"); if (purchaseDataList.size() > 0) { // Item already Purchased.... // Manage your in-app view }else{ // Item not purchased } } } catch (RemoteException e) { e.printStackTrace(); } }
The logical element used above before purchasing, if the element is not purchased, then call in-app getPurchases (), otherwise hide or control the presentation in the application.
Elesh baraiya
source share