Class
CommerceService
NotCreatableService
Supports real-world purchases that you can bundle with digital benefits.
CommerceService is a service that supports real-world purchases that
you can bundle with virtual items. For information on eligibility and
implementation, see
Commerce products.
Methods 4#
| GetCommerceProductInfoAsync | Retrieves information about the commerce products you are selling in experience.Yields |
| PromptCommerceProductPurchase | Prompts a user to purchase a commerce product using the provided
commerceProductId. Opens a webview that guides the user through the
purchasing flow. |
| PromptRealWorldCommerceBrowser | Legacy endpoint that opens an in-experience browser to a real-world
commerce URL for the specified player; superseded by
CommerceService:PromptCommerceProductPurchase(). |
| UserEligibleForRealWorldCommerceAsync | Legacy endpoint that returns whether the current user is eligible for
real-world commerce; superseded by PolicyService.Yields |
GetCommerceProductInfoAsync(commerceProductId: string): Dictionary#
Yields
Retrieves information about the products that you are selling and surface them within your experience. How you surface products to your users is entirely up to you.
| Name | string | Localized name of of the physical item |
|---|---|---|
| Description | string | Localized description of the physical item |
| IconImageAssetId | number | The image asset ID of main default image of the physical item |
| DisplayPrice | string | Localized price string with currency symbol of the physical item. e.g. “$4.99“ |
| IsPurchasable | bool | If the item can be added to a merchant checkout session, i.e. item is in stock, or can be backordered |
| Name | Type | Default | Description |
|---|---|---|---|
commerceProductId | string | The identifier of the commerce product to look up, either the numeric
ID or the full COM--prefixed form. |
Returns
Dictionary— A dictionary of information about the commerce product, including whether itIsForSale, anItemsub-table of display details (Name,Description,IconImageAssetId,DisplayPrice, andIsPurchasable), and theBenefitsgranted by purchasing it.
PromptCommerceProductPurchase(user: Player, commerceProductId: string): ()#
Prompts a user to purchase a commerce product using the provided
commerceProductId. Opens a webview that guides the user through the
purchasing flow.
| Name | Type | Default | Description |
|---|---|---|---|
user | Player | The Player to prompt with the purchase flow. When called from
a client script, this must be the local player. | |
commerceProductId | string | The identifier of the commerce product to purchase, either the numeric
ID or the full COM--prefixed form. |
Returns
()
PromptRealWorldCommerceBrowser(player: Player, url: string): ()#
This is a legacy endpoint that is not meant for use. To open the webview
to the purchasing flow for real world commerce, see
CommerceService:PromptCommerceProductPurchase. For more
information, see
Commerce products
| Name | Type | Default | Description |
|---|---|---|---|
player | Player | The Player for whom the browser opens. When called from a
client script, this must be the local player. | |
url | string | The real-world commerce URL to open. The URL must be on the commerce allowlist, or the request is ignored. |
Returns
()
UserEligibleForRealWorldCommerceAsync(): boolean#
Yields
This is a legacy endpoint that is not meant for use. To check if a user is
eligible for real world commerce, see
PolicyService.IsEligibleToPurchaseCommerceProduct. For more
information, see
Commerce products
Returns
boolean—trueif the current user is eligible for real-world commerce.
Events 1#
| PromptCommerceProductPurchaseFinished | Fires when commerce purchase webview has closed - not an indicator that a purchase was successful. |
PromptCommerceProductPurchaseFinished(user: Player, productId: string)#
Use this signal to detect when a user has completed the purchasing flow and the webview has closed to resume gameplay within the experience. This signal does not indicate a successful purchase, so do not grant virtual items solely from this signal.
While optional, it is recommended to use this signal to reorient your users on Android, as the commerce purchasing flow will have forced them into portrait mode.
Inherited members#
Inherited from Instance 58
Properties (10)
Archivable, archivable, Capabilities, IsInSandbox, Name, Parent, PredictionMode, RobloxLocked, Sandboxed, UniqueId
Methods (39)
AddTag, children, ClearAllChildren, Clone, clone, Destroy, destroy, FindFirstAncestor, FindFirstAncestorOfClass, FindFirstAncestorWhichIsA, FindFirstChild, findFirstChild, FindFirstChildOfClass, FindFirstChildWhichIsA, FindFirstDescendant, GetActor, GetAttribute, GetAttributeChangedSignal, GetAttributes, GetChildren, getChildren, GetDebugId, GetDescendants, GetFullName, GetStyled, GetStyledPropertyChangedSignal, GetTags, HasTag, IsAncestorOf, IsDescendantOf, isDescendantOf, IsPropertyModified, QueryDescendants, Remove, remove, RemoveTag, ResetPropertyToDefault, SetAttribute, WaitForChild