I am not an expert, but I will try to help here. I believe that in order to recover your purchased items you will need the SKU of the purchased items. And to pass the test that you will need to create real SKUs for your application. You can do this by adding your signed apk to beta testing and adding details to store listings. After that, you can add information about your purchased products in the "Products for applications" section. By doing so, you assign a Title, Description, Cost, and SKU (Product Identifier) ββfor each item you purchase in your application. Now, to recover your items, you need to have SKU of purchased items, etc.
You can do this by following these steps:
- To complete all the steps, follow these steps, but you will need your signed apk to test the functionality (you will upload the same to the developer console).
- In the IabHelper class, create your own method, call it getPurchasesDetail (). Use the following lines of code in this method:
Bundle ownedItems=mService.getPurchases(3, mContext.getPackageName(), "inapp", null); ArrayList<String> ownedSkus=new ArrayList<String>(); int response = ownedItems.getInt("RESPONSE_CODE"); if (response == 0) { ownedSkus = ownedItems.getStringArrayList("INAPP_PURCHASE_ITEM_LIST"); }
code>
Now the above lines will provide you with a list of purchased items in the array, enter the return type for your method and get it in your class where you need to restore purchases.
- In your class, where you want to restore your purchases, follow these steps:
iabHelper=new IabHelper(this, "you public here"); iabHelper.startSetup(new OnIabSetupFinishedListener() { @Override public void onIabSetupFinished(IabResult result) { if(result.isSuccess()) { try { ownedSkus=iabHelper.getPurchasesDetail();
code> 4. Now download the signed apk with this code and the public key in the developer's console (at the beta testing stage) and use the same apk to verify the execution that has been completed so far. But, buy items before restoration, do not forget to do it.
Hope this helps. Thanks.
source share