I have implemented In-App purchase with API 3 and for testing I published apk as alpha test version. I am able to make purchase using my test account ,it work fine . But I need to check restore functionality but purchase state is not changing as apk is in alpha test.
How can I check restore functionality before I publish?please help me.
mHelper = new IabHelper(this, base64EncodedPublicKey);
// enable debug logging (for a production application, you should set this to false).
mHelper.enableDebugLogging(true);
// Start setup. This is asynchronous and the specified listener
// will be called once setup completes.
Log.d(TAG, "Starting setup.");
mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
public void onIabSetupFinished(IabResult result) {
Log.d(TAG, "Setup finished.");
if (!result.isSuccess()) {
// Oh noes, there was a problem.
complain("Problem setting up in-app billing: " + result);
return;
}
// Have we been disposed of in the meantime? If so, quit.
if (mHelper == null) return;
// IAB is fully set up. Now, let's get an inventory of stuff we own.
Log.d(TAG, "Setup successful. Querying inventory.");
ArrayList<String> skuList = new ArrayList<String> ();
skuList.add("purchase.test");
skuList.add("purchase.test2");
skuArray = new JSONArray(skuList);
mHelper.queryInventoryAsync(true, skuList, mQueryFinishedListener);
}
});
}
IabHelper.QueryInventoryFinishedListener mQueryFinishedListener = new IabHelper.QueryInventoryFinishedListener() {
public void onQueryInventoryFinished(IabResult result, Inventory inventory)
{
if (result.isFailure()) {
Log.v("Menu", "RESULT FALIURE");
return;
}
Log.v("Menu", "this +" + skuArray);
Log.v("Menu", "Inventory +" + inventory);
for(int i = 0; i < skuArray.length(); i++){
try {
String SKU = skuArray.getString(i);
if(inventory.getSkuDetails(SKU) != null){
Toast.makeText(getApplicationContext(), "SKU = " + SKU+" .... "+inventory.hasPurchase(SKU), Toast.LENGTH_LONG).show();
Log.v("Menu", "SKU = " + SKU+" .... "+inventory.hasPurchase(SKU));
Log.v("Menu", "SKU" + SKU + "= " + inventory.getSkuDetails(SKU).getTitle());
}else{
Log.v("Menu", "SKU RETURNED NULL" + SKU);
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
};