Issue with webhook sending

Hey everyone! I’m trying to make it so when someone buys one of the games’ devproducts, it would send a message to the webhook.
Though, it is not currently sending the message to the webhook.
Here’s my script, if that’s helpful:

local webhookLink = "WEBHOOKLINK"
local MarketplaceService = game:GetService("MarketplaceService")

MarketplaceService.PromptPurchaseFinished:Connect(function(player, assetId, isPurchased)
	if isPurchased then
			local Asset = game:GetService("MarketplaceService"):GetProductInfo(assetId)
		    local http = game:GetService("HttpService")
		    local data = 
					{
						["embeds"] = {{
							["title"] = "New Donation",
							["description"] = "**"..player.Name.."** just donated `"..Asset.PriceInRobux.."`!",
							["thumbnail"] = {
								["url"] = "http://www.roblox.com/Thumbs/Avatar.ashx?x=100&y=100&Format=Png&userId=" .. player.UserId,
							},
							["type"] = "rich",
							["color"] = 2489161
						}}
					}
		data = http:JSONEncode(data)
		http:PostAsync(webhookLink, data)
	else
	end
end)

I have tried this in a LocalScript in StarterPlayerScripts and a script in ServerScriptService.

Any help is appreciated, thanks!

2 Likes

Are you getting any errors in the Output window? Also, make sure HTTP Requests are enabled in Studio

2 Likes

Is enabled and no output. (30chars)

1 Like

That color isn’t valid

DEFAULT: 0,
AQUA: 1752220,
GREEN: 3066993,
BLUE: 3447003,
PURPLE: 10181046,
GOLD: 15844367,
ORANGE: 15105570,
RED: 15158332,
GREY: 9807270,
DARKER_GREY: 8359053,
NAVY: 3426654,
DARK_AQUA: 1146986,
DARK_GREEN: 2067276,
DARK_BLUE: 2123412,
DARK_PURPLE: 7419530,
DARK_GOLD: 12745742,
DARK_ORANGE: 11027200,
DARK_RED: 10038562,
DARK_GREY: 9936031,
LIGHT_GREY: 12370112,
DARK_NAVY: 2899536,
LUMINOUS_VIVID_PINK: 16580705,
DARK_VIVID_PINK: 12320855

And there is no reason to supply the embed type when by default it is “rich”, this is most likely an issue with your marketplaceservice code

3 Likes

The color isn’t right.
Try this
[“color”] = 0x2489161

1 Like

The color is valid I believe. I used an embed vizualiser. I guess Lua doesn’t support those color codes than just these specific ones. I will give that a try.

1 Like

it depends on the URL, roblox doesn’t allow webhooking with nontrusted websites, due to ip logging concerns.

1 Like

You can do webhooks with discord.

1 Like

Is he doing discord webhooks? 30 charssss

1 Like

From looking at the code, it looks like discord webhooks.

1 Like

They aren’t hex codes, they are integer representations of hex codes

1 Like

The color code they said wasn’t a HEX code, I now can’t remember the name of it… but it should also work on webhooks. (I haven’t tried the modifications btw.) HEX codes are 6 characters.

1 Like

Hey, doesn’t seem to work:

local webhookLink = "https://discordapp.com/api/webhooks/740819109629001728/OEV2bHKwi6k2mnMujuCzojWYNsitxWmaRcjgjPcs4jgcVZ-XxBhUyHZ_dyIwJkeSSfRH"
local MarketplaceService = game:GetService("MarketplaceService")

MarketplaceService.PromptPurchaseFinished:Connect(function(player, assetId, isPurchased)
	if isPurchased then
			local Asset = game:GetService("MarketplaceService"):GetProductInfo(assetId)
		    local http = game:GetService("HttpService")
		    local data = 
					{
						["embeds"] = {{
							["title"] = "New Donation",
							["description"] = "**"..player.Name.."** just donated `"..Asset.PriceInRobux.."`!",
							["thumbnail"] = {
								["url"] = "http://www.roblox.com/Thumbs/Avatar.ashx?x=100&y=100&Format=Png&userId=" .. player.UserId,
							},
							["color"] = 3066993
						}}
					}
		data = http:JSONEncode(data)
		http:PostAsync(webhookLink, data)
	else
	end
end)

I also tried @varjoy’s color, didn’t work.
I also tried this in a server script and a LocalScript. Which one do you think this belongs to?

1 Like

GetProductInfo should be passed an infotype, unless its an Asset. I believe your product is either a gamepass or devproduct, so you need to specify that with Enum.InfoType.Product or Enum.InfoType.GamePass.

1 Like

Do you think this would work on a LocalScript or a Server Side script?

local webhookLink = "WEBHOOK"
local MarketplaceService = game:GetService("MarketplaceService")

MarketplaceService.PromptPurchaseFinished:Connect(function(player, assetId, isPurchased)
	if isPurchased then
		    local Asset = game:GetService("MarketplaceService"):GetProductInfo(assetId)
		    Asset = Enum.InfoType.Product
		    local http = game:GetService("HttpService")
		    local data = 
					{
						["embeds"] = {{
							["title"] = "New Donation",
							["description"] = "**"..player.Name.."** just donated `"..Asset.PriceInRobux.."`!",
							["thumbnail"] = {
								["url"] = "http://www.roblox.com/Thumbs/Avatar.ashx?x=100&y=100&Format=Png&userId=" .. player.UserId,
							},
							["color"] = 3066993
						}}
					}
		data = http:JSONEncode(data)
		http:PostAsync(webhookLink, data)
	else
	end
end)
1 Like

Pretty sure the issue lies with the marketplace service code. I am pretty sure prompt purchase is for the purchase of roblox gear in your game. However if you are trying to log dev products you will need to use MarketplaceService/ProcessReceipt MarketplaceService | Documentation - Roblox Creator Hub

1 Like

Do you think this would work on a LocalScript or a Server Side script?

1 Like

Server script. @kingerman88 is correct, since prompt purchase finished is not to handle purchasing.

2 Likes