In-App Purchases
The In-App Purchase APIs enable players to buy virtual goods, check balances, recharge coins, and navigate to the balance management page.
TT.Pay(param)
Initiates an In-App Purchase. The player will see a payment dialog for the specified product.
Signature
public static void Pay(PayParam param)Parameters
Field | Type | Description | Required |
|
| Payment mode ( | Yes |
|
| Environment (0 for production, 1 for sandbox) | Yes |
|
| Currency type | No |
|
| Payment platform ( | No |
|
| Quantity to purchase (for | No |
|
| Zone ID | No |
|
| Custom order ID for tracking | No |
|
| Additional order information in JSON format | No |
|
| Success callback | No |
|
| Failure callback | No |
|
| Completion callback | No |
Example
TT.Pay(new PayParam
{
mode = "gamecoin",
env = 0,
currency = "diamond",
platform = "android",
buyQuantity = 100,
Success = result => Debug.Log("Payment succeeded"),
Fail = error => Debug.LogError($"Payment failed: {error.ErrMsg}"),
Complete = () => Debug.Log("Payment flow completed")
});TT.NavigateToBalance(param)
Opens the balance management page where the user can view and manage their coin balance.
Signature
public static void NavigateToBalance(NavigateToBalanceParam param)Parameters
Field | Type | Description | Required |
|
| Success callback | No |
|
| Failure callback | No |
|
| Completion callback | No |
Example
TT.NavigateToBalance(new NavigateToBalanceParam
{
Success = () => Debug.Log("Balance page opened"),
Fail = error => Debug.LogError(error.ErrMsg),
Complete = () => Debug.Log("Navigation completed")
});TT.CheckBalance(param)
Queries the user's current coin balance.
Signature
public static void CheckBalance(CheckBalanceParam param)Parameters
Field | Type | Description | Required |
|
| Success callback with balance info | No |
|
| Failure callback | No |
|
| Completion callback | No |
Example
TT.CheckBalance(new CheckBalanceParam
{
Success = result => Debug.Log($"Balance: {result.balance}"),
Fail = error => Debug.LogError(error.ErrMsg),
Complete = () => Debug.Log("Balance check completed")
});TT.Recharge(param)
Initiates a coin recharge flow. The player will see a recharge dialog for the specified amount.
Signature
public static void Recharge(RechargeParam param)Parameters
Field | Type | Description | Required |
|
| Recharge mode | Yes |
|
| Environment (0 for production, 1 for sandbox) | Yes |
|
| Currency type | No |
|
| Payment platform | No |
|
| Quantity to recharge | No |
|
| Zone ID | No |
|
| Custom order ID | No |
|
| Additional order info in JSON | No |
|
| Success callback | No |
|
| Failure callback | No |
|
| Completion callback | No |
Example
TT.Recharge(new RechargeParam
{
mode = "gamecoin",
env = 0,
currency = "diamond",
platform = "android",
buyQuantity = 50,
Success = result => Debug.Log("Recharge succeeded"),
Fail = error => Debug.LogError(error.ErrMsg),
Complete = () => Debug.Log("Recharge flow completed")
});