Lesson 3
Developer products and ProcessReceipt
Goal: Grant a repeatable purchase exactly once.
about 7 min3 practice exercises
Developer products can be bought again and again, so there is no "owns it" check. Instead, every purchase arrives on the server as a receipt, in one function called ProcessReceipt.
local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local COINS_100 = 0 -- your developer product ID
MarketplaceService.ProcessReceipt = function(receiptInfo)
local player = Players:GetPlayerByUserId(receiptInfo.PlayerId)
if not player then
return Enum.ProductPurchaseDecision.NotProcessedYet
end
if receiptInfo.ProductId == COINS_100 then
player.leaderstats.Coins.Value += 100
return Enum.ProductPurchaseDecision.PurchaseGranted
end
return Enum.ProductPurchaseDecision.NotProcessedYet
end
Your function must answer with one of two values:
PurchaseGranted: "I have given the player what they paid for."NotProcessedYet: "I could not do it." Roblox will try again the next time the player joins.
Roblox's rules for this function:
- Only one script in the whole game may set
ProcessReceipt. Handle every product in it. - Do not grant items from
PromptProductPurchaseFinished. Roblox says that event firing does not mean the purchase succeeded. - Prices run from 1 to 1,000,000,000 Robux.
To sell a product, a LocalScript calls MarketplaceService:PromptProductPurchase(player, COINS_100).
Go deeper on Rodex
Sources
Checked against Roblox's documentation on . The lesson is in our own words; these pages are the source of truth.