In App Purchase: two devices with the same account do not receive the same purchased items

What am I trying to do?

Purchasing products on the same Android device with a configured email address X. When I check another device configured for the same email address. but items purchased on the first device are not available on the other device.

What have i tried?

I tried using:

inappBillingService.getPurchases(InAppBuyActivity.INAPPVERSION, getPackageName(), "inapp", null); 

and also tried using:

 IabHelper.QueryInventoryFinishedListener mGotInventoryListener = new IabHelper.QueryInventoryFinishedListener() { public void onQueryInventoryFinished(IabResult result, Inventory inventory) { if (result.isFailure()) { // handle error here } else { // Not getting same purchased on both devices } } }; 

I generate a signed apk with the same version name and version code as in the playstore version.

+7
android in-app-billing
source share
2 answers

I tested the application using two devices. It takes time to reflect purchases.

If I delete the application and reinstall it as new, then there will be new items purchased. But, if I buy one item and check it on the second device, then at the same time it does not reflect.

The application shows items already purchased on the second device when the user tries to buy it. But its not available in inappBillingService.getPurchases and IabHelper.QueryInventory .

0
source share

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.

0
source share

All Articles