Why do I keep getting this error with devproducts?

I’m working off from the devhub and for some reason my scripts aren’t working :/, I keep getting the “Error occurred while processing a product purchase” error.

Code:

ServerScript
local MarketplaceService = game:GetService("MarketplaceService")
local DataStoreService = game:GetService("DataStoreService")
local Players = game:GetService("Players")
local purchaseHistoryStore = DataStoreService:GetDataStore("PurchaseHistorytest1")
local productFunctions = {}

-- ProductId 456456 for ?
productFunctions[1110641683] = function(receipt, player)
	print("got ya")
	local amount = 10000
	game:GetService("ReplicatedStorage").frCash:FireServer(player, amount)
		return true -- Successful purchase
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

LocalScript
local MarketplaceService = game:GetService("MarketplaceService")

local Players = game:GetService("Players")

local productID = 1110641683 -- Change this to your developer product ID

-- Function to prompt purchase of the developer product

local function promptPurchase()

local player = Players.LocalPlayer

MarketplaceService:PromptProductPurchase(player, productID)

end

script.Parent.MouseButton1Click:Connect(promptPurchase)

Also, is it safe to handle purchased tokens through a remote event in ReplicatedStorage?

it really depends, If you are using remote events without filtering enabled then this may be a problem.

FilteringEnabled, I’m pretty sure, is turned on always by default.

You cant fire a remote event in a server event with :FireServer(). That only works in local scripts.

Instead, what is a viable option? Just :Fire()?

Thanks for spotting this.

:Fire() is only for BindableEvents, I’ll just have to add the function into the other script.

FilteringEnabled is always on, which is why many games broke a few years ago when it was forced to be on in all games.