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)
Opens the payment sheet for an order your server created. Before calling this method, create the order on your server with the create order API and pass the returned trade_order_id to the client.
Signature
public static void Pay(TTPayParam param)Caution: The success callback doesn't confirm payment and doesn't authorize delivery. Deliver items only after your server confirms the order through the payment webhook or the query order API.
Parameters
Field | Type | Description | Required |
|
| The trade order ID returned by your server's create order request. | Yes |
|
| Called when the payment call succeeds. | No |
|
| Called when the payment call fails. | No |
|
| Called after | No |
Example
TT.Pay(new TTPayParam
{
trade_order_id = tradeOrderId,
success = result =>
{
// Ask your server for the order status before delivering items
},
fail = error =>
{
// Handle payment failure
}
});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")
});