Skip to main content
Samsung Developer Program

SamsungIapHelper

IAP Helper provides methods to instantiate a SamsungIapHelper object, get the commercial product items offered for sale in the service app, get the items purchased by the current end user, and initiate the purchase and payment processing of an item.

 

getInstance( )

Instantiates the SamsungIapHelper object as a singleton, enables the processing of IAP method calls, and controls purchase and payment request processing according to the specified IAP operating mode.

public static SamsungIapHelper getInstance(Context _context, int _mode)
Request Parameters

_context

Required

Context

Android™ context.

_mode

Required

Integer

IAP operating mode that controls the processing of startPayment() purchase requests (All other IAP API requests are processed normally):

This parameter MUST be specified as a constant (MODE in example).

0           Commercial_Mode
Attempts to process all purchase requests as specified and returns the actual processing results (successful or failed).
NOTE: When the service app is operating in a commercial implementation (after the service is being distributed via Samsung Seller Office), successful purchase processing in this mode WILL result in financial transactions occurring (for example, end-user credit cards WILL be billed).

 1          Developer Test Mode (Success)
Attempts to process all purchase requests as specified and returns the actual processing results (successful or failed).

-1         Developer Test Mode (Failure)
Always results in failed processing of purchase requests and throws an exception.
NOTE: BOTH test modes (1 and -1) always BLOCK ALL financial transactions, whether the service app is operating in a commercial or development implementation.

getItemList( )

Available starting with IAP 3.0.

Gets the specified range and type(s) of commercial products items offer for sale in the service app with the item data specified by the OnGetInboxListener() callback, and returns the processing results.

Replaces the deprecated getItemList( ) because PackageName replaces itemGroupId.

public void getItemList(int _startNum, int _endNum, String _itemType, int _mode, OnGetItemListener _onGetItemListener)
Request Parameters

_startNum

Required

Integer

The lowest index number assigned to an item in the range of items to be returned (subject to the specified type and mode).

NOTE: The first item in the list is assigned number 1 (NOT 0).

_endNum

Required

Integer

The highest index number assigned to an item in the range of items to be returned (subject to the specified type and mode).

If _startNum = 1 and _endNum = 15 in a request, the first fifteen (15) items in the list will be returned when the request is successful AND the specified type and mode do NOT restrict the returned items.

_itemType

Required

String

Type of commercial product items to be returned:

00        Consumable (Consumable items) only.

01       NonConsumable (Nonconsumable items) only.

02        Subscription (Non-recurring subscription items) only.

03        Auto-Recurring Subscriptions only.

Supported since IAP 3.0

10        Return all types (in the specified range).

_mode

Required

Integer

IAP operating mode:

0       Commercial_Mode
Returns items regardless of successful or failed purchase processing.

 1       Developer Test Mode (Success)
ONLY returns items that were successfully purchased.

-1     Developer Test Mode (Failure)
ONLY returns items that were requested to be purchased but failed.

_onGetItemListener

Required

OnGet
Item
Listener

Name of the OnGetItemListener() interface that specifies the data and getItemList()processing results to be returned.

Returns

Processing results and data specified by the OnGetItemListener() callback.

getItemInboxList(_startNum, _endNum, _startDate, _endDate)

Available starting with IAP 3.0.

Generates a list containing the specified range (based on assigned index number and date of purchase) of user-purchased commercial product items with the item data specified by the OnGetInboxListener() callback, and returns the processing results.

Replaces the deprecated getItemInBoxList() because PackageName replaces itemGroupId.

public void getItemInboxList( int _startNum, int _endNum, String _startDate, String _endDate, OnGetInboxListener _onGetInboxListener)
Request Parameters

_startNum

Required

Integer

The lowest index number assigned to an item in the range of items to be returned (subject to the specified _startDate and _endDate).
Note: The first item in the list is assigned number 1 (NOT 0).

_endNum

Required

Integer

The highest index number assigned to an item in the range of items to be returned (subject to the specified _startDate and _endDate).

If _startNum = 1 and _endNum = 15 in a request, the first fifteen (15) items in the list will be returned when the request is successful AND the specified _startDate and _endDate do NOT restrict the returned items.

_startDate

Required

String

The earliest purchase date (yyyymmdd) of the items to be returned (subject to the specified _startNum and _endNum).

_endDate

Required

String

The latest purchase date (yyyymmdd) of the items to be returned (subject to the specified _startNum and _endNum).

_onGetInboxListener

Required

onGetInboxListener

Name of the OnGetInboxListener() interface that specifies the data and getItemInboxList() processing results to be returned.

Returns

Processing results and data specified by the OnGetInboxListener() callback.

getItemInboxList(_itemslds)

Available starting with IAP 3.0.

Either gets the locally cached list or, when a list is not already locally cached, generates and locally caches a list of any specified user-purchased commercial product items with the item data specified by the OnGetInboxListener() callback, and returns the processing results.

When the list is already locally cached, this method is much faster than getItemInboxList(_startNum, _endNum, _startDate, _endDate).

public void getItemInboxList(String _itemIds, OnGetInboxListener _onGetInboxListener)
Request Parameters

_itemIds

Required

String

1 or more unique identifier(s) of the user-purchased items for which OnGetInboxListener() specified item data is to be returned.

Separate multiple IDs by a comma (for example, "000000057507, 000000057508, 000000057509”).

Each item ID is assigned by and can be reviewed in Samsung Seller Office.
Note: If an item ID of an item that has never been purchased by the user is specified in  _itemIds, no data will be returned for that item.

_onGetInboxListener

Required

onGetInbox
Listener

Name of the OnGetInboxListener() interface that specifies the item data and getItemInboxList() processing results to be returned.

Returns

Processing results and data specified by the OnGetInboxListener() callback.

startPayment( )

Available starting with IAP 3.0.

Initiates purchase and payment processing of the specified item, can notify the end user of a successful purchase, and returns the processing status and OnPaymentListener() specified data.

Caution: When SamsungIapHelper is instantiated with  _mode = 0 (commercial operating mode) and when the service app is being distributed by Samsung Seller Office, successful startPayment() processing will result in financial transactions, for example, end-user credit cards will be billed. When both conditions are not met, financial transactions will not occur.

Replaces the deprecated startPayment() because PackageName replaced itemGroupId.

public void startPayment(String _itemId, boolean _showSuccessDialog, OnPaymentListener _onPaymentListener)
Request Parameters

_itemId

Required

String

Identifier of the commercial product item to be purchased.

_showSuccessDialog

Required

Boolean

Whether or not after successful purchase and payment processing to display the IAP dialog box that notifies the end user that purchasing was successful:

true          The IAP dialog box is to be displayed.
NOTE: The dialog box is not displayed after a failed process.

false        The IAP dialog box is not to be displayed.
NOTE: For all third-party service apps, after successful processing WHEN _showSuccessDialog = false, service app logic and code must inform the end user that the item was successfully purchased.

_onPaymentListener

Required

OnPaymentListener

Name of the OnPaymentListener() interface that specifies the data and startPayment()processing results to be returned.

Returns

Processing results and data specified by the OnPaymentListener() callback.

  • Was this article helpful?