Qadr Ingame Tebex Shop

πŸ“‹ Table of Contents


🎯 Overview

QADR Tebex Shop is a professional Tebex payment system integration developed for RedM servers. This script allows your players to securely shop from the in-game store and automatically receive their rewards.

✨ Features

  • βœ… Secure Payment System: Safe payment processing with Tebex infrastructure

  • βœ… Automatic Product Delivery: Products are automatically delivered to players upon payment completion

  • βœ… Multi-Package Support: Multiple packages can be purchased in a single transaction

  • βœ… Browser Integration: Seamless payment experience through Steam overlay

  • βœ… Real-time Status Tracking: Track payment status in real-time

  • βœ… Multi-Language Support: English and Turkish language support

  • βœ… Database Management: All transactions are stored in the database

  • βœ… Cancel and Rollback: Players can cancel the transaction at any time

πŸ”§ Technical Requirements

  • RedM Server (prerelease build)

  • MySQL Database (mysql-async or oxmysql)

  • RedEM Roleplay Framework

  • Tebex Account (with Creator API access)


πŸ“¦ Installation

Step 1: Script Download and Placement

  1. Copy the script files to your server's resources folder

  2. Make sure the folder name is qadr_tebex_shop

resources/
└── qadr_tebex_shop/
    β”œβ”€β”€ fxmanifest.lua
    β”œβ”€β”€ client/
    β”œβ”€β”€ server/
    β”œβ”€β”€ shared/
    β”œβ”€β”€ html/
    └── lang/

Step 2: Database Setup

The script will automatically create the required table on first startup. However, if you want to create it manually:

CREATE TABLE IF NOT EXISTS qadr_tebex_shop_orders (
    id INT AUTO_INCREMENT PRIMARY KEY,
    playeridentifier VARCHAR(255) NOT NULL,
    basketident VARCHAR(255) NOT NULL,
    `status` ENUM('waiting', 'canceled', 'completed') DEFAULT 'waiting',
    qadr_tebex_shop_id VARCHAR(255) NOT NULL,
    ordernumber VARCHAR(255),
    INDEX idx_playeridentifier (playeridentifier),
    INDEX idx_basketident (basketident),
    INDEX idx_qadr_tebex_shop_id (qadr_tebex_shop_id),
    INDEX idx_ordernumber (ordernumber)
);

Step 3: server.cfg Configuration

Add the following line to your server.cfg file:

ensure qadr_tebex_shop

Important: Make sure the script starts after redem_roleplay and database resource:

ensure mysql-async
ensure redem_roleplay
ensure qadr_tebex_shop

Step 4: Database Connection

If you're using oxmysql, edit the fxmanifest.lua file:

server_script {
    '@oxmysql/lib/MySQL.lua', -- Use this line instead of mysql-async
    "server/server_conf.lua",
    "server/verification.lua",
    "server/server.lua",
}

βš™οΈ Configuration

Tebex API Settings

Edit the server/server_conf.lua file:

qadr_tebex_shop_variable = {
    projectId = "YOUR_PROJECT_ID",  -- Tebex Project ID
    privateKey = "YOUR_PRIVATE_KEY",  -- Tebex Private Key
    publicToken = "YOUR_PUBLIC_TOKEN",  -- Tebex Public Token
    loginReturnUrl = "https://yourdomain.com/redirect.html"  -- Post-login return URL
}

Getting Tebex API Keys

  1. Go to Developers > API Keys section

  2. Copy the following information:

    • Project ID: Your project number

    • Private API Key: Your private API key

    • Public Token: Your public token

⚠️ Security Warning: Never share your privateKey and publicToken publicly!

General Settings

Edit the shared/conf.lua file:

lang = {}
qadr_tebex_shop_lang = "en"  -- Language: "en" or "tr"
qadr_tebex_shop_payment_timeout = 5  -- Payment timeout (minutes)

Language Settings

The script supports the following languages:

  • en - English

  • tr - Turkish

You can create a new file in the lang/ folder to add a new language.


