samsung iap sdk

17
Manikantan K [email protected] @manikantan_k Samsung IAP

Upload: manikantan-krishnamurthy

Post on 01-Nov-2014

966 views

Category:

Technology


3 download

DESCRIPTION

Outlines the Samsung In App Purchase (iAP) SDK for Android.

TRANSCRIPT

Page 1: Samsung IAP SDK

Manikantan K

[email protected] @manikantan_k

Samsung IAP

Page 2: 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.

Page 3: Samsung IAP SDK

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

Page 4: Samsung IAP SDK

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

Page 5: Samsung IAP SDK

Subscriptions

Subscriptions are convenient for recurring periodic purchases.

Eg : Magazines or TV shows or newspapers

Page 6: Samsung IAP SDK

A simple purchase flow Hotel Story

Page 7: Samsung IAP SDK

A simple purchase flow Hotel Story

Page 8: Samsung IAP SDK
Page 9: Samsung IAP SDK

• 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

Page 10: Samsung IAP SDK

• 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

Page 11: Samsung IAP SDK

Intent serviceIntent = new Intent( "com.sec.android.iap.service.iapService" );

bindService( serviceIntent, mServiceConn, Context.BIND_AUTO_CREATE );

Step 3 Bind with IAPConnector

Page 12: Samsung IAP SDK

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

Page 13: Samsung IAP SDK

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

Page 14: Samsung IAP SDK

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

Page 15: Samsung IAP SDK

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

Page 16: Samsung IAP SDK

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