Skip to content

zlexif/tebexapi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

tebexapi

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.

What this resource does

  • Creates and maintains the tebex_transactions database table.
  • Creates and maintains the tebex_command_logs database table.
  • Registers a console-only tebexpurchase command for Tebex purchase callbacks.
  • Registers a console-only tebexstatus command for updating transaction status.
  • Stores the raw purchase payload fields that are passed through the command.
  • Provides a GetTransaction export so other server resources can read a transaction by ID.

What this resource does not do

  • 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.

Requirements

  • A FiveM server.
  • oxmysql installed 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.

Installation

  1. Place the tebexapi folder in your server resources directory.
  2. Make sure oxmysql is installed.
  3. Add the resource to your server.cfg after oxmysql:
ensure oxmysql
ensure tebexapi
  1. Start the server.
  2. 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.

Tebex package setup

Create your packages in the Tebex web panel and add Game Server Commands to each package.

  1. Open your Tebex web panel.
  2. Create or edit a package.
  3. Go to the package command settings.
  4. Select Game Server Commands.
  5. Add a command that runs when the package is purchased.
  6. Use the tebexpurchase command format shown below.
  7. Save the package.
  8. 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.

Purchase command

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.

Example Tebex command

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.

Field order

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.

Status command

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:

  • completed
  • refunded
  • chargeback
  • expired
  • renewed

Using the transaction data in your own scripts

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'
    ))
end

From there, your own code should decide how to grant rewards. Common approaches include:

  • Check package_id or package_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.

Database tables

tebex_transactions

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_id
  • steam_id
  • tebex_user_id
  • username
  • package_id
  • package_name
  • price
  • currency
  • quantity
  • email
  • status
  • raw_payload
  • created_at
  • updated_at

tebex_command_logs

Stores a log entry each time this resource records a purchase or status command.

Important columns:

  • transaction_id
  • command
  • source
  • success
  • message
  • created_at

Testing

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.

Troubleshooting

The command does nothing from in game

This is expected. The commands are console-only so players cannot spoof purchases.

No database rows are created

  • Make sure oxmysql starts before tebexapi.
  • 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.

The transaction is recorded but no reward is given

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.

Package names with spaces are cut off

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.

Security notes

  • Do not expose these commands to players.
  • Do not blindly trust package_name for reward logic if you can use a stable package_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.

About

No description, website, or topics provided.

Resources

Stars

4 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages