示例#1
0
    public void onBuyIAPFail(string code)
    {
        Debug.Log("onBuyIAPFail: " + code);

        buying = false;
        WaitMgr.Hide();

        GameAlert.Show("购买失败:" + code);
    }
示例#2
0
    public void onBuyIAPResp(string receipt)
    {
        var file = Application.persistentDataPath + "/receipts/" + receipt;

        buying = false;

        if (!File.Exists(file))
        {
            Debug.Log("receipt not exist");
            return;
        }

        string content = File.ReadAllText(file);
        var    args    = new JsonObject();
        var    token   = NetMgr.GetInstance().getToken();

        args ["token"]  = token;
        args["receipt"] = content;

        var http = Http.GetInstance();

        http.Post("/pay_iap/query_order", args, data => {
            Debug.Log("ret from pay_iap");

            QueryOrderReply ret = JsonUtility.FromJson <QueryOrderReply> (data.ToString());

            if (ret.errcode == (int)QueryOrderErrcode.ORDER_SUCCESS)
            {
                GameAlert.Show("购买成功");

                GameMgr.GetInstance().get_coins();

                File.Delete(file);
            }
            else
            {
                GameAlert.Show("购买失败:" + ret.errcode);
            }

            WaitMgr.Hide();
        }, err => {
            WaitMgr.Hide();
            GameAlert.Show("购买通讯失败");
        });
    }