How do I detect (with a script) if someone is currently purchasing a development product?

Title.

I have no idea how to do this, HELP

1 Like
local marketplaceService = game:GetService("MarketplaceService")
marketplaceService.ProcessReceipt = function(receiptInfo)
   --.. user is purchasing a developer product
end
2 Likes

Could you detail this a little more? I’m a little confused.

Please help, I tried doing this on a local script, and it said “ProcessReceipt can be only handled on server” so I wrote this in ServerScriptService:

local mS = game:GetService("MarketplaceService")
local plrs = game:GetService("Players")
local productID = 1578922289

mS.ProcessReceipt = function(receipt)
	local plr = plrs:GetPlayerByUserId(receipt.PlayerId)
	if not plr then
		return Enum.ProductPurchaseDecision.NotProcessedYet
	end
	if receipt.productID == productID then
		print("Thanks for supporting the game," .. plr.Name)
	end
end

But it doesn’t work! HELP

1 Like

You must confirm the operation with Enum.ProductPurchaseDecision.PurchaseGranted. Example:

local mS = game:GetService("MarketplaceService")
local plrs = game:GetService("Players")
local productID = 1578922289

mS.ProcessReceipt = function(receipt)
	local plr = plrs:GetPlayerByUserId(receipt.PlayerId)
	if not plr then
		return Enum.ProductPurchaseDecision.NotProcessedYet
	end
	if receipt.productID == productID then
		print("Thanks for supporting the game," .. plr.Name)
		return Enum.ProductPurchaseDecision.PurchaseGranted
	end
end
2 Likes

Don’t know why, the message did not print.

1 Like

replace to ProductId. Sorry, didn’t see it.

local mS = game:GetService("MarketplaceService")
local plrs = game:GetService("Players")
local productID = 1578922289

mS.ProcessReceipt = function(receipt)
	local plr = plrs:GetPlayerByUserId(receipt.PlayerId)
	if not plr then
		return Enum.ProductPurchaseDecision.NotProcessedYet
	end
	if receipt.ProductId == productID then
		print("Thanks for supporting the game," .. plr.Name)
		return Enum.ProductPurchaseDecision.PurchaseGranted
	end
end
2 Likes

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