Samsung IAP SDK
-
Upload
manikantan-krishnamurthy -
Category
Technology
-
view
965 -
download
3
description
Transcript of Samsung IAP SDK
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.
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
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
Subscriptions
Subscriptions are convenient for recurring periodic purchases.
Eg : Magazines or TV shows or newspapers
A simple purchase flow Hotel Story
A simple purchase flow Hotel Story
• Check IAP installation Intent serviceIntent = new Intent(
"com.sec.android.iap.service.iapService" );
Boolean flag = getPackageManager().queryIntentServices( serviceIntent, 0 ).isEmpty()
Step 1 IAP install 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);
Step 2 Samsung Account check
Intent serviceIntent = new Intent( "com.sec.android.iap.service.iapService" );
bindService( serviceIntent, mServiceConn, Context.BIND_AUTO_CREATE );
Step 3 Bind with 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 );
Step 4 Setup 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 );
Step 5 Functions on IAPConnector
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 );
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.
Step 6 Purchase
Unbind IAPConnector and Service Connection Object.
This after all IAP operations are completed and to release the associated resources
unbindService( mServiceConn );
Step 7 Unbind IAPConnector
http://developer.samsung.com/android/tools-sdks/In-App-Purchase-Library
Includes sample code, technical documentation and FAQ.
Manikantan K [email protected]
@manikantan_k
Resources