Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Where Can I Check Who Bought My Developer Product?

I'm trying to make a script that keeps track of who bought my developer product. I have this script, but I'm not sure where to see who bought it.

local MarketplaceService = game:GetService("MarketplaceService")
local DataStoreService = game:GetService("DataStoreService")
local Players = game:GetService("Players")
 

local purchaseHistoryStore = DataStoreService:GetDataStore("PurchaseHistory")
 
local productFunctions = {}

productFunctions[1010354831] = function(receipt, player)
			wait(1)
		return true
	end

local function processReceipt(receiptInfo)
  
	local playerProductKey = receiptInfo.PlayerId .. "_" .. receiptInfo.PurchaseId
	local purchased = false
	local success, errorMessage = pcall(function()
		purchased = purchaseHistoryStore:GetAsync(playerProductKey)
	end)

	if success and purchased then
		return Enum.ProductPurchaseDecision.PurchaseGranted
	elseif not success then
		error("Data store error:" .. errorMessage)
	end
 
	local player = Players:GetPlayerByUserId(receiptInfo.PlayerId)
	if not player then

		return Enum.ProductPurchaseDecision.NotProcessedYet
	end
	

	local handler = productFunctions[receiptInfo.ProductId]
 

	local success, result = pcall(handler, receiptInfo, player)
	if not success or not result then
		warn("Error occurred while processing a product purchase")
		print("\nProductId:", receiptInfo.ProductId)
		print("\nPlayer:", player)
		return Enum.ProductPurchaseDecision.NotProcessedYet
	end
 

	local success, errorMessage = pcall(function()
		purchaseHistoryStore:SetAsync(playerProductKey, true)
	end)
	if not success then
		error("Cannot save purchase data: " .. errorMessage)
	end

	return Enum.ProductPurchaseDecision.PurchaseGranted
end
 
MarketplaceService.ProcessReceipt = processReceipt

2 answers

This discussion is preserved as it was. New answers, comments, and votes are closed.