# Tebex Implementation

> This guide explains how to connect your Coinsystem V2 with Tebex to handle coin purchases via Tebex.

For recurring VIP packages, use the separate [VIP subscription commands](/docs/scripts/coinsystem/vip-tiers).
They award coins on first purchases and paid renewals, keep upgrades free of coin rewards,
and support removing pending or claimed VIP payments.
The coin-purchase command below is for standalone coin packages.

<steps level="3">

### Add Tebex Secret Key to Your server.cfg

1. Log in to your Tebex control panel.
2. On the left-hand navigation menu, click **Integrations** and **Game Servers**.
3. Click **Instructions** next to the Game Server you want to use.
![](/docs/coinsystem/secretkey.webp)
4. Copy the command provided and paste it into your `server.cfg`. It should look something like this:

```cfg [server.cfg]
sv_tebexSecret <YourSecretKey>
```

Make sure to replace `<YourSecretKey>` with the actual secret key provided by Tebex.

Restart the FiveM server, then return to Tebex and verify the game-server connection. See
[Tebex's FiveM setup guide](https://docs.tebex.io/creators/tebex-control-panel/game-servers/fivem).

### Create a Tebex Package

1. In your Tebex control panel, navigate to **Packages**.
2. Create a new package, for example, "100 Coins".
3. At the bottom of the package creation screen, select **Game Server Commands** as the deliverable type.

![](/docs/coinsystem/deliverable.webp)

1. Select your game server and click **Add Command**.
2. Use the following command to deliver the coins:```bash
saveredeemcode {transaction} 100 {packageId} {purchaseQuantity}
```

<note>

Replace the **100** with the amount of coins delivered by one package. Keep `{packageId}` and
`{purchaseQuantity}` exactly as written. They let Coinsystem count package quantities correctly
while safely ignoring a command if Tebex resends it.

</note>
3. Open the command settings.
4. Select the intended game server and allow the command to run while the player is offline. This command records the payment for the player to claim later.

![](/docs/coinsystem/command.webp)

1. Save your package.

### Test the Integration

1. In the Tebex control panel, click **Payments** on the left-hand menu.
2. Click on **Create Payment**.
3. Enter your username under **Customer** and select the package you created earlier.
4. After creating the payment, you should be able to claim the coins in-game by using your payment ID.

</steps>

## Possible Problems

### A Purchase Can Be Claimed More Than Once

**Problem:** The same Tebex payment command appears multiple times and the payment grants too many coins.

**Fix:** Update every coin package to use the complete command shown above. Coinsystem records each
`{transaction}` and `{packageId}` combination once. Resent commands are ignored, while different
packages and `{purchaseQuantity}` values in the same payment are still counted correctly.

If players are unable to claim their coins after a Tebex purchase, try the following solutions:

### Wait for Processing

**Problem:** Sometimes there's a short delay before coins become available after a successful purchase.

**Fix:** Inform players that it can take **up to 5 minutes** for coins to be claimable in-game after completing the purchase.

### Check Tebex Secret Key Usage

**Problem:** Payment commands may run on the wrong server if multiple servers use the same `sv_tebexSecret`.

**Fix:**

- Open the `server.cfg` file on all running servers.
- Check that the package targets the intended game server in Tebex.
- Make sure only that server uses its `sv_tebexSecret`; remove the same key from development or test servers.
- Restart any server whose configuration you changed.
