Questions regarding Process Receipt

I’m on a loss as to how you call the function on process receipt and I want to know what does the first argument of Process Receipt (in a function) represent and the second?

MarketPlaceService.ProcessReceipt = productHandler

Why can’t you just call the function by it’s name? Someone please explain.

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

local Ids = {
[1034505260] = 50,
[1034505524] = 110,
[1034505858] = 250,
[1034506135] = 600,
[1034506492] = 1500,
}

local function productHandler(productInfo)
	
	local Player = Players:GetPlayerByUserId(productInfo.PlayerId)
	
	if not Player then return Enum.ProductPurchaseDecision.NotProcessedYet
	end
	
	Player.leaderstats.Points.Value += Ids[productInfo.ProductId]
	
	return Enum.ProductPurchaseDecision.PurchaseGranted
end

MarketPlaceService.ProcessReceipt = productHandler

The first (and only) parameter is receiptInfo. It is a dictionary containing 6 entries, PurchaseId, PlayerId, ProductId, CurrencySpent, CurrencyType and PlaceIdWherePurchased. They’re all pretty self explanatory but if you want more clarification let me know.

1 Like