-- functions


local function ProcessReceipt(receiptInfo)
	local player	= Players:GetPlayerByUserId(receiptInfo.PlayerId)
	if player then
		if receiptInfo.ProductId == TIER_SKIP_ID then
			print(player.Name .. " skipped a tier")
			local success	= script.Parent.Ranking.RankingScript.SkipTier:Invoke(player)
			if success then
				return Enum.ProductPurchaseDecision.PurchaseGranted
			else
				return Enum.ProductPurchaseDecision.NotProcessedYet
			end
		elseif CURRENCY_IDS[receiptInfo.ProductId] then
			local tickets		= CURRENCY_IDS[receiptInfo.ProductId]
			local playerData	= PLAYER_DATA:FindFirstChild(player.Name)
			
			if playerData then
				print(player, "purchased", tickets, "tickets")
				playerData.Currency.Tickets.Value	= playerData.Currency.Tickets.Value + tickets
				local success	= script.Parent.DataScript.SaveData:Invoke(player)
				if success then
					return Enum.ProductPurchaseDecision.PurchaseGranted
				else
					return Enum.ProductPurchaseDecision.NotProcessedYet
				end
			else
				return Enum.ProductPurchaseDecision.NotProcessedYet
			end
		end
	else
		return Enum.ProductPurchaseDecision.NotProcessedYet
	end
end
