ProcessReciept not working, tried everything

1. What do you want to achieve?
I want to achieve making a functional donations leaderboard

2. What’s your issue?
ProcessReciept is processing things twice, thrice, or abnormally.

3. What solutions have you tried so far?
Gone through several Roblox-development Discord servers, none of them have had a solution. Most of them say it must be a Roblox bug.

Basically, when purchasing a 10 robux developer product, waiting 10 seconds, and purchasing a 100 robux developer product, it processes the first 10 robux developer product. You can see in the image below that my webhook and my datastore is processing it as being bought twice. The only thing on my client is prompting the developer product. When purchasing further developer products it keeps cloning previous purchases. Quite an annoying bug as people’s donation numbers easily get inflated.

game.MarketplaceService.ProcessReceipt = function(recieptIgame.MarketplaceService.ProcessReceipt = function(recieptInfo)
	local id = recieptInfo.ProductId
	local playerID = recieptInfo.PlayerId
	local userName = game.Players:GetNameFromUserIdAsync(playerID)
	local data = game.MarketplaceService:GetProductInfo(id, Enum.InfoType.Product)
	local price = data.PriceInRobux

	if price <= 50 then
		game.ReplicatedStorage.Events.MiniMessage:FireAllClients(userName.. " just bought a " ..price.. " robux donation for the game!")
	else
		game.ReplicatedStorage.Events.Broadcast:FireAllClients(userName.. " just bought a " ..price.. " donation for the game!")
	end

	local currentDonation = Donations:GetAsync(playerID)
	
	Donations:SetAsync(playerID, currentDonation + price)
end

EDIT fyi I’ve tried updateasync it didn’t work

1 Like

You need to return Enum.ProductPurchaseDecision.PurchaseGranted

game.MarketplaceService.ProcessReceipt = function(recieptIgame.MarketplaceService.ProcessReceipt = function(recieptInfo)
	local id = recieptInfo.ProductId
	local playerID = recieptInfo.PlayerId
	local userName = game.Players:GetNameFromUserIdAsync(playerID)
	local data = game.MarketplaceService:GetProductInfo(id, Enum.InfoType.Product)
	local price = data.PriceInRobux

	if price <= 50 then
		game.ReplicatedStorage.Events.MiniMessage:FireAllClients(userName.. " just bought a " ..price.. " robux donation for the game!")
	else
		game.ReplicatedStorage.Events.Broadcast:FireAllClients(userName.. " just bought a " ..price.. " donation for the game!")
	end

	local currentDonation = Donations:GetAsync(playerID)
	
	Donations:SetAsync(playerID, currentDonation + price)
	return Enum.ProductPurchaseDecision.PurchaseGranted
end
1 Like

This fixed it! Thank you so much.

Hey, I know this isn’t related to your question, but I was wondering how you made this system. I’m guessing you used HTTP Services. If you learned from a YT video, can you link it here?
Thanks!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.