Skip to main content

Commerce.Purchase

Class

Represents a completed or pending transaction for a product.

  • Snapchat: not supported
  • SPECS: fully supported
  • Camera Kit Web: not supported
  • Camera Kit Mobile: not supported
  • SnapchatNot supported — Available on SPECS only
  • SPECSFully supported
  • Camera Kit WebNot supported — Available on SPECS only
  • Camera Kit MobileNot supported — Available on SPECS only

Platform details

  • Snapchat — Not supported — Available on SPECS only.

  • SPECS — Fully supported.

  • Camera Kit Web — Not supported — Available on SPECS only.

  • Camera Kit Mobile — Not supported — Available on SPECS only.

Represents a completed or pending transaction for a product. When a user buys something, or when their purchase history is retrieved, Purchase objects are received. These objects contain important details like the unique ID of the purchase, the ID of the product that was bought, when the purchase occurred, and its current state (e.g., purchased, pending, or invalidated).

Index

Extends

Properties

expiryTime

readonly expiryTime: number

SPECS

For subscription purchases, the end of the current billing period in milliseconds since the Unix epoch. Not set for non-subscription purchases.

Since

Lens Scripting Version 377


isAcknowledged

readonly isAcknowledged: boolean

SPECS

Indicates whether this purchase has been acknowledged via Client#acknowledgePurchase.

Since

Lens Scripting Version 377


isAutoRenewing

readonly isAutoRenewing: boolean

SPECS

Indicates whether a subscription purchase renews automatically at the end of the current billing period. Always false for non-subscription purchases.

Since

Lens Scripting Version 377


productId

readonly productId: string

SPECS

The unique identifier for the product that was purchased. It's the same ID you use to identify the product in the store or when querying for product details.


purchaseState

readonly purchaseState: PurchaseState

SPECS

Indicates the current status of the transaction.


purchaseTime

readonly purchaseTime: number

SPECS

Represents the exact moment the purchase was made, measured as the number of milliseconds since January 1, 1970, UTC (Unix epoch time). This timestamp is crucial for tracking purchase dates, managing subscriptions, and for reconciliation purposes.


token

readonly token: string

SPECS

A unique identifier generated by the payment system for the order. It can be useful for linking purchases to specific order records in your backend or for support purposes.

Methods

getTypeName()

static getTypeName(): TypeName<Purchase>

SPECS

Returns the fully-qualified JavaScript type name for this class (for example, "Component.Camera"). This is a static accessor (no instance required) and returns the same value as the instance getTypeName().

Returns

TypeName<Purchase>

Overrides

ScriptObject.getTypeName


getTypeName()

getTypeName(): string

Returns the name of this object's type.

Returns

string

Inherited from

ScriptObject.getTypeName


isOfType()

isOfType(type): boolean

Returns true if the object matches or derives from the passed in type.

Parameters

ParameterType
typestring

Returns

boolean

Inherited from

ScriptObject.isOfType


isSame()

isSame(other): boolean

Returns true if this object is the same as other. Useful for checking if two references point to the same thing.

Parameters

ParameterType
otherScriptObject

Returns

boolean

Inherited from

ScriptObject.isSame