After a player makes a purchase through a
MarketplaceService/PromptProductPurchase|PromptProductPurchase() dialog, this callback is called multiple times until it returns
Enum.ProductPurchaseDecision.PurchaseGranted. For example, the function is called again for a product when the player joins the game — or even after they have bought something else — unless you return
Enum.ProductPurchaseDecision.PurchaseGranted. Do not return PurchaseGranted if the product could not be granted.
It’s important to carefully examine the information passed to the callback via the receipt info table and properly process the receipt. See the code sample below for a model of how to create a receipt handling callback.
Script. If you're selling multiple products in your game, this callback must handle receipts for all of them.
Receipt Info Table
The receipt info table passed to this callback will contain the following data:
|string||A unique identifier for the specific purchase.|
|number||The ID of the player who made the purchase.|
|number||The ID of the purchased product.|
|number||The amount of currency spent in the purchase.|
|The type of currency spent in the purchase; always |
|number||The ID of the place where the product was purchased (not necessarily the same as the current place's ID).|
The receiptInfo is a table with the following keys:
Expected return type:
An enum representing in what manner the developer product receipt was processed:
This code sample illustrates a
MarketplaceService/ProcessReceipt|ProcessReceipt callback function for a game to handle purchasing of two
Articles/Developer Products In Game Purchases|developer products (more can be added as needed). It properly checks for and records purchases using a
GlobalDataStore called “PurchaseHistory.”
Most importantly, it properly returns
Enum.ProductPurchaseDecision.PurchaseGranted when the transaction is successfully completed or if it’s detected that the purchase has already been granted using the “PurchaseHistory” data store.