• Studio

  • Studio API

  • Bots

  • Web API

  • Designer Resources

  • Host Resources

  • Globals

    WorldProductPurchase

    WorldProductPurchase represents a completed purchase transaction. Received in Payments.PurchaseHandler when a player makes a purchase. Contains purchase details including product ID, user ID, and timestamp.

    Properties

    id

    string
    ServerOnly
    ReadOnly

    The unique identifier for this purchase transaction.

    print("Purchase ID: " .. purchase.id)
    

    product_id

    string
    ServerOnly
    ReadOnly

    The ID of the product that was purchased.

    print("Product ID: " .. purchase.product_id)
    

    purchase_date

    number
    ServerOnly
    ReadOnly

    Unix epoch timestamp (UTC) when the purchase was made. Use os.date() to format into human-readable format.

    local purchaseDate = os.date("%Y-%m-%d %H:%M:%S", purchase.purchase_date)
    print("Purchased on: " .. purchaseDate)
    

    user_id

    string
    ServerOnly
    ReadOnly

    The user ID of the player who made the purchase.

    print("Buyer ID: " .. purchase.user_id)
    if purchase.user_id == player.user.id then
        print("Purchase belongs to this player")
    end
    

    Updated 19 days ago

    PocketWorlds Icon

    © 2025 Pocket Worlds. All rights reserved.