How to make a post to a discord webhook after someone buys a developer product ingame

Hey everyone, I’ve been doing searches, trying and failing, but I can’t seem to do exactly what the title says.

How to make a post to a discord webhook after someone buys a developer product ingame

I’m not a great scripter which is why I’ve been unable to do this, so does anyone have an idea of how I can do this? I’m hoping that someone could provide me a script and then I would review it so I could learn more about how this works etc.

Thanks! :slight_smile:

1 Like

First of all, make sure that you have enabled the HTTP requests in the game settings.

You should read the Discord Webhook Documentation to know what you need to send.

local Http = game:GetService("HttpService")
local MarketPlaceService = game:GetService("MarketplaceService")

MarketPlaceService.ProcessReceipt = function(...)
	Http:PostAsync('your webhook url', Http:JSONEncode({
		content = 'hello!'
	}))
end

This is how you could send a request after a product is bought. You can also use embeds but you would need to read the documentation a little bit more.

2 Likes

Thank you. One question, if I would to put that in my game, replace my webhook URL, and turn on notifications; would it work or do I have to put things in?

Just make sure to replace the content field with something you want to send. You would also need to filter out some words such as @everyone and @here.

Okay. I’m going to try and do it where it says the username and the gamepass name in the message. Thanks for your help