tebexapi is a small helper resource for logging Tebex purchases inside your FiveM server database. It gives Tebex a console command to run when a package is purchased, stores the transaction details in MySQL, and exposes that data so your own scripts can decide what to do next.
This is not a ready out-of-the-box store or reward system. It does not automatically give vehicles, items, money, ranks, jobs, permissions, or other rewards. It is meant to help server owners and developers integrate Tebex purchases into their own server logic.
- Creates and maintains the
tebex_transactionsdatabase table. - Creates and maintains the
tebex_command_logsdatabase table. - Registers a console-only
tebexpurchasecommand for Tebex purchase callbacks. - Registers a console-only
tebexstatuscommand for updating transaction status. - Stores the raw purchase payload fields that are passed through the command.
- Provides a
GetTransactionexport so other server resources can read a transaction by ID.
- It does not connect to the Tebex HTTP API by itself.
- It does not create Tebex packages for you.
- It does not grant rewards automatically.
- It does not validate that a package should receive a specific reward.
- It does not replace your own reward, permission, inventory, vehicle, or framework integration code.
You must create the packages in your Tebex panel and configure their Game Server Commands so Tebex runs the commands provided by this resource.
- A FiveM server.
oxmysqlinstalled and started before this resource.- A working Tebex store connected to your game server.
- A developer or server owner who can connect the logged transaction data to the rewards your server should give.
- Place the
tebexapifolder in your server resources directory. - Make sure
oxmysqlis installed. - Add the resource to your
server.cfgafteroxmysql:
ensure oxmysql
ensure tebexapi- Start the server.
- Check your server console for:
[tebexapi] database tables ready
The resource creates its tables automatically on startup. The SQL file in sql/tebexapi.sql is included for reference or manual import if you prefer to manage schema setup yourself.
Create your packages in the Tebex web panel and add Game Server Commands to each package.
- Open your Tebex web panel.
- Create or edit a package.
- Go to the package command settings.
- Select Game Server Commands.
- Add a command that runs when the package is purchased.
- Use the
tebexpurchasecommand format shown below. - Save the package.
- Test the package with a real or test purchase and confirm the transaction is inserted into your database.
The exact placeholder names available in Tebex can vary by store/game-server setup. Use the variables shown by your Tebex panel when editing the Game Server Command. If a field is not available, pass nil so the resource stores it as empty.
Use this command in the Tebex package's Game Server Commands section:
tebexpurchase <transaction_id> <steam_id> <tebex_user_id> <username> <package_id> <price> <currency> <quantity> <email> <package_name>
The command must be run by the server console. Players cannot run it in game.
Adapt the placeholders to the variables available in your Tebex panel:
tebexpurchase {transaction} {steamid} {id} {username} {packageId} {price} {currency} {quantity} {email} {packageName}
If your panel uses different variable names, replace them with the correct Tebex placeholders. For example, some stores may use a different placeholder for the player's identifier, package ID, or transaction ID.
The order matters:
| Position | Field | Description |
|---|---|---|
| 1 | transaction_id |
Unique Tebex transaction/payment ID. Required. |
| 2 | steam_id |
Player Steam/license identifier or nil if unavailable. |
| 3 | tebex_user_id |
Tebex/player user ID or nil if unavailable. |
| 4 | username |
Buyer/player name. |
| 5 | package_id |
Tebex package ID. |
| 6 | price |
Purchase price as a number. |
| 7 | currency |
Currency code, such as USD, EUR, or GBP. |
| 8 | quantity |
Quantity purchased. Defaults to 1 if invalid or empty. |
| 9 | email |
Buyer email or nil if unavailable. |
| 10+ | package_name |
Package name. This can contain spaces. |
Values that are empty, null, nil, or missing are stored as NULL, except transaction_id, which is required.
Use tebexstatus if you want Tebex or an admin-side workflow to update an existing transaction status:
tebexstatus <transaction_id> <completed|refunded|chargeback|expired|renewed> [reason]
Example:
tebexstatus {transaction} refunded Refunded through Tebex
Supported statuses are:
completedrefundedchargebackexpiredrenewed
Other server resources can read a logged transaction with the export:
local transaction = exports.tebexapi:GetTransaction(transactionId)Example:
local transaction = exports.tebexapi:GetTransaction('tbx-123456')
if transaction and transaction.status == 'completed' then
print(('Package %s was purchased by %s'):format(
transaction.package_name or transaction.package_id or 'unknown',
transaction.username or transaction.steam_id or 'unknown'
))
endFrom there, your own code should decide how to grant rewards. Common approaches include:
- Check
package_idorpackage_name. - Match the transaction to a player identifier.
- Give inventory items through your inventory resource.
- Add money through your framework.
- Insert vehicle ownership records.
- Assign roles, permissions, jobs, or VIP status.
- Mark custom rewards as claimed in your own database table.
Keep reward logic idempotent. Tebex commands can be retried or re-run, so your reward script should make sure the same transaction does not grant the same reward twice.
Stores one row per transaction. The transaction_id is the primary key, so running the same purchase command again updates the existing row instead of creating a duplicate.
Important columns:
transaction_idsteam_idtebex_user_idusernamepackage_idpackage_namepricecurrencyquantityemailstatusraw_payloadcreated_atupdated_at
Stores a log entry each time this resource records a purchase or status command.
Important columns:
transaction_idcommandsourcesuccessmessagecreated_at
You can test from the server console:
tebexpurchase test-transaction-001 steam:110000000000000 12345 TestUser 1001 9.99 USD 1 test@example.com Test Package
Then check your database:
SELECT * FROM tebex_transactions WHERE transaction_id = 'test-transaction-001';If the row exists, Tebex command logging is working. The next step is writing your own integration logic to grant rewards based on that stored transaction.
This is expected. The commands are console-only so players cannot spoof purchases.
- Make sure
oxmysqlstarts beforetebexapi. - Check that your database connection is configured correctly.
- Check your server console for MySQL errors.
- Confirm Tebex is actually sending the Game Server Command to this server.
This resource only records the transaction. You still need to write or install server-specific code that reads the transaction and grants the correct reward.
Only the package name field can contain spaces because the resource joins all arguments from position 10 onward. Fields before package name should not contain spaces.
- Do not expose these commands to players.
- Do not blindly trust
package_namefor reward logic if you can use a stablepackage_id. - Always prevent duplicate reward claims for the same
transaction_id. - Treat this as an integration helper, not as a complete anti-fraud or entitlement system.