Recently I began making an escrow service for roblox, I won’t talk about that here though, you can join that discussion here. While making this I knew I would need a way to automatically make a developer product and then prompt that product purchase to the user. However, I could not find any working solutions for this problem, so I decided to make my own. This, however was inspired by: Custom Developer Products, and some of their code is reused here.
This resource uses an http server made in node.js, along with using the developer product api.
The github repo for the web server can be found here. Currently it uses a json file for storing existing price/product combinations, which I do not recommend, but it is the easiest to do without any extra dependencies and no database knowledge. In my actual solutions I use a custom SQL database. Here’s what you need to do after cloning this repository (this resource does not handle hosting, I have my own dedicated server for that, I suggest a VPS if you want to use this in production, but you can also maybe find a free service such as glitch):
- Ensure node is installed and run
npm i
, this will install the necessary dependencies (including my custom build of noblox.js) - Check the .env file and change it to your liking. You must have your cookie correctly set (you can find out how to do this here, scroll to authentication, I recommend using a bot account that has access to edit games in a group)
- Ensure the
SERVERAUTH
environment variable matches the value on the actual server (more on that later) - Run it with
node index.js
(note: make sure your firewall allows incoming requests from the port you set!)
Alongside this github repository I made an uncopylocked place which you can find here. Here’s what you need to know/change:
- This only handles creating new developer products that are of a set price. The product id is saved with the price and that creates a lookup table that allows us to retrieve products based on the price. This is used specifically for donating. You could modify it to save a name/product id combination instead if you want to save multiple products of the same price.
-
SeverStorage>baseRequestUrl
is important. Change this to the base url with no trailing slash. Make sure to includehttp://
orhttps://
at the start (ex value:http://example.com
. If you have a port along side this without dns, you add that here as well, for example:http://example.com:8592
) -
ReplicatedStorage>GetProduct
is the function theServerScriptService>GetProductHandler
is bound to. Invoke this remote function where ever you need to get a new donation product. The only parameter is the price. - Inside of
ServerScriptService>GetProductHandler
there are a few things you will need to customize: -
-
auth
This should be the same value as the enviornment variableSERVERAUTH
in the web server.
-
-
-
minPrice
andmaxPrice
. Self explanatory. However, ifmaxPrice
is less than or equal tominPrice
, no maximum price will be applied.
-
-
-
requestInterval
this defines how many seconds must pass before sending another request. It’s rate limiting.
-
However, that’s basically all you need to know. Here’s a video of it working (sorry about the messy compression):