store.consumePurchase()

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

Overview

This function “consumes” a purchased consumable item and makes it available for purchase again. Once a consumable item is purchased, Samsung IAP considers it “owned” and it cannot be purchased again until it is consumed. Consume the item after you granted it to the user.

Non-consumable items and subscriptions must not be consumed; acknowledge them with store.acknowledgePurchase() instead.

The result is dispatched as a storeTransaction event with a state of "consumed", one event per purchase identifier. Check statusType ("success" when the item was consumed) and purchaseId of the event.

Gotchas

Syntax

store.consumePurchase( purchaseId )
purchaseId (required)

String. The purchaseId of the purchase to consume. Several purchases can be consumed at once by passing a comma separated string or an array of purchase identifiers. The event.transaction table of a storeTransaction event is accepted as well.

Example

local function transactionListener( event )
    local transaction = event.transaction

    if ( event.name == "storeTransaction" and transaction.state == "purchased" and transaction.isConsumable ) then
        -- Grant the item to the user, then consume it
        store.consumePurchase( transaction.purchaseId )

    elseif ( event.name == "storeTransaction" and transaction.state == "consumed" ) then
        print( "consumed " .. transaction.purchaseId .. ": " .. transaction.statusType )
    end
end