2. Introduction
• In-App Purchase enables you to sell various items from
inside your applications.
• In-App Purchase is only available for Android-based
applications for Samsung Apps.
• Currently, it supports more than 60 countries with Credit
card, P-SMS, and several local payment methods.
3. IAP v2
New version of library was released recently. Supports
• Consumable/non-consumable/subscription
• Account based purchase management (not IMEI based)
• Supports Samsung Single Sign On.
• Increased geographic coverage US via Credit card.
• Uses AIDL (Android Interface Definition Language) for a
more seamless user experience
4. Consumable Vs Non consumables
CONSUMABLES
One off purchase and cannot be restored.
Eg : Medikit, life points or coins in games.
NON CONSUMABLES
Restorable and are account based.
Eg : Unlock stages in a game, premium upgrade
10. Step 2 Samsung Account check
• Check Samsung Account on the phone
ComponentName com = new ComponentName(
"com.sec.android.iap",
"com.sec.android.iap.activity.AccountActivity" );
Intent intent = new Intent(); intent.setComponent( com );
startActivityForResult(intent, 1001);
11. Step 3 Bind with IAPConnector
Intent serviceIntent = new Intent(
"com.sec.android.iap.service.iapService" );
bindService( serviceIntent, mServiceConn,
Context.BIND_AUTO_CREATE );
12. Step 4 Setup IAPConnector
Init() must be first called before any IAP operation.
Init() setups basic account payment information
Call it on separate thread to avoid ANR.
Bundle result = mIAPConnector.init( mMode );
13. Step 5 Functions on IAPConnector
Call it on separate thread to avoid ANR.
Result is a Bundle along with a STATUS_CODE
Bundle itemList = mIAPConnector.getItemList( developerMode,
getPackageName(), _itemGroupId, _startIndexInList,
_endIndexInList,
_itemType );
14. Step 6 Purchase
Bundle bundle = new Bundle();
bundle.putString( "THIRD_PARTY_NAME", getPackageName() );
bundle.putString( "ITEM_GROUP_ID", _itemGroupId );
bundle.putString( "ITEM_ID", _itemId );
ComponentName com = new ComponentName( "com.sec.android.iap",
"com.sec.android.iap.activity.PaymentMethodListActivity" );
Intent intent = new Intent( Intent.ACTION_MAIN );
intent.addCategory( Intent.CATEGORY_LAUNCHER );
intent.setComponent( com );
intent.putExtras( bundle );
startActivityForResult( intent, 1000 );
15. Step 6 Purchase
Do Purchase in separate thread, to avoid ANR.
Returned result from purchase.
STATUS_CODE AND ERROR_STRING describe the outcome of
purchase.
RESULT_OBJECT is a big JSON, which includes info such as
purchaseID, purchase Date, price, item image etc.
16. Step 7 Unbind IAPConnector
Unbind IAPConnector and Service Connection Object.
This after all IAP operations are completed and to release the
associated resources
unbindService( mServiceConn );