How to add more Player info to developer product purchase webhook

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I Would like to add Player Name & Player thumbnail to this webhook.
  2. What is the issue? Include screenshots / videos if possible!
    I was able to add some basic info like price, product name but cant seem to add player name next to userid.
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    Found one similar topic but didn’t help, I successfully use other webhooks that include these fields without a problem and have also tried to adapt the script to it but failed.

Here is the script I need adjusted and below is a similar one that already works.
Thanks in advance!

productName = "Dev Product"
ProductId = 0000
Price = "$90"
MarketplaceService = game:GetService("MarketplaceService")
HTTPService = game:GetService("HttpService")

Webhook_URL = "   " 
MarketplaceService.PromptProductPurchaseFinished:Connect(function(userid, id, ifpurchased)
	
	if ifpurchased then
		
		local Data = {
			
			["content"] = "",
			["embeds"] = {{
				
				["title"] = userid , -- title
				["description"] = " has purchased: " .. productName,
				["type"] = "rich",
				["color"] = tonumber(0xff0065), --any hex colour code
				["fields"] = {
					{
						["name"] =  Price, --name of field, eg mine is Feedback
						["value"] = ifpurchased, -- change to your text
						["inline"] = true
					}
				}
				
			}}
		}
		Data = HTTPService:JSONEncode(Data)
		HTTPService:PostAsync(Webhook_URL, Data)
	end
end)

What I need for the one above is to function like the one below

local url = "  "
local http = game:GetService("HttpService")

	script.Parent.MouseClick:Connect(function(player)


	local data = {
		['embeds'] = {{
			
			['title'] = "" .. player.Name .. "",
			['description'] = "Clicked: " ..  " "..Part.." " ,
			["color"] = tonumber(0xFFFAFA),
			['fields'] = {
				{
					['name'] = " Account Age",
					["value"] =  player.AccountAge,
					['inline'] = true
				},

				{
					['name'] = " User ID",
					['value'] = player.UserId,
					['inline'] = true
				},
			},
			["image"] = {
				['url'] = "https://www.roblox.com/Thumbs/Avatar.ashx?x=250&y=250&username=" .. player.Name,
			}
		}},
		['avatar_url'] = "https://www.roblox.com/Thumbs/Avatar.ashx?x=250&y=250&username=" .. player.Name,
	}
	local finaldata = http:JSONEncode(data)
	http:PostAsync(url, finaldata)
end)
1 Like

https://developer.roblox.com/en-us/api-reference/function/Players/GetPlayerByUserId

From this you should be able to fill in the blanks.

1 Like

Ok, easy fix.

  • To add Player’s Name:
local Name = game.Players:GetNameFromUserIdAsync(userid)
  • Thumbnail URL (which works with Discord ofc):
local ThumbnailURL = "https://www.roblox.com/Thumbs/Avatar.ashx?x=250&y=250&username="..Name

Your script shoud look like this:

productName = "Dev Product"
ProductId = 0000
Price = "$90"
MarketplaceService = game:GetService("MarketplaceService")
HTTPService = game:GetService("HttpService")

Webhook_URL = "   " 

MarketplaceService.PromptProductPurchaseFinished:Connect(function(userid, id, ifpurchased)
local Name = game.Players:GetNameFromUserIdAsync(userid)
local ThumbnailURL = "https://www.roblox.com/Thumbs/Avatar.ashx?x=250&y=250&username="..Name

	if ifpurchased then
		
		local Data = {
			
			["content"] = "",
			["embeds"] = {{
				
				["title"] = userid , -- title
				["description"] = Name.." has purchased: " .. productName,
				["type"] = "rich",
				["color"] = tonumber(0xff0065), --any hex colour code
				["fields"] = {
					{
						["name"] =  Price, --name of field, eg mine is Feedback
						["value"] = ifpurchased, -- change to your text
						["inline"] = true
					};
				},
				["thumbnail"] = {
					["url"] = ThumbnailURL
				},
			}},
		},
		Data = HTTPService:JSONEncode(Data)
		HTTPService:PostAsync(Webhook_URL, Data)
	end
end)
4 Likes

Thank you! Just removed some of those camas and it works great. Would you accept a robux payout? Just join group if so an as usual takes about 2 weeks.

1 Like

Why not fetch the player instance using the API method I linked and then get the player’s name, account age & other information from that?

1 Like

Will try to apply that, thank you!

No it’s alright, it’s for free! :smiley:

(and also the commas can be added at the end of a table, it wont break)

Yea, but I don’t know how this will help.

I mean what matters the most is the user id and the username. Getting random stuff like the account age is useless but everyone is free to do whatever they want, so yea.

It’s fetched in the second script though, hence why I mentioned it (account age).