πŸš€ Usage

Basic Usage

To allow players to shop from the store, you need to initiate a checkout process. This is usually triggered by a command, menu, or NPC interaction.

Starting Checkout

RegisterCommand("checkout", function(src, args, raw)
    local packages = {
        ["6301329"] = { -- Tebex Package ID
            addItem = {
                {
                    itemName = "bandage",
                    itemCount = 1,
                    metaData = {}
                },
                {
                    itemName = "water",
                    itemCount = 1,
                    metaData = {}
                }
            },
            addMoney = 5000,
        }
    } 
    TriggerServerEvent("qadr_tebex_shop:createBasket", packages)
end)

Flow Diagram

1. Player uses /checkout command
   ↓
2. Client sends package information to server
   ↓
3. Server creates basket on Tebex
   ↓
4. Browser opens for player to log in
   ↓
5. Player logs in on Tebex
   ↓
6. Products are added to basket
   ↓
7. Player makes payment
   ↓
8. Server verifies payment
   ↓
9. Rewards are automatically given to player

πŸ“š API Reference

Client-Side Events

qadr_tebex_shop:changestatus

Updates payment status and changes UI.

Parameters:

{
    status = "pending" | "success" | "Error" | "firstOpening",
    text = "Error message",  -- Only for Error status
    base_price = 0.00,       -- Total price
    ident = "basket_ident",  -- Basket ID
    user = "username",       -- Username
    rewards = {}             -- Reward list
}

qadr_tebex_shop:paymentSuccess

Triggered when payment is successful.

Parameters:

basket_data = {
    country = "TR",
    currency = "USD",
    username = "buyer_name",
    email = "buyer@email.com",
    base_price = 10.00,
    total_price = 10.00,
    complete = true,
    packages = {...}
}

NUI Callbacks

closePanel

Closes the payment panel and cancels the transaction.

fetch(`https://${GetParentResourceName()}/closePanel`, {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({})
});

πŸ’‘ Examples

Example 1: Simple Single Package Sale

RegisterCommand("buygold", function()
    local packages = {
        ["6301329"] = {
            addItem = {
                {itemName = "gold", itemCount = 10, metaData = {}}
            },
            addMoney = 0
        }
    }
    TriggerServerEvent("qadr_tebex_shop:createBasket", packages)
end)

Example 2: Multi-Package Sale

RegisterCommand("buystarter", function()
    local packages = {
        ["6301329"] = {  -- Starter Package
            addItem = {
                {itemName = "water", itemCount = 5, metaData = {}},
                {itemName = "bread", itemCount = 5, metaData = {}},
                {itemName = "bandage", itemCount = 3, metaData = {}}
            },
            addMoney = 100
        },
        ["6301327"] = {  -- Extra Bonus
            addItem = {
                {itemName = "rope", itemCount = 1, metaData = {}}
            },
            addMoney = 50
        }
    }
    TriggerServerEvent("qadr_tebex_shop:createBasket", packages)
end)

Example 3: Money Only

RegisterCommand("buymoney", function()
    local packages = {
        ["6301330"] = {
            addItem = {},
            addMoney = 10000
        }
    }
    TriggerServerEvent("qadr_tebex_shop:createBasket", packages)
end)

Example 4: Item with Metadata

RegisterCommand("buyweapon", function()
    local packages = {
        ["6301331"] = {
            addItem = {
                {
                    itemName = "weapon_pistol",
                    itemCount = 1,
                    metaData = {
                        durability = 100,
                        ammo = 50,
                        quality = "legendary"
                    }
                }
            },
            addMoney = 0
        }
    }
    TriggerServerEvent("qadr_tebex_shop:createBasket", packages)
end)

Example 5: Menu Integration

