MarketplaceService
MarketplaceService : Instance
Overview
MarketplaceService is a service responsible for handling in-world product purchases and processing delivery upon successful payment.
Creators must define the ProcessReceipt callback function to ensure that deliveries are not missed when a product is sold, and are responsible for using DataStore or similar mechanisms to make sure deliveries complete successfully.
Properties
ProcessReceipt
Value
A callback function that processes undelivered receipts from successfully purchased products.
Code Samples
Methods
GetProductInfo
Returns the product information corresponding to the product ID (productId) and product type (Enum.InfoType).
Parameters
number ProductId
The ID of the product.
Enum.InfoType InfoType
The type of the product.
Return
Value
A dictionary containing the product information.
stringName: Product namestringDescription: Product descriptionnumberProductId: Product IDstringProductType: Product typenumberPriceInBLUC: Product pricenumberCreated: Time the product was created (UNIX timestamp)numberUpdated: Time the product was last updated (UNIX timestamp)
Code Samples
GetWorldProductsAsync
Returns a Pages object containing information about all world products.
Parameters
Return
Pages
An object containing information about every world product in the current world.
Code Samples
PromptProductPurchase
Requests the purchase of the product corresponding to the world product ID (productId). (A purchase window is displayed through the system UI.)
Parameters
Player Player
The Player who will purchase the product.
number ProductId
The world product ID.
Return
void
Code Samples
Events
PromptProductPurchaseFinished
This event is triggered when the purchase window opened by a purchase request (PromptProductPurchase) is closed. If the purchase succeeds, true is passed to isPurchased; if the user cancels or the purchase fails, false is passed.
This event should only be used to detect whether the purchase window has been closed. It must never be used to process delivery for purchased products.
Parameters
string UserId
The UserId of the Player who requested the purchase.
number ProductId
The ID of the requested product.
bool bIsPurchased
Whether the purchase succeeded.
Code Samples
Callback
ProcessReceipt
An event is triggered that returns information about undelivered receipts among successfully purchased products.
Trigger Conditions
When a world product is successfully purchased (the successful purchase popup is shown to the user),
if there are any undelivered products, those previous pending items will also be triggered together when the new purchase is made.
When the user connects (or reconnects) to the server
How to Update Delivery Status
After successfully delivering the product, return Enum.ProductPurchaseDecision.PurchaseGranted.
Important Notes
The ProcessReceipt event should be connected only once in a server-side script.
This callback can yield indefinitely and remains valid until it receives a response, as long as the server is running.
If there are multiple undelivered receipts, each one will be triggered individually, and the order of these callbacks is non-deterministic.
The callback will only be triggered when the user is present on the server.
However, the result of the callback may still be recorded on the backend even if the user is no longer on the server.
Returning PurchaseGranted from the callback does not guarantee that the backend will successfully record it. In such cases, the receipt status remains unchanged (remains undelivered).
Products in an undelivered state will have their funds held in an Escrow state.
Parameters
table Receipt
A dictionary containing the receipt information for a successfully purchased product.
stringPurchaseId: Receipt IDstringPlayerId: The Player's UserIdnumberProductId: Product IDnumberCurrencySpent: Amount of currency spent on the transactionnumberPurchaseDateTime: Time the product was purchased (UNIX timestamp)
Return
Enum.ProductPurchaseDecision
The delivery status of the world product.
PurchaseGranted: The product has been successfully delivered to the Player.
NotProcessedYet: The product has not yet been delivered.
Code Samples
See also
World Product SalesLast updated