Samsung Apps IAP 2.0 Problems

I have been grappling with an annoying issue with the Samsung Apps IAP 2.0 libary for the last couple of weeks. I’m making this post for the purposes of trying to help others who run into similar issues.

Definition of Problem

The current API for using Samsung In-App-Billing is Samsung IAP 2.0. Many of the API calls require you to supply a mode, there are three possible values:

[java]final public static int IAP_MODE_TEST_SUCCESS = 1;
final public static int IAP_MODE_TEST_FAIL = -1;
final public static int IAP_MODE_COMMERCIAL = 0;[/java]

Item groups created in the Samsung dashboard can have two states:

  1. Temporary
  2. Sales

Twice Circled business blog - apps games and shared workspaces - samsung iap 2.0 error commercial test release mode certification

If your app is in IAP_MODE_TEST_SUCCESS mode then it can find and interact with your item group regardless of status. In IAP_MODE_COMMERCIAL mode, your app can only interact with item groups with sales status.

The problem is when you apply to get your app certified by Samsung, you need to supply your app in IAP_MODE_COMMERCIAL mode. However item groups are only given sales status after the app has been certified.

Catch 22.

The worst bit is that if you are using the provided helper class SamsungIapHelper then the standard behaviour is to bring up an error dialog which states:

“Product does not exist in this store (E9202/6005)”

This will likely cause the certification team to reject your app.

Forum posts which relate to this issue:

Forum post 1

Forum post 2

Solution

You need to alter the default behaviour to somehow mask the fact that the IAP items are temporarily missing so you can get it through certification. Once through certification your app needs to be able to automatically revert back to the standard behaviour when the item groups are given sales status.

Case Study: Ionage – Twice Circled Ltd.

Stop the error

In Ionage, I have a dedicated store page that lists all the items for sale. When the user navigates to here I call:[java gutter=false]samsungIapHelper.safeGetItemList(listener, badgeGroupId, startNum,   endNum, itemType);[/java]

This sets in motion a series of actions which will eventually return the requested list of items to the listener provided. However as described above, on commercial mode this will display an error dialog when it reaches this line of code in SamsungIapHelper:

[java num =1062]
// If error is occurred during loading list of product
// ============================================================
else {
dismissProgressDialog();
showIapDialog(mActivity, mActivity.getString(R.string.in_app_purchase), mActivity.getString(R.string.msg_failed_to_load_list_of_product) + “nn” + mErrorVO.getErrorString(), false, null);
Log.e(TAG, mErrorVO.getErrorString());
}
[/java]

You can stop it showing this error dialog simply by commenting out the following line:

[java gutter=false]showIapDialog(…);[/java]

Revert to correct behaviour
I made the default behaviour of the shop to show the following message “There are no items currently available from the Ionage store”. This stops the user trying to buy any items if they are not successfully found by the app.  However it’s important to make it revert to the correct behaviour once the item group is set to sales status.

I did this by replacing the stock text with the actual list of items in the following call back:

[java]
@Override
public void onSucceedGetItemList(ArrayList<ItemVO> itemList) {

}
[/java]

This method will only get called once the item group is set to sales status and the app has gone live, so you can be confident you won’t hit any more errors.

Notes for certification team

Finally I added the following explanation as a reference material to the certification team:

“The app uses IAP 2.0. This means when the app is set to release mode (as opposed to developer mode) the items available for purchase cannot be read into the app until they are marked as ‘sales’ instead of ‘temporary’. This will occur when the app passes certification. Therefore when you test it the Badges tab will state “No badges are currently available from the Ionage store”.

I have already tested the app on developer mode to test the purchases work correctly. See the ‘Video link for certification review reference’. It shows the process of purchasing a badge and redeeming old badge purchases working correctly. As soon as the app passes certification this is how the app will behave as the item group will be flagged as ‘sales’.”

… and provided the following YouTube video to prove the IAPs worked in developer mode:

http://www.youtube.com/watch?v=a1EudTSB5vU