MarketplaceService.ProcessReceipt not firing at all?

I’m making a script that when a person buys a gamepass/devproduct, it will fire an event in the replicated storage. But, it appears that the Marketplace.ProcessReceipt event never occurs when I perform a test purchase in studio. Here is my code. What could be the issue?

local MarketplaceService = game:GetService("MarketplaceService")
local Events = game.ReplicatedStorage.Marketplace
local Players =  game:GetService("Players")

local Events = {
    [39145813] = Events.Backpack.Backpack20Slots
}

local function processReceipt(receiptInfo)
    print("TEST") -- does not print and the lines of code below dont do anything

    local player = Players:GetPlayerByUserId(receiptInfo.PlayerId)
    if not player then
        -- player does not exist / left game?
        return Enum.ProductPurchaseDecision.NotProcessedYet
    end
    print(player.Name.." just purchased "..receiptInfo.ProductId)

    for id,event in pairs(Events) do
        if id == receiptInfo.ProductId then
            event:Fire(player, id) -- id parameter isn't always used in other scripts (this is mainly for when effects are bought)
            print("Event Fired for"..id)
            return Enum.ProductPurchaseDecision.PurchaseGranted
        end
    end
end

MarketplaceService.ProcessReceipt = processReceipt

Does your game have multiple scripts with MarketplaceService.ProcessReceipt?

1 Like

try and use PromptGamePassPurchaseFinished for game passes or PromptProductPurchaseFinished for developer products.

Here’s an example for both.

local mps = game:GetService("MarketplaceService")

local Id = 0

-- GamePasses
mps.PromptGamePassPurchaseFinished:Connect(function(player, PassId, Succes)
	if PassId == Id and Succes == true then
		print("GamePass was sucesfully purchased!")
	end
end)

-- Products 
mps.PromptProductPurchaseFinished:Connect(function(userId, PassId, Succes)
	if PassId == Id and Succes == true then
		print("Product was sucesfully purchased!")
	end
end)

Here’s also some references to the api’s
https://developer.roblox.com/en-us/api-reference/event/MarketplaceService/PromptGamePassPurchaseFinished

https://developer.roblox.com/en-us/api-reference/event/MarketplaceService/PromptProductPurchaseFinished

2 Likes