store.purchase()

Type Function
Return value none
Revision Release 2026.3728
Keywords Samsung, IAP, in-app purchases, purchase
See also store.init()
store.consumePurchase()
store.acknowledgePurchase()
store.*

Overview

Initiates a purchase transaction on a provided product by sending out a purchase request to the store, then dispatches a storeTransaction event to the listener defined in store.init(). Consumable items, non-consumable items and subscriptions can all be purchased with this function.

Gotchas

Syntax

store.purchase( productIdentifier [,options] )
productIdentifier (required)

String. String representing the product identifier of the item to purchase.

options (optional)

Table. A table with the following optional keys:

  • obfuscatedAccountId — A string (up to 64 bytes) that identifies the user’s account in your app, for example a SHA-256 hash of the account name. Samsung uses it for fraud detection and returns it in the purchase, in store.restore() results and in receipts. Never pass the plain account name.

  • obfuscatedProfileId — A string (up to 64 bytes) that identifies the user’s profile in your app, obfuscated like obfuscatedAccountId. Requires obfuscatedAccountId.

  • passThroughParam — A string (up to 255 bytes) that is attached to the transaction and returned in the passThroughParam field of the purchase. Deprecated by Samsung since IAP SDK 6.4 in favor of the obfuscated identifiers; it is ignored when obfuscatedAccountId or obfuscatedProfileId is set.

For backwards compatibility, a string can be passed instead of the table; it is used as passThroughParam.

Example

-- Consumable item
store.purchase( "com.mycompany.mygame.coins100" )

-- Subscription, tagged with the (hashed) account of the signed in user
store.purchase( "com.mycompany.mygame.premium.monthly", {
    obfuscatedAccountId = hashedAccountId,
} )