Are they any problems with this devproduct process receipt callback?

I was just wondering as I heard product purchases can fail sometimes. This is the code I currently have for one of my products:

local ID = receiptInfo.ProductId
	if ID == ProductIDs.Robux10ID then
		local PlayerID = receiptInfo.PlayerId
		local Player = Players:GetPlayerByUserId(PlayerID)
		if not Player then
			return Enum.ProductPurchaseDecision.NotProcessedYet
		else
			Player.leaderstats[" Donated"].Value += 10
			Player:SetAttribute("Donation", 10)
			Player:SetAttribute("NameTag", "Starter Support")
			CreateNameTag(Player, "[Starter Support]", Color3.new(1, 1, 1))
			return Enum.ProductPurchaseDecision.PurchaseGranted
		end

Is there any issue with this possibly failing or anything?

4 Likes

Dev product purchases may ‘fail’ in these cases:

  • ProcessReceipt callback errors.
  • ProcessReceipt callback returns Enum.ProductPurchaseDecision.NotProcessedYet
  • ProcessReceipt does not return a value (returns a value which is not a Enum.ProductPurchaseDecision, errors or yields indefinitely)
  • Roblox Backend does not successfully record the value in their backend (accidental/occasional server failures)

When one of these takes place, Roblox will indefinitely call the callback function until it does not ‘fail’ anymore. This will only happen when:

  • Player rejoins the game
  • Player buys same/another dev product

In your case, it’s most probably fine.

This page has all the info.

Thanks for the help because I was worrying whether I had to change anything.