抖音开放平台Logo
开发者文档
控制台
  • 体验抖音小游戏
  • 游戏引擎
  • Unity 引擎适配
  • WebGL 方案与优化
  • BGDT 手册
  • 接入
  • C# API
  • API 概览
  • 开放能力
  • 基础
  • 设备
  • 文件
  • 媒体
  • 网络
  • 游戏分享
  • 数据缓存
  • 系统
  • 界面
  • 支付
  • 支付请求
  • 支付接入
  • 游戏金币(仅抖音 lite)
  • 广告
  • 宿主事件
  • 抖音云模块
  • 邀请模块
  • PlayerPrefs
  • 调试工具
  • 初始化
  • 渲染
  • Cocos/Laya/Egret引擎适配
  • 基础功能
  • 开放能力
  • 性能优化
  • 安全指引
  • 游戏金币(仅抖音 lite)
    收藏
    我的收藏

    TT.RequestGoldOrder

    6.0.0 开始支持本方法,WebGL也支持该方法
    金币发放 or 扣除。
    前提条件
    业务背景
    使用限制
    注意事项
    仅在当前小游戏生效,离开小游戏后设置失效。
    相关教程

    语法

    public static void RequestGoldOrder( JsonData paramJson, Action<JsonData> successCallback, Action completeCallback, Action<int, string> errorCallback)

    参数说明

    属性名
    类型
    默认值
    必填
    说明
    paramJson
    JsonData
    --
    金币参数使用json的形式传入,例如:{"type":1,"bizId":"xxxxx","goldNum":1,"customId":"xxxx"}
    successCallback
    Action<JsonData>
    --
    接口调用成功的回调函数
    completeCallback
    Action
    --
    接口调用完成的回调函数
    failCallback
    Action<string>
    --
    接口调用失败的回调函数
    paramJson 为 JsonData 包含下列键值对:
    类型
    默认值
    必填
    说明
    type
    string
    --
    订单类型,1-发放金币,2-消耗金币
    bizId
    string
    --
    点位ID,在开发者后台中金币配置中获取, string
    goldNum
    int
    --
    金币数量, int
    customId
    string
    --
    开发者自定义的订单号, string

    代码示例

    private void Test() { var bizId = "xxxx"; var goldNum = 100; var customId = DateTime.UtcNow.ToUniversalTime().Millisecond+"-"+Random.Range(0,11); var paramJson = new JsonData { ["type"] = dropdownEnumsList[dropdownSelectIndex], ["bizId"] = bizId, ["goldNum"] = goldNum, ["customId"] = customId }; Debug.Log($"RequestGoldOrder param :{paramJson.ToJson()}"); TT.RequestGoldOrder(paramJson, orderId => { var printText = $"requestGoldOrder success, {orderId}"; Debug.Log(printText); }, () => { var printText = $"requestGoldOrder complete"; Debug.Log(printText); }, (errorCode, errorMsg) => { var printText = $"requestGoldOrder error, errorCode :{errorCode}, errorMsg:{errorMsg}"; Debug.Log(printText); }); }