What is the difference between this 2 ProcessReceipt code

well I don’t know if this question really belong to this section but since it is a question about coding…
so. is there any difference between BuyingProductV1 and V2? or which one is safe
I don’t want to seem like scamming players or something,
or is there something I am forgetting about receipts? this is my first time creating DevProducts so sorry if this is a nonsense question?

both functions gives player +1 coin so? I really don’t know if there is something wrong or not

ProductFunctions[1733] = function(receipt,Player) -- Test Product Id
	print("WELp")
	if Player.Character and Player.Character:FindFirstChild("Humanoid") then
		Player.leaderstats.Coins.Value += 1
		return true
	end
end

local function BuyingProductV1(ReceiptInfo)
	local player = Players:GetPlayerByUserId(ReceiptInfo.PlayerId)
	if not player then return Enum.ProductPurchaseDecision.NotProcessedYet
	  else
		print("Welp2")
		local Handler = ProductFunctions[ReceiptInfo.ProductId]
		if not Handler then return Enum.ProductPurchaseDecision.NotProcessedYet
		else
			local success, Message = pcall(Handler,ReceiptInfo,player)
			print("Welp3")
			if success then
				print("Successsss")
				return Enum.ProductPurchaseDecision.PurchaseGranted
			else
				warn("Error")
				return Enum.ProductPurchaseDecision.NotProcessedYet
			end
		end
	end
end

local function BuyingProductV2(ReceiptInfo)
	local Player = Players:GetPlayerByUserId(ReceiptInfo.PlayerId)
	if not Player then return nil end
	local Handler = ProductFunctions[ReceiptInfo.ProductId]
	if not Handler then 
		return nil
	end
	local success,Result = pcall(Handler,ReceiptInfo,Player)
	if not success or not Result then
		print("Error")
		return nil
	end
 return true
end


MarketPlaceService.ProcessReceipt = BuyingProductV2
MarketPlaceService.ProcessReceipt = BuyingProductV1

They are essentially the same thing, just formatted in a Different way

I would Recommend V1 as it seems more understandable to read while the V2 is sort of a more simplified version of V1, and if you really wanted to you can shorten the code, like with V2, Like for Example:

local Granted = Enum.ProductPurchaseDecision.PurchaseGranted
local NotProcessed = Enum.ProductPurchaseDecision.NotProcessedYet

print(success and "Successsss" or "Error")
return success and Granted or NotProcessed

-- success and Granted is just if it was successful, 'Granted' would be chosen
-- the or is there in case the statement is false, 'NotProcessed' would be chosen
1 Like

so there is no difference about granting the reward or not granting the reward?
Thanks!
I was confused about return nil, return true part since they are not enum stilled