What's up with my dev product handler script?

I’m trying to create a developer product. The following is a server script that I used to award the player with items upon buying it.

local MarketplaceService = game:GetService("MarketplaceService")


MarketplaceService.ProcessReceipt = function(receiptInfo)
	if not game.Players:GetPlayerByUserId(receiptInfo.ProductId) then
		return Enum.ProductPurchaseDecision.NotProcessedYet
	else
		if receiptInfo.ProductId == 123123 then -- our product id
			print('works')
			return Enum.ProductPurchaseDecision.PurchaseGranted
		end
	end
	
end

This same script has worked for me previously, and has stopped working. Any idea what’s going on?

Make sure the dev product is in the same game universe, you can’t sell dev products from other games.

It is. The purchase prompts perfectly but the awarding system is broken.

I think Roblox thinks it should return this:

for this:

Try this:

local MarketplaceService = game:GetService("MarketplaceService")
MarketplaceService.ProcessReceipt = function(receiptInfo)
    local Return = nil
    if not game.Players:GetPlayerByUserId(receiptInfo.ProductId) then
	    Return = Enum.ProductPurchaseDecision.NotProcessedYet
    else
	    if receiptInfo.ProductId == 123123 then -- our product id
		    print('works')
		    Return = Enum.ProductPurchaseDecision.PurchaseGranted
		end
    end
    if Return == nil then
	    warn("Return = nil")
    end
end

Still doesn’t work! Nothing shows up in output either.

The parameter of the function GetPlayerByUserId() should be receiptInfo.PlayerId instead of receiptInfo.ProductId

local MarketplaceService = game:GetService("MarketplaceService")


MarketplaceService.ProcessReceipt = function(receiptInfo)
	if not game.Players:GetPlayerByUserId(receiptInfo.PlayerId) then
		return Enum.ProductPurchaseDecision.NotProcessedYet
	else
		if receiptInfo.ProductId == 123123 then -- our product id
			print('works')
			return Enum.ProductPurchaseDecision.PurchaseGranted
		end
	end
	
end
1 Like