I understand that this most likely is due to improper scripting on my end, but I am trying to resolve it to the best of my ability. I have tried resolving this issue for many months now, and every solution I have tried seems to not work. Again, this happens very rarely but it can still happen.
A player within my game purchased a DevProduct, and it gave them this error message:
They were still charged for the full Robux amount, unfortunately. It was my understanding that returning Enum.ProductPurchaseDecision.NotProcessedYet would, in the event they rejoined the server, charge the user as well as grant them the rewards , but it appears this user’s Robux was taken. Can anyone help understand why this may be?
Here is my code:
local function PlayerPurchasedItem(ReceiptInfo)
if typeof(ReceiptInfo) == "table" then
local ProductId = ReceiptInfo.ProductId
local UserId = ReceiptInfo.PlayerId
local Player = nil
if typeof(UserId) == "number" then
pcall(function()
Player = game:GetService("Players"):GetPlayerByUserId(UserId)
end)
end
if Player then
-- Get the handler function associated with the developer product ID and attempt to run it
local Completed = false
local _, Error = pcall(function()
Completed = DevProductFunctions[ProductId](Player,UserId)
end)
if Completed then
-- The player has received their benefits!
-- return PurchaseGranted to confirm the transaction.
print("Purchase completed: ",Completed)
return Enum.ProductPurchaseDecision.PurchaseGranted
else
warn("Failed to process receipt:", ReceiptInfo, Error)
end
end
end
-- the player's benefits couldn't be awarded.
-- return NotProcessedYet to try again next time the player joins.
print("Not processed yet")
return Enum.ProductPurchaseDecision.NotProcessedYet
end
-- Set the callback; this can only be done once by one script on the server!
MarketplaceService.ProcessReceipt = PlayerPurchasedItem
If anyone can help me resolve this issue, it would be greatly appreciated!