Dev product purchase not working correctly?

Hi, I’m trying to make a confetti dev product if they tip. But I get an error.
code:

local MPS = game:GetService("MarketplaceService")
script.Parent.MouseClick:Connect(function(player)
	MPS:PromptProductPurchase(player, 1131007865)
	local Players = game:GetService("Players")
	local function processReceipt(receiptInfo)
		local player = Players:GetPlayerByUserId(receiptInfo.PlayerId)
		if not player then
			print("There was an error when completing the Purchase!")
			return Enum.ProductPurchaseDecision.NotProcessedYet
		end
		if receiptInfo.PurchaseId == 1131007865 then
			if player then
				local PurchasedConfetti = game.ReplicatedStorage.Confetti:Clone()
				PurchasedConfetti.Parent = game.Workspace
				wait(5)
				PurchasedConfetti:Destroy()
			end
			return Enum.ProductPurchaseDecision.PurchaseGranted
		end

		MPS.ProcessReceipt = processReceipt()
		end
end)

error:
Workspace.TipsJar.BasePart.ClickDetector.Script:6: attempt to index nil with ‘PlayerId’

Why did you do MPS.ProcessReceipt = processReceipt() in the same function where you define it…?

I was watching a yt tutorial bc I couldn’t figure out ProcessReceipt