# CommerceService

Roblox Engine API class from Roblox Studio 0.744.0.7441077 (version-7aaa6838d36c4448).

- Inherits from, nearest first: [Instance](https://rapi.sleaze.dev/classes/Instance.md), [Object](https://rapi.sleaze.dev/classes/Object.md)
- Tags: Not creatable, Service
- Memory category: Instances
- HTML page: https://rapi.sleaze.dev/classes/CommerceService/
- Roblox documentation: https://create.roblox.com/docs/reference/engine/classes/CommerceService

Supports real-world purchases that you can bundle with digital benefits.

## Methods

### GetCommerceProductInfoAsync

```luau
CommerceService:GetCommerceProductInfoAsync(commerceProductId: string): { [string]: any }
```

- Tags: Yields, Capabilities: Monetization

Retrieves information about the commerce products you are selling in experience.

Parameters:

- `commerceProductId`: The identifier of the commerce product to look up, either the numeric ID or the full `COM-`-prefixed form.

Returns: A dictionary of information about the commerce product, including whether it `IsForSale`, an `Item` sub-table of display details ([`Name`](https://rapi.sleaze.dev/classes/Instance.md), `Description`, `IconImageAssetId`, `DisplayPrice`, and `IsPurchasable`), and the `Benefits` granted by purchasing it.

### PrepareCommerceProductPurchase

```luau
CommerceService:PrepareCommerceProductPurchase(commerceProductId: string): { [string]: any }
```

- Tags: Yields, Roblox script security, Capabilities: Monetization

### PromptCommerceProductPurchase

```luau
CommerceService:PromptCommerceProductPurchase(user: Player, commerceProductId: string)
```

- Tags: Capabilities: Monetization

Prompts a user to purchase a commerce product using the provided `commerceProductId`. Opens a webview that guides the user through the purchasing flow.

Parameters:

- `user`: The [`Player`](https://rapi.sleaze.dev/classes/Player.md) to prompt with the purchase flow. When called from a client script, this must be the local player.
- `commerceProductId`: The identifier of the commerce product to purchase, either the numeric ID or the full `COM-`-prefixed form.

### PromptRealWorldCommerceBrowser

```luau
CommerceService:PromptRealWorldCommerceBrowser(player: Player, url: string)
```

- Tags: Capabilities: Monetization

Legacy endpoint that opens an in-experience browser to a real-world commerce URL for the specified player; superseded by [`CommerceService:PromptCommerceProductPurchase()`](https://rapi.sleaze.dev/classes/CommerceService.md).

Parameters:

- `player`: The [`Player`](https://rapi.sleaze.dev/classes/Player.md) for whom the browser opens. When called from a client script, this must be the local player.
- `url`: The real-world commerce URL to open. The URL must be on the commerce allowlist, or the request is ignored.

### SignalPromptCommerceProductPurchaseFinished

```luau
CommerceService:SignalPromptCommerceProductPurchaseFinished(productId: string, didTryPurchase: boolean, checkoutSessionId: string? = "")
```

- Tags: Roblox script security, Capabilities: Monetization

### UserEligibleForRealWorldCommerceAsync

```luau
CommerceService:UserEligibleForRealWorldCommerceAsync(): boolean
```

- Tags: Yields, Capabilities: Monetization

Legacy endpoint that returns whether the current user is eligible for real-world commerce; superseded by [`PolicyService`](https://rapi.sleaze.dev/classes/PolicyService.md).

Returns: `true` if the current user is eligible for real-world commerce.

## Events

### BenefitStatusReceived

```luau
CommerceService.BenefitStatusReceived: RBXScriptSignal<(isGranted: boolean)>
```

- Tags: Roblox script security, Capabilities: Monetization

### FetchReceipt

```luau
CommerceService.FetchReceipt: RBXScriptSignal<()>
```

- Tags: Roblox engine security, Capabilities: Monetization

### InExperienceBrowserRequested

```luau
CommerceService.InExperienceBrowserRequested: RBXScriptSignal<(url: string)>
```

- Tags: Roblox engine security, Capabilities: Monetization

### PromptCommerceProductPurchaseFinished

```luau
CommerceService.PromptCommerceProductPurchaseFinished: RBXScriptSignal<(user: Player, productId: string)>
```

- Tags: Capabilities: Monetization

Fires when commerce purchase webview has closed - not an indicator that a purchase was successful.

### PromptCommerceProductPurchaseRequested

```luau
CommerceService.PromptCommerceProductPurchaseRequested: RBXScriptSignal<(commerceProductId: string)>
```

- Tags: Roblox script security, Capabilities: Monetization

### PurchaseBrowserClosed

```luau
CommerceService.PurchaseBrowserClosed: RBXScriptSignal<()>
```

- Tags: Roblox script security, Capabilities: Monetization

## Inherited members

- From [Instance](https://rapi.sleaze.dev/classes/Instance.md): `Archivable`, `archivable`, `Attributes`, `AttributesReplicate`, `AttributesSerialize`, `HistoryId`, `Name`, `Parent`, `PredictionMode`, `PropertyStatusStudio`, `RobloxLocked`, `SerializedOverrides`, `SourceAssetId`, `Tags`, `UniqueId`, `numExpectedDirectChildren`, `DataCost`, `Capabilities`, `DefinesCapabilities`, `IsInSandbox`, `Sandboxed`, `AddTag`, `ClearAllChildren`, `Clone`, `Destroy`, `FindFirstAncestor`, `FindFirstAncestorOfClass`, `FindFirstAncestorWhichIsA`, `FindFirstChild`, `FindFirstChildOfClass`, `FindFirstChildWhichIsA`, `FindFirstDescendant`, `GetActor`, `GetAttribute`, `GetAttributeChangedSignal`, `GetAttributes`, `GetChildren`, `GetDebugId`, `GetDescendants`, `GetFullName`, `GetStyled`, `GetStyledPropertyChangedSignal`, `GetTags`, `HasTag`, `IsAncestorOf`, `IsDescendantOf`, `IsPropertyModified`, `QueryDescendants`, `RemoveTag`, `ResetPropertyToDefault`, `SetAttribute`, `WaitForChild`, `Remove`, `children`, `clone`, `destroy`, `findFirstChild`, `getChildren`, `isDescendantOf`, `remove`, `AncestryChanged`, `AttributeChanged`, `ChildAdded`, `ChildRemoved`, `DescendantAdded`, `DescendantRemoving`, `Destroying`, `StyledPropertiesChanged`, `childAdded`
- From [Object](https://rapi.sleaze.dev/classes/Object.md): `ClassName`, `className`, `GetPropertyChangedSignal`, `IsA`, `isA`, `Changed`