-- With MenuAPI or similar menu system
function OpenTebexShop()
    local elements = {
        {label = "Starter Package - $5.00", value = "starter"},
        {label = "Gold Package - $10.00", value = "gold"},
        {label = "VIP Package - $25.00", value = "vip"}
    }
    
    MenuData.Open('default', GetCurrentResourceName(), 'tebex_shop', {
        title = "Tebex Store",
        align = "top-left",
        elements = elements
    }, function(data, menu)
        if data.current.value == "starter" then
            TriggerServerEvent("qadr_tebex_shop:createBasket", {
                ["6301329"] = {
                    addItem = {{itemName = "water", itemCount = 5}},
                    addMoney = 100
                }
            })
        elseif data.current.value == "gold" then
            -- Gold package code
        end
        menu.close()
    end)
end

RegisterCommand("shop", function()
    OpenTebexShop()
end)

Example 6: Listening to Payment Success Event

RegisterNetEvent("qadr_tebex_shop:paymentSuccess")
AddEventHandler("qadr_tebex_shop:paymentSuccess", function(basket_data)
    -- You can perform custom operations
    print("βœ… Payment successful!")
    print("User: " .. basket_data.username)
    print("Total: $" .. basket_data.total_price)
    
    -- Example: Thank you message to player
    TriggerEvent("redem_roleplay:showNotification", {
        type = "success",
        text = "Your purchase has been completed! Thank you.",
        time = 5000
    })
    
    -- Discord webhook notification
    TriggerServerEvent("sendDiscordWebhook", {
        username = basket_data.username,
        amount = basket_data.total_price
    })
end)

πŸ”§ Troubleshooting

Common Errors

1. "Code Used" Error

Cause: Transaction ID has been used before.

Solution:

  • A new transaction ID is generated for each payment

  • Check database: SELECT * FROM qadr_tebex_shop_orders WHERE ordernumber = 'TXN_ID'

2. "Code Wrong" Error

Cause: Transaction ID is invalid or payment is not completed.

Solution:

  • Verify payment is completed from Tebex panel

  • Make sure the transaction ID is correct

3. Item Not Given

Cause: Item name or metadata is incorrect.

Solution:

-- Correct usage
{itemName = "water", itemCount = 1, metaData = {}}

-- Wrong usage
{item = "water", count = 1}  -- ❌ Wrong key names

4. Database Error

Cause: Table not created or connection issue.

Solution:

  • Make sure MySQL service is running

  • Run table creation SQL manually

  • Check server.log file


❓ FAQ (Frequently Asked Questions)

Technical Questions

Q: Is it compatible with other inventory systems? A: No, it currently only works with RedEM Roleplay inventory system.

Q: Can a player start multiple checkouts? A: No, a player can only have one checkout process at a time.

Q: Can I change the payment timeout duration? A: Yes, change the qadr_tebex_shop_payment_timeout value in shared/conf.lua file.

Security Questions

Q: Are my API keys safe? A: Yes, API keys are only used server-side and are never sent to the client.

Q: Can fake payments be made? A: No, all payments are verified through Tebex API and recorded in the database.

Q: Can transaction IDs be reused? A: No, each transaction ID can only be used once. The system performs duplicate checks.

Customization Questions

Q: Can I add a new language? A: Yes, you can create a new language file in the lang/ folder:

lang["de"] = {
    codeUsed = "Code verwendet",
    codeWrong = "Code falsch",
    -- ... other translations
}

Then in shared/conf.lua file:

qadr_tebex_shop_lang = "de"

πŸ“ž Support and Contact

Bug Report

If you find a bug, please report it with the following information:

  1. Server.log output

  2. Step-by-step description of how the error occurs

  3. Expected behavior vs actual behavior

  4. Server version and other scripts used


This script uses the Tebex Limited API. You must comply with Tebex's terms of service.

Important Notes:

  • You cannot redistribute this script without permission

  • You cannot modify files under escrow protection

  • All payment transactions are managed by Tebex Limited


πŸ”„ Version History

v1.0.0

  • βœ… First stable release

  • βœ… Basic payment system

  • βœ… Multi-package support

  • βœ… TR/EN language support


Last Update: November 4, 2025 Document Version: 1.0.0

Last updated