Roblox UtilitiesDevlHub Roblox Documentation

Class

CommerceService

NotCreatableService
Inherits
Instance › Object
Memory category
Instances

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#

GetCommerceProductInfoAsyncRetrieves information about the commerce products you are selling in experience.Yields
PromptCommerceProductPurchasePrompts a user to purchase a commerce product using the provided commerceProductId. Opens a webview that guides the user through the purchasing flow.
PromptRealWorldCommerceBrowserLegacy endpoint that opens an in-experience browser to a real-world commerce URL for the specified player; superseded by CommerceService:PromptCommerceProductPurchase().
UserEligibleForRealWorldCommerceAsyncLegacy 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
NameTypeDefaultDescription
commerceProductIdstringThe 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 it IsForSale, an Item sub-table of display details (Name, Description, IconImageAssetId, DisplayPrice, and IsPurchasable), and the Benefits granted 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.

NameTypeDefaultDescription
userPlayerThe Player to prompt with the purchase flow. When called from a client script, this must be the local player.
commerceProductIdstringThe 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

NameTypeDefaultDescription
playerPlayerThe Player for whom the browser opens. When called from a client script, this must be the local player.
urlstringThe 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 — true if the current user is eligible for real-world commerce.

Events 1#

PromptCommerceProductPurchaseFinishedFires 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.

NameTypeDefaultDescription
userPlayerThe Player who was prompted with the purchase flow.
productIdstringThe identifier of the commerce product whose purchase flow finished.

Inherited members#

Inherited from Instance 58
Inherited from Object 6
Properties (2)

ClassName, className

Events (1)

Changed