Class
MarketplaceService
NotCreatableService
The service responsible for in-experience transactions.
MarketplaceService is responsible for in-experience transactions. The
most notable methods are
PromptProductPurchase and
PromptPurchase, as well as the
callback ProcessReceipt which must
be defined so that developer product transactions do not fail.
BindReceiptHandler is a newer
alternative that processes developer product receipts (and Robux transfer
receipts) through one or more bound handlers instead of the single
ProcessReceipt callback.
MarketplaceService also has methods that fetch information about
developer products
(GetProductInfoAsync and
GetDeveloperProductsAsync),
passes
(UserOwnsGamePassAsync()),
and other assets
(PlayerOwnsAssetAsync,
PlayerOwnsBundleAsync).
Understanding MarketplaceService is the first step towards learning to
monetize an experience on Roblox,
as well as learning to use DataStoreService, which is responsible for
saving and loading all data related to purchases.
Methods 28#
| BindReceiptHandler | Registers a callback to process receipts of a specific type. |
| GetDeveloperProductsAsync | Returns a Pages object which contains information for all of the
current experience's developer products.Yields |
| GetProductInfo | Returns the product information of an asset using its asset ID.DeprecatedYields |
| GetProductInfoAsync | Returns the product information of an asset using its asset ID.Yields |
| GetRobloxSubscriptionDetailsAsync | Returns the subscription details for the given user for the Roblox Subscription ecosystem.Yields |
| GetSubscriptionProductInfoAsync | Returns the product information of a subscription for the given
subscriptionId.Yields |
| GetUsersPriceLevelsAsync | Returns the regionalized price levels of users, representing the recommended price for an item in each user's regional market.Yields |
| GetUserSubscriptionDetailsAsync | Returns a table that contains the details of the user's subscription for a
given subscriptionId.Yields |
| GetUserSubscriptionPaymentHistoryAsync | Returns an Array that contains up to one year of the
user's subscription payment history for the given subscriptionId.Yields |
| GetUserSubscriptionStatusAsync | Returns a table that contains the subscription status of the
user for the given subscriptionId.Yields |
| OpenShop | Opens a personalized in-game Shop for the given player. |
| PlayerOwnsAsset | Returns whether the given user has the given asset.DeprecatedYields |
| PlayerOwnsAssetAsync | Returns whether the given user has the given asset.Yields |
| PlayerOwnsBundle | Returns whether the given player owns the given bundle.DeprecatedYields |
| PlayerOwnsBundleAsync | Returns whether the given player owns the given bundle.Yields |
| PromptBulkPurchase | Prompts a user to purchase multiple avatar items with the given assetId
or bundleId. |
| PromptBundlePurchase | Prompts a user to purchase a bundle with the given bundleId. |
| PromptCancelSubscription | Prompts a user to cancel a subscription for the given subscriptionId. |
| PromptGamePassPurchase | Prompts a user to purchase a pass with the given gamePassId. |
| PromptPremiumPurchase | Prompts a user to purchase Roblox Premium.Deprecated |
| PromptProductPurchase | Prompts a user to purchase a developer product with the given productId. |
| PromptPurchase | Prompts a user to purchase an item with the given assetId. Does not work
for USD Creator Store purchases. |
| PromptRobloxSubscriptionPurchase | Prompts a user to purchase a Roblox Plus subscription. |
| PromptRobuxTransferAsync | Initiates a Robux transfer from the sender to another user.Yields |
| PromptSubscriptionPurchase | Prompts a user to purchase a subscription for the given subscriptionId. |
| RankProductsAsync | Takes a list of product IDs and returns a personalized ordered list of those products.Yields |
| RecommendTopProductsAsync |
|
| UserOwnsGamePassAsync | Returns true if the player with the given UserId
owns the pass with the given gamePassId.Yields |
BindReceiptHandler(transactionType: ReceiptType, handler: Function, filter: Array?): RBXScriptConnection#
BindReceiptHandler registers a callback to process receipts of a
specific ReceiptType. You can use it to handle developer product
receipts (ReceiptType.DeveloperProduct) and Robux transfer receipts
(ReceiptType.RobuxTransferSender and
ReceiptType.RobuxTransferReceiver).
For ReceiptType.DeveloperProduct, you can register handlers in two
ways:
- Filtered — Pass a
filterarray of developer product IDs so the handler only fires for receipts whoseProductIdis in that array. Use this to route specific products to dedicated handlers. - Catch-all — Omit
filterso the handler fires for any developer product receipt not already claimed by a filtered handler.
For developer products, BindReceiptHandler is an alternative to the
legacy ProcessReceipt callback.
A bound handler takes precedence; if no bound handler matches a developer
product receipt, it falls through to ProcessReceipt. This lets you adopt
BindReceiptHandler incrementally without removing an existing
ProcessReceipt callback.
The handler callback receives a receipt info dictionary and must return
an ReceiptDecision value:
ReceiptDecision.Processed— Indicates the receipt was successfully processed and all benefits have been granted. The receipt is marked as complete.ReceiptDecision.NotProcessedYet— Indicates the receipt has not been processed yet. The receipt remains unresolved and will be delivered again on the next opportunity.
Receipt Info Dictionary#
The receipt info dictionary passed to the handler contains the following
fields:
| Key | Type | Description |
|---|---|---|
PurchaseId |
string | A unique identifier for this specific receipt. |
PlayerId |
number | The Class.Player.UserId of the user associated with
this receipt. |
PlaceIdWherePurchased |
number | The place ID where the transaction was initiated. |
ReceiptType |
Enum.ReceiptType |
The type of this receipt. |
ProductId |
number | The developer product ID. Only present for
Enum.ReceiptType.DeveloperProduct receipts. |
CurrencyType |
Enum.CurrencyType |
The currency used for the purchase. Only present for
Enum.ReceiptType.DeveloperProduct receipts. |
CurrencySpent |
number | The amount of Robux involved in the transaction. For
Enum.ReceiptType.DeveloperProduct receipts, this is the
product's price. For
Enum.ReceiptType.RobuxTransferSender receipts, this is
the amount sent. For
Enum.ReceiptType.RobuxTransferReceiver receipts, this is
the amount received. |
TransferRequestId |
string | The transfer request ID from
Class.MarketplaceService:PromptRobuxTransferAsync(). Only
present for Enum.ReceiptType.RobuxTransferSender and
Enum.ReceiptType.RobuxTransferReceiver receipts. |
Receipt Timing#
For Robux transfer receipts, handler is invoked once the transfer
settles. A settled receipt is delivered to whichever server the user is
currently in (the user does not need to rejoin).
ReceiptType.RobuxTransferReceiver— Delivered to the server the receiver is currently in once the transfer settles. If the receiver is offline at that time, delivery happens the next time they join a server.ReceiptType.RobuxTransferSender— Delivered immediately if the transfer settles synchronously. If the transfer is gated on receiver approval (for example, parental consent), delivery happens once the receiver accepts, to whichever server the sender is currently in or on their next join if they are offline.
For developer product receipts, handler is invoked when the purchase
completes while the buyer is on a server. If the handler returns
ReceiptDecision.NotProcessedYet, or the buyer is not reachable, the
receipt remains unresolved and is redelivered on a later opportunity or
the next time the buyer joins a server.
The user must be on a server for handler to fire.
Errors#
This method throws an error if:
- A handler is already registered for the same
ReceiptTypeand product ID combination. - A catch-all handler is already registered for the same
ReceiptType.
| Name | Type | Default | Description |
|---|---|---|---|
transactionType | ReceiptType | The ReceiptType indicating which kind of receipt to handle. | |
handler | Function | A callback function that receives a receipt info dictionary and must
return an ReceiptDecision value. | |
filter | Array? | An optional array of product IDs. When provided, the handler only
fires for receipts matching those product IDs. Not supported for
RobuxTransferSender or RobuxTransferReceiver receipt types. |
Returns
RBXScriptConnection— ARBXScriptConnectionthat can be disconnected to unregister the handler.
GetDeveloperProductsAsync(): Instance#
Yields
Returns a Pages object which contains information for all of the
current experience's
developer products.
GetProductInfo(assetId: int64, infoType: InfoType = Asset): Dictionary#
YieldsDeprecatedDeprecated
Deprecated. This method has been superseded by
GetProductInfoAsync().
Returns the product information of an asset using its asset ID.
| Name | Type | Default | Description |
|---|---|---|---|
assetId | int64 | The asset ID of the specified product. | |
infoType | InfoType | Asset | An InfoType enum value specifying the type of information being
retrieved. |
Returns
Dictionary— A dictionary containing information about the queried item, described in the previous tables.
GetProductInfoAsync(assetId: int64, infoType: InfoType = Asset): Dictionary#
Yields
This method provides information about an asset,
developer product,
or pass based on the asset
ID and the InfoType. If an item with the given ID does not exist,
this method throws an error.
Information about the queried item is provided in a dictionary with the following keys. Note that not all information is provided or necessarily relevant for the kind of product you're querying.
| Key | Type | Description |
|---|---|---|
Name |
string | The name shown on the asset's page. |
Description |
string | The description shown on the asset's page; can be nil if blank. |
PriceInRobux |
number | The cost of purchasing the asset using Robux. |
UserBasePriceInRobux |
number | The base price of the asset in Robux before any discounts are applied. |
PriceDiscountDetails |
Array | An ordered list of discounts representing the difference between UserBasePriceInRobux and PriceInRobux. Each entry contains the following keys: |
Type: The type of discount. "RobloxPlusSubscription" indicates that the discount was applied due to the user’s Roblox Plus subscription. |
||
AmountInRobux: number — The value of the discount in Robux. |
||
Percent: number — The percentage of the discount. |
||
ProductId |
number | The product ID if Enum.InfoType is Product. |
ProductType |
string | A string describing what the product is. Not to be confused with Enum.MarketplaceProductType. |
Created |
string | Timestamp of when the asset was created, for example 2022-01-02T10:30:45Z. Formatted using ISO 8601. |
Updated |
string | Timestamp of when the asset was last updated by its creator, for example 2022-02-12T11:22:15Z. Formatted using ISO 8601. |
ContentRatingTypeId |
number | Indicates whether the item is marked as 13+ in catalog. |
MinimumMembershipLevel |
number | The minimum subscription level necessary to purchase the item. |
IsPublicDomain |
boolean | Describes whether the asset can be taken for free. |
TargetId |
number | The ID of the product or asset. |
Creator Information#
| Key | Type | Description |
|---|---|---|
Creator |
table | Dictionary table of information describing the creator of the asset, containing the following fields: |
CreatorType: Either User or Group. |
||
CreatorTargetId: The ID of the creator user or group. |
||
HasVerifiedBadge: Boolean of whether the creator has a verified badge. |
||
Name: The name/username of the creator. |
||
Id: Use CreatorTargetId instead. |
||