Service · inherits Instance
MarketplaceService
The service responsible for in-experience transactions.
About MarketplaceService
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 24
BindReceiptHandler
(transactionType: ReceiptType, handler: Function, filter: Array?) → RBXScriptConnectionRegisters a callback to process receipts of a specific type.BindReceiptHandlerregisters a callback to process receipts of a specificReceiptType. You can use it to handle developer product receipts (ReceiptType.DeveloperProduct) and Robux transfer receipts (ReceiptType.RobuxTransferSenderandReceiptType.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,
BindReceiptHandleris an alternative to the legacyProcessReceiptcallback. A bound handler takes precedence; if no bound handler matches a developer product receipt, it falls through toProcessReceipt. This lets you adoptBindReceiptHandlerincrementally without removing an existingProcessReceiptcallback.The
handlercallback receives a receipt info dictionary and must return anReceiptDecisionvalue: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
handlercontains the following fields:Receipt Timing
For Robux transfer receipts,
handleris 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,
handleris invoked when the purchase completes while the buyer is on a server. If the handler returnsReceiptDecision.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
handlerto 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.
- Filtered — Pass a
GetDeveloperProductsAsync
() → InstanceYieldsReturns aPagesobject which contains information for all of the current experience's developer products.Returns a
Pagesobject which contains information for all of the current experience's developer products.GetProductInfoAsync
(assetId: int64, infoType: InfoType = Asset) → DictionaryYieldsReturns the product information of an asset using its asset ID.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.
Creator Information
Asset Information
Collectibles Information
Sale Location Settings
Timed Options
Batching behavior
This method is Transparent Batching capable. If you spawn multiple calls concurrently using
task.spawn, the engine automatically combines them into fewer HTTP requests behind the scenes. This is faster and helps you avoid rate limits. See Transparent Batching for details and a code example.GetRobloxSubscriptionDetailsAsync
(user: Player) → DictionaryYieldsReturns the subscription details for the given user for the Roblox Subscription ecosystem.This method is a streamlined endpoint to check for a single, platform-wide Roblox subscription product. By providing
StartTime(conditionally) andIsOriginExperienceto reward long-term loyalists without compromising user data across the platform.The returned dictionary contains the following fields:
GetSubscriptionProductInfoAsync
(subscriptionId: string) → DictionaryYieldsReturns the product information of a subscription for the givensubscriptionId.Returns the product information of a subscription for the given
subscriptionId. Because it returns a localized price, you can only call this method from aScriptwithRunContext.Client.GetUsersPriceLevelsAsync
(userIds: Array) → List<PriceLevelInfo>YieldsReturns the regionalized price levels of users, representing the recommended price for an item in each user's regional market.Returns the regionalized price levels of users, representing the recommended price for an item in each user's regional market. For example, a price level of 100 means that the suggested price for that user (based on their region and purchasing power) is 100 Robux.
See Protect your trades and gifts for more information.
GetUserSubscriptionDetailsAsync
(user: Player, subscriptionId: string) → DictionaryYieldsReturns a table that contains the details of the user's subscription for a givensubscriptionId.Returns a dictionary table containing the details of the user's subscription for the given
subscriptionId. The table contains the following keys:Note that this method can only be called from a
ScriptwithRunContextofServer. If you only need to determine theIsSubscribedstatus of a user, it's recommended to useGetUserSubscriptionStatusAsyncas it is faster and more efficient for that particular purpose.GetUserSubscriptionPaymentHistoryAsync
(user: Player, subscriptionId: string) → ArrayYieldsReturns anArraythat contains up to one year of the user's subscription payment history for the givensubscriptionId.Returns an
Arraythat contains up to one year of the user's subscription payment history for the givensubscriptionId, sorted from the most recent status to the least recent. You can only call this method from aScriptwithRunContext.Server.Each entry in the payment history
Arraycontains the following keys:Payment History Length
Only creators affiliated with the subscription product can access up to one year worth of the user's subscription payment history. Non-associated creators can only get the user's current subscription payment status or an empty
Arrayif the user has no active subscription.Grace Period
Subscription renewal payments can have some processing time. Payment history doesn't return a table for this period. However, in order to preserve a user's subscription experience during the processing period,
GetUserSubscriptionStatusAsyncreturnsIsSubscribed: truefor the given user. Don't grant durable items or currency type subscription benefits to the user until after payment has been confirmed for the current cycle.For example, on August 31, 2023, User A's Subscription B is up for renewal. On September 1, 2023, the payment has yet to be processed. If you call
GetUserSubscriptionPaymentHistoryAsyncon September 1, 2023 on User A for Subscription B, the first entry of the return value is:Note that since the user is within the grace period, the cycle they have yet to pay for (September 1, 2023) does not appear in the return value at all. This field only populates after the payment has been received and processed.
At the same time,
GetUserSubscriptionStatusAsyncreturns the following result until the renewal payment process fails or the user cancels:GetUserSubscriptionStatusAsync
(user: Player, subscriptionId: string) → DictionaryYieldsReturns atablethat contains the subscription status of the user for the givensubscriptionId.Returns a
tablethat contains the subscription status of the user for the givensubscriptionId. The table contains the following keys:Note that
IsSubscribedwill betrueonly when a user has purchased the subscription and the payment has been successfully processed. If the payment for a user's initial subscription purchase is still processing or has failed,IsSubscribedreturnsfalse. To understand when a user's subscription status has changed, see thePlayers.UserSubscriptionStatusChangedevent.OpenShop
(player: Player) → ()Opens a personalized in-game Shop for the given player.Opens an in-game Shop as an overlay window for the given
Player. Shop displays a personalized list of the experience's passes and developer products ranked for the user.A default Shop is generated automatically for every game and requires no additional developer setup. You can customize which items appear in the shop from Creator Hub.
This method can be called from either a server
Scriptor aLocalScript. When called from aLocalScript,playermust match the local player.You can call this method in response to any user action, such as a button click, the player reaching a specific location, or joining the experience.
PlayerOwnsAssetAsync
(player: Instance, assetId: int64) → booleanYieldsReturns whether the given user has the given asset.Returns whether the inventory of a specific user contains an asset, based on the asset ID. This method throws an error if the query fails, so you should wrap calls to this method in
pcall().- This method should not be used for
passes since they use a
separate ID system. Legacy passes that still depend on an asset ID
should use
UserOwnsGamePassAsync()instead of this method. - This method cannot be used to check for developer products since they can be purchased multiple times but not owned themselves. Instead, use a data store to save when a user buys a developer product.
- This method should not be used for
passes since they use a
separate ID system. Legacy passes that still depend on an asset ID
should use
PlayerOwnsBundleAsync
(player: Player, bundleId: int64) → booleanYieldsReturns whether the given player owns the given bundle.Returns whether the inventory of a specific user contains a bundle, based on the bundle ID. This method throws an error if the query fails, so you should wrap calls to this method in
pcall().PromptBulkPurchase
(player: Player, lineItems: Array, options: Dictionary) → ()Prompts a user to purchase multiple avatar items with the givenassetIdorbundleId.Prompts a user to purchase multiple avatar items with the given
assetIdorbundleId. Does not work with non-avatar items.PromptBulkPurchaseonly allows prompting from server scripts.For limited items, original copies are prompted until they run out, regardless of the price. Once original copies are out, resale copies are prompted.
A maximum of 20 items can be added to a single bulk purchase prompt.
PurchaseOptions
Each line item can optionally include a
PurchaseOptionsarray to control which purchase option appears in the prompt. If omitted, the user is prompted for a permanent purchase only (default behavior).PurchaseOptionscurrently supports only one entry. If more than one option is provided, the API throws an error.Each entry in
PurchaseOptionscontains:Do not hardcode duration values. Available durations and prices are determined by the backend and may change at any time. Always retrieve them from one of the following APIs and pass the values through to
PurchaseOptions:PromptBundlePurchase
(player: Instance, bundleId: int64) → ()Prompts a user to purchase a bundle with the givenbundleId.PromptCancelSubscription
(user: Player, subscriptionId: string) → ()Prompts a user to cancel a subscription for the givensubscriptionId.Prompts a user to cancel a subscription for the given
subscriptionId. Once the user successfully cancels the subscription, thePlayers.UserSubscriptionStatusChangedevent fires.PromptGamePassPurchase
(player: Instance, gamePassId: int64) → ()Prompts a user to purchase a pass with the givengamePassId.Prompts a user to purchase a pass with the given
gamePassId.PromptProductPurchase
(player: Instance, productId: int64, equipIfPurchased: boolean = true, currencyType: CurrencyType = Default) → ()Prompts a user to purchase a developer product with the givenproductId.Prompts a user to purchase a developer product with the given
productId.PromptPurchase
(player: Instance, assetId: int64, equipIfPurchased: boolean = true, currencyType: CurrencyType = Default) → ()Prompts a user to purchase an item with the givenassetId. Does not work for USD Creator Store purchases.Prompts a user to purchase an item with the given
assetId.- This does not work for USD Creator Store purchases.
- If the item has the
Sale Location
set as
Experience By Place ID (API Only), you must callMarketplaceService.PromptPurchasefrom a server script. - If prompting a purchase of a
limited
item:
- (Recommended) Server requests prompt original copies until they run out, regardless of the price. Once original copies run out, resale copies are prompted.
- Client requests prompt from the lowest resale price even if original copies are available.
PromptRobloxSubscriptionPurchase
(user: Player) → ()Prompts a user to purchase a Roblox Plus subscription.Prompts a user to purchase a Roblox Plus subscription. When the user successfully subscribes, any experience-defined rewards for the upsell are granted automatically through the engine API.
See Also
MarketplaceService.PromptRobloxSubscriptionPurchaseFinishedwhich fires when the Roblox Plus purchase UI closes.Player.HasRobloxSubscriptionwhich can be observed viaInstance.GetPropertyChangedSignalto detect when a user's subscription status changes.
PromptRobuxTransferAsync
(sender: Player, receiverUserId: int64, amount: int64) → stringYieldsInitiates a Robux transfer from the sender to another user.PromptRobuxTransferAsyncinitiates a Robux transfer from thesenderto the user specified byreceiverUserId. This is a server-only method and must be called from aScriptwithRunContextset toServer.After a successful transfer, both the sender and receiver will have receipts delivered to their respective
BindReceiptHandlercallbacks:- The sender's receipt has
ReceiptType.RobuxTransferSender. - The receiver's receipt has
ReceiptType.RobuxTransferReceiver.
Both receipts include a
TransferRequestIdfield matching thetransferRequestIdreturned by this method, which you can use for logging or to correlate sender and receiver receipts.Receipt Timing
Both receipts are delivered to whichever server the corresponding user is currently in once the transfer settles (neither side needs to rejoin). If a transfer is gated on receiver approval, for example parental consent for the receiver's account, it does not settle until approval lands; receipts are delivered after that point.
- Receiver receipt is delivered to the server the receiver is currently in once the transfer settles, or on their next session join if they are offline.
- Sender receipt is delivered immediately if the transfer settles synchronously. If approval is required, it is delivered to the server the sender is currently in once the receiver accepts, or on the sender's next session join if they are offline.
Errors
This method throws an error if:
- The
senderis not a validPlayerinstance. receiverUserIdis not a positive integer.amountis not a positive integer.- The method is called from the client instead of the server.
- The sender's receipt has
PromptSubscriptionPurchase
(user: Player, subscriptionId: string) → ()Prompts a user to purchase a subscription for the givensubscriptionId.RankProductsAsync
(productIdentifiers: Array) → List<RankedItem>YieldsTakes a list of product IDs and returns a personalized ordered list of those products.Takes a list of product IDs and returns a personalized ordered list of those products.
This API has a client-side throttling limit of 10 requests per minute. If you exceed this limit, wait 60 seconds and make the request again.
RecommendTopProductsAsync
(infoTypes: Array) → List<RankedItem>Yields- Takes an array of
InfoTypeand returns up to 50 items representing the products a user is most likely to engage with and purchase.
Takes an array of
InfoTypeand returns up to 50 items representing the products a user is most likely to engage with and purchase. If no recommendations can be determined, the method returns an empty list.This API has a client-side throttling limit of 5 requests per minute. If you exceed this limit, wait 60 seconds and make the request again.
- Takes an array of
UserOwnsGamePassAsync
(userId: User, gamePassId: int64) → booleanYieldsReturns true if the player with the givenUserIdowns the pass with the givengamePassId.Returns true if the user with the given
UserIdowns the pass with the givengamePassId(not to be confused with an asset ID). You can use this method on both the client and the server.Caching Behavior
The results of this function are cached so that repeated calls are returned faster. When the
PromptGamePassPurchaseFinishedevent fires, the cache gets updated to reflect the latest ownership state of the associated game pass.If the user purchases a game pass outside of the experience while remaining in the same session, the cache is eventually updated, but this process might take several minutes to propagate.
When a user first enters a server after purchasing a game pass, this functions always returns true.
Batching behavior
This method is Transparent Batching capable. If you spawn multiple calls concurrently using
task.spawn, the engine automatically combines them into fewer HTTP requests behind the scenes. This is faster and helps you avoid rate limits. See Transparent Batching for details.
Events 8
PromptBulkPurchaseFinished
MarketplaceService.PromptBulkPurchaseFinished:Connect(function(player, status, results))Fires when a purchase prompt for bulk avatar items is closed.This event fires when a purchase prompt for a bulk avatar items closes. For example, when a user receives the purchase prompt and clicks Cancel, or when they receive a success or error message and click OK.
Note: This is not a trusted event from the client. To check if the user owns the items purchased, use
MarketplaceService.PlayerOwnsAssetAsyncorMarketplaceService.PlayerOwnsBundleAsync.PromptBundlePurchaseFinished
MarketplaceService.PromptBundlePurchaseFinished:Connect(function(player, bundleId, wasPurchased))Fires when a bundle purchase prompt closes.This event fires when a purchase prompt for a bundle closes. Use
PlayerOwnsBundleAsync()to verify ownership instead of trusting this client-originated event.PromptGamePassPurchaseFinished
MarketplaceService.PromptGamePassPurchaseFinished:Connect(function(player, gamePassId, wasPurchased))Fires when a purchase prompt for a pass is closed.This event fires when a purchase prompt for a pass closes. For example, when a user receives the purchase prompt and clicks Cancel, or when they receive a success or error message and click OK.
See Also
- For repeatable developer product purchase prompts, use
PromptProductPurchaseFinished. - For affiliate gear sales or other assets, use
PromptPurchaseFinished. - For more information on saving and replicating user data like purchases and progress, see Implementing player data and purchases.
- For repeatable developer product purchase prompts, use
PromptPremiumPurchaseFinished
MarketplaceService.PromptPremiumPurchaseFinished:Connect(function())Fires when a purchase prompt for Roblox Premium is closed.This event fires when a purchase prompt for Roblox Premium closes. For example, when a user receives the purchase prompt and clicks Cancel, or when they receive a success or error message and click OK.
See Also
PromptPremiumPurchaseto prompt a user to purchase Premium.PlayerMembershipChanged, which fires when the server recognizes that a user's membership has changed.
PromptProductPurchaseFinished
MarketplaceService.PromptProductPurchaseFinished:Connect(function(userId, productId, isPurchased))Fires when a purchase prompt for a developer product is closed. Do not use this event to process purchases.IMPORTANT: Do not use the
PromptProductPurchaseFinishedevent to process purchases; instead, use theProcessReceiptcallback. The firing ofPromptProductPurchaseFinisheddoes not mean that a user has successfully purchased an item.This event fires when a purchase prompt for a developer product closes. For example, when a user receives the purchase prompt and clicks Cancel, or when they receive a success or error message and click OK. The firing of this event does not mean that a user has successfully purchased an item.
While you can use the
PromptProductPurchaseFinishedevent to detect when a user closes a purchase prompt, you should not use it to process purchases because those purchases might still fail in the backend for several reasons. For example, if a Roblox system is offline, or if the product price has changed and the user now doesn't have enough Robux to make the purchase. To process purchases, you must useProcessReceipt. UsingProcessReceiptallows you to confirm that the purchase has succeeded before you grant the user the item they have purchased.The
PromptProductPurchaseFinishedevent fires with aPlayer.UserIdinstead of a reference to thePlayerobject.See Also
PromptGamePassPurchaseFinishedto prompt a user to purchase a pass.PromptPurchaseFinishedto prompt a user to purchase affiliate gear or other assets.- For more information on saving and replicating user data like purchases and progress, see Implementing player data and purchases.
PromptPurchaseFinished
MarketplaceService.PromptPurchaseFinished:Connect(function(player, assetId, isPurchased))Fires when a purchase prompt for an affiliate gear sale or other asset is closed. Does not fire for developer product or pass prompts.This event fires when a purchase prompt for an affiliate gear sale or other asset closes. For example, when a user receives the purchase prompt and clicks Cancel, or when they receive a success or error message and click OK.
This event does not fire for developer product or pass prompts.
See Also
PromptGamePassPurchaseFinishedto prompt a user to purchase a pass.PromptProductPurchaseFinishedto prompt a user to purchase a developer product.- For more information on saving and replicating user data like purchases and progress, see Implementing player data and purchases.
PromptRobloxSubscriptionPurchaseFinished
MarketplaceService.PromptRobloxSubscriptionPurchaseFinished:Connect(function(user, didTryPurchasing))Fires when a purchase prompt for Roblox Plus is closed.This event fires when a purchase prompt for Roblox Plus closes. For example, when a user receives the purchase prompt and clicks Cancel, or when they receive a success or error message and click OK.
Note that this event firing does not guarantee the subscription was successfully processed. Listen to
Player.HasRobloxSubscriptionviaInstance.GetPropertyChangedSignalon the server to confirm a subscription change before granting rewards.See Also
PromptRobloxSubscriptionPurchaseto prompt a user to purchase Roblox Plus.Player.HasRobloxSubscription, which can be observed viaInstance.GetPropertyChangedSignalto detect when a user's subscription status changes.
PromptSubscriptionPurchaseFinished
MarketplaceService.PromptSubscriptionPurchaseFinished:Connect(function(user, subscriptionId, didTryPurchasing))Fires when a purchase prompt for a subscription is closed.This event fires when a purchase prompt for an affiliate gear sale or other asset closes. For example, when a user receives the purchase prompt and clicks Cancel, or when they receive a success or error message and click OK.
See Also
PromptSubscriptionPurchaseto prompt a user to purchase a subscription.UserSubscriptionStatusChanged, which fires when the server recognizes that a user's membership has changed.
Callbacks 1
ProcessReceipt
(receiptInfo: Dictionary) → ProductPurchaseDecisionA callback to process receipts of developer product purchases.
MarketplaceService also has every member of Instance. Deprecated and Roblox-only members are hidden.
Reference text from the Roblox Creator Documentation, licensed CC BY 4.0, reorganized by rbxtoolshub.com · Studio 0.743.0.7431133.