How To Make A Dev Product Purchase Log Webhook

Currently I have a Donation Board in my game.
How would I make the script ‘detect’ a purchase of dev products?
I already know how to do webhooks, so that might be the only thing I need to know.

You would use JSON Http Service as everyone knows, calculate the tax from each gamepass OR dev product, if you wanted to convert it to USD you would do:

 function robuxToUsd(robux)

    local tax = 0.3*robux

    local afterTax = robux - tax

    return 0.0035*afterTax

    end

then you would create a table and make a function sending from the person, the asset Id, and the amount, also use PostASync once your done, I can’t write this script for you because I don’t have that time right now and I am not allowed to based on Scripting Support Rules

local table = {}

function table:send(person,asset,amount)

Should be a module btw

That’s not what I wanted help with. You’re telling me how to convert Robux to Usd, I’m talking about how I would detect a purchase.

You would need to use ProcessReceipt to detect a purchase of dev products. Here is a link: Link

I said that was optional, I basically told you how it worked I’m not making the whole entire script for you

You can use ProcessReceipt from MarketplaceService. Since you already know how to use webhooks, you would just connect the event of a product being purchased to sending data to your webhook.

Sample code from ProcessReceipt’s page:

local MarketplaceService = game:GetService("MarketplaceService")
local DataStoreService = game:GetService("DataStoreService")
local Players = game:GetService("Players")
 
-- Data store for tracking purchases that were successfully processed
local purchaseHistoryStore = DataStoreService:GetDataStore("PurchaseHistory")
 
-- Table setup containing product IDs and functions for handling purchases
local productFunctions = {}
-- ProductId 123123 for a donation
productFunctions[123123] = function(receipt, player)
	--You would post data to a webhook here aswell!
    return true --Return true to mark success
end
 
-- The core 'ProcessReceipt' callback function
local function processReceipt(receiptInfo)
 
	-- Determine if the product was already granted by checking the data store  
	local playerProductKey = receiptInfo.PlayerId .. "_" .. receiptInfo.PurchaseId
	local purchased = false
	local success, errorMessage = pcall(function()
		purchased = purchaseHistoryStore:GetAsync(playerProductKey)
	end)
	-- If purchase was recorded, the product was already granted
	if success and purchased then
		return Enum.ProductPurchaseDecision.PurchaseGranted
	elseif not success then
		error("Data store error:" .. errorMessage)
	end
 
	-- Find the player who made the purchase in the server
	local player = Players:GetPlayerByUserId(receiptInfo.PlayerId)
	if not player then
		-- The player probably left the game
		-- If they come back, the callback will be called again
		return Enum.ProductPurchaseDecision.NotProcessedYet
	end
	
	-- Look up handler function from 'productFunctions' table above
	local handler = productFunctions[receiptInfo.ProductId]
 
	-- Call the handler function and catch any errors
	local success, result = pcall(handler, receiptInfo, player)
	if not success or not result then
		warn("Error occurred while processing a product purchase")
		print("\nProductId:", receiptInfo.ProductId)
		print("\nPlayer:", player)
		return Enum.ProductPurchaseDecision.NotProcessedYet
	end
 
	-- Record transaction in data store so it isn't granted again
	local success, errorMessage = pcall(function()
		purchaseHistoryStore:SetAsync(playerProductKey, true)
	end)
	if not success then
		error("Cannot save purchase data: " .. errorMessage)
	end
 
	-- IMPORTANT: Tell Roblox that the game successfully handled the purchase
	return Enum.ProductPurchaseDecision.PurchaseGranted
end
 
-- Set the callback; this can only be done once by one script on the server! 
MarketplaceService.ProcessReceipt = processReceipt

To @ItsMeFelixAccept, OP asking how to connect events to a developer product being purchased, not how to convert usd to robux or use webhooks. This is not against the rules of scripting support.

1 Like