Example #1
0
    /// <summary>
    /// 登陆后本地缓存一份token,用于查询
    /// </summary>
    /// <param name="LoginInfo"></param>
    public void LoginCallback(string LoginInfo)
    {
        JsonData jsrr = JsonMapper.ToObject(LoginInfo);

        SetMassage(LoginInfo);
        DemoController.showLoading();

        if (jsrr["access_token"] != null)
        {
            CommonDic.getInstance().access_token = jsrr["access_token"].ToString();
        }
        if (jsrr["open_id"] != null)
        {
            CommonDic.getInstance().open_id = jsrr["open_id"].ToString();
        }
        if (jsrr["refresh_token"] != null)
        {
            CommonDic.getInstance().refresh_token = jsrr["refresh_token"].ToString();
        }

        if (jsrr["expires_in"] != null)
        {
            CommonDic.getInstance().expires_in = jsrr["expires_in"].ToString();
        }



        Debug.Log("调用login回调:" + LoginInfo);
    }
Example #2
0
    /// <summary>
    /// 接收支付或者查询订单操作的返回结果,根据提示码确定当前状态及订单信息
    /// </summary>
    /// <param name="payInfo"></param>
    public void QueryOrPayCallback(string queryOrPayInfo)
    {
        JsonData jsrr = JsonMapper.ToObject(queryOrPayInfo);

        if (jsrr["code"] != null)
        {
            CommonDic.getInstance().code = jsrr["code"].ToString();
        }
        if (jsrr["msg"] != null)
        {
            CommonDic.getInstance().msg = jsrr["msg"].ToString();
        }
        if (jsrr != null)
        {
            CommonDic.getInstance().order_info = jsrr[1].ToString();
        }
        if (CommonDic.getInstance().code.Equals("13000") || CommonDic.getInstance().code.Equals("12004"))
        {
            return;
        }

        SetMassage(queryOrPayInfo);
        DemoController.showLoading();
        Debug.Log("调用pay回调:" + queryOrPayInfo);
    }
Example #3
0
    //支付
    public static void Pay(string payOrderJson)
    {
        AndroidJavaClass  jc  = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
        AndroidJavaObject mJo = jc.GetStatic <AndroidJavaObject>("currentActivity");

        jo.Call("pay", CommonDic.getInstance().access_token, CommonDic.getInstance().open_id, payOrderJson);
    }
Example #4
0
    public void UserInfoCallback(string userInfo)
    {
        CommonDic.getInstance().user_info = userInfo;

        SetMassage(userInfo);
        DemoController.showLoading();
        Debug.Log("调用userInfo回调:" + userInfo);
    }
Example #5
0
    //用户信息
    public static void GetUserAPI()
    {
        AndroidJavaClass  jc        = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
        AndroidJavaObject mJo       = jc.GetStatic <AndroidJavaObject>("currentActivity");
        string            userToken = "{\"access_token\":\"" + CommonDic.getInstance().access_token + "\",\"open_id\":\"" + CommonDic.getInstance().open_id + "\"}";

        Debug.Log("Unity json:" + userToken);
        jo.Call("getUserAPI", userToken);
    }
Example #6
0
 bool VerifyLocalToken()
 {
     if (CommonDic.getInstance().access_token.Equals(""))
     {
         GameObject.Find("MassageInfo").GetComponent <Text>().text = "{code:exception,msg:请先登录}";
         currentOrderID = "";
         StopLoading();
         return(false);
     }
     else
     {
         return(true);
     }
 }
Example #7
0
 public void DoPayByCode()
 {
     CommonDic.getInstance().setParameters("subject", "game");
     CommonDic.getInstance().setParameters("body", "gamePay");
     CommonDic.getInstance().setParameters("order_id", getRamdomTestOrderID());
     CommonDic.getInstance().setParameters("total", "0");
     CommonDic.getInstance().setParameters("goods_tag", "game");
     CommonDic.getInstance().setParameters("notify_url", "www.picovr.com");
     CommonDic.getInstance().setParameters("pay_code", GameObject.Find("CodeText").GetComponent <Text>().text);
     Debug.Log("商品码支付" + GameObject.Find("CodeText").GetComponent <Text>().text);
     StartLoading();
     GameObject.Find("CodeText").GetComponent <Text>().text = "";
     InputPanel.SetActive(false);
     PicoPaymentSDK.Pay(CommonDic.getInstance().PayOrderString());
 }
Example #8
0
    //登陆
    public static void Login(string appID, string appKey, string merchantID, string payKey)
    {
        //储存开发者提供的数据
        CommonDic.getInstance().app_ID      = appID;
        CommonDic.getInstance().app_Key     = appKey;
        CommonDic.getInstance().merchant_ID = merchantID;
        CommonDic.getInstance().paykey      = payKey;
        AndroidJavaClass  jc  = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
        AndroidJavaObject mJo = jc.GetStatic <AndroidJavaObject>("currentActivity");     //获取当前Activity的对象

        jo.Call("initPay", appID, merchantID, payKey);


        jo.Call("authSSO", appID, "www.picovr.com", "get_user_info", appKey);
    }
Example #9
0
    void OnClick(GameObject btnObj)
    {
        if (Application.internetReachability == NetworkReachability.NotReachable)
        {
            GameObject.Find("MassageInfo").GetComponent <Text>().text = "{" +
                                                                        "\"ret_code\":\"5000\",\n" +
                                                                        "\"ret_msg\":\"NETWORK_ERROR\"" + "}";
            return;
        }
        switch (btnObj.name)
        {
        case "Login":
            StartLoading();
            PicoPaymentSDK.Login();
            break;

        case "PayOne":
            CommonDic.getInstance().setParameters("subject", "game");
            CommonDic.getInstance().setParameters("body", "gamePay");
            CommonDic.getInstance().setParameters("order_id", getRamdomTestOrderID());
            CommonDic.getInstance().setParameters("total", "1");
            CommonDic.getInstance().setParameters("goods_tag", "game");
            CommonDic.getInstance().setParameters("notify_url", "www.picovr.com");
            CommonDic.getInstance().setParameters("pay_code", "");

            StartLoading();
            PicoPaymentSDK.Pay(CommonDic.getInstance().PayOrderString());

            break;

        case "PayCode":
            InputPanel.SetActive(true);
            break;

        case "QueryOrder":
            StartLoading();
            PicoPaymentSDK.QueryOrder(currentOrderID);
            break;

        case "GetUserAPI":
            StartLoading();
            PicoPaymentSDK.GetUserAPI();
            break;
        }
    }
Example #10
0
    public void LoginCallback(string LoginInfo)
    {
        JsonData jsrr = JsonMapper.ToObject(LoginInfo);

        SetMassage(LoginInfo);
        DemoController.showLoading();

        if (jsrr[IS_SUCCESS] != null)
        {
            CommonDic.getInstance().isSuccess = jsrr[IS_SUCCESS].ToString();
        }
        if (jsrr[MSG] != null)
        {
            CommonDic.getInstance().loginMsg = jsrr[MSG].ToString();
        }

        Debug.Log("调用login回调:" + LoginInfo);
    }
Example #11
0
    void OnClick(GameObject btnObj)
    {
        switch (btnObj.name)
        {
        case "Login":
            StartLoading();
            LoginSDK.Login();
            break;

        case "PayOne":
            CommonDic.getInstance().setParameters("subject", "game");
            CommonDic.getInstance().setParameters("body", "gamePay");
            CommonDic.getInstance().setParameters("order_id", getRamdomTestOrderID());
            CommonDic.getInstance().setParameters("total", "1");
            CommonDic.getInstance().setParameters("goods_tag", "game");
            CommonDic.getInstance().setParameters("notify_url", "www.picovr.com");
            CommonDic.getInstance().setParameters("pay_code", "");

            StartLoading();
            PicoPaymentSDK.Pay(CommonDic.getInstance().PayOrderString());

            break;

        case "PayCode":
            InputPanel.SetActive(true);
            break;

        case "QueryOrder":
            StartLoading();
            PicoPaymentSDK.QueryOrder(currentOrderID);
            break;

        case "GetUserAPI":
            StartLoading();
            LoginSDK.GetUserAPI();
            break;
        }
    }
Example #12
0
    /// <summary>
    /// 接收支付或者查询订单操作的返回结果,根据提示码确定当前状态及订单信息
    /// </summary>
    /// <param name="payInfo"></param>
    public void QueryOrPayCallback(string queryOrPayInfo)
    {
        Debug.Log("Debug.Log - QueryOrPayCallback: " + queryOrPayInfo);

        JsonData jsrr = JsonMapper.ToObject(queryOrPayInfo);

        if (jsrr[CODE] != null)
        {
            CommonDic.getInstance().code = jsrr["code"].ToString();
        }
        if (jsrr[MSG] != null)
        {
            CommonDic.getInstance().msg = jsrr["msg"].ToString();
        }
        if (jsrr != null)
        {
            CommonDic.getInstance().order_info = jsrr[1].ToString();
        }

        SetMassage(queryOrPayInfo);
        DemoController.showLoading();
        Debug.Log("调用pay回调:" + queryOrPayInfo);
    }
    public string PayOrderString()
    {
        string json = JsonMapper.ToJson(CommonDic.getInstance());

        return(json);
    }
    //ButtonClickedEvent
    void OnClick(GameObject btnObj)
    {
        //判断网络
        if (Application.internetReachability == NetworkReachability.NotReachable)
        {
            GameObject.Find("MassageInfo").GetComponent <Text>().text = "{" +
                                                                        "\"ret_code\":\"5000\",\n" +
                                                                        "\"ret_msg\":\"NETWORK_ERROR\"" + "}";
            return;
        }
        switch (btnObj.name)
        {
        case "Login":     //登陆
            StartLoading();
            PicoPaymentSDK.Login();
            break;

        case "PayOne":     //支付1P币
            CommonDic.getInstance().setParameters("subject", "game");
            CommonDic.getInstance().setParameters("body", "gamePay");
            CommonDic.getInstance().setParameters("order_id", getRamdomTestOrderID());
            CommonDic.getInstance().setParameters("total", "1");
            CommonDic.getInstance().setParameters("goods_tag", "game");
            CommonDic.getInstance().setParameters("notify_url", "www.picovr.com");
            CommonDic.getInstance().setParameters("pay_code", "");

            StartLoading();
            //if (!VerifyLocalToken()) {
            //    return;
            //}
            PicoPaymentSDK.Pay(CommonDic.getInstance().PayOrderString());

            break;

        case "PayCode":     //使用商品码支付1P币
            //if (!VerifyLocalToken()) {
            //    return;
            //}

            /*
             * if (CommonDic.getInstance().access_token.Equals(""))
             * {
             *  GameObject.Find("MassageInfo").GetComponent<Text>().text = "请先登录";
             *  currentOrderID = "";
             *  StopLoading();
             *  return;
             * }
             * */
            InputPanel.SetActive(true);

            break;

        case "QueryOrder":     //查询订单
            StartLoading();
            //if (currentOrderID.Equals(""))
            //{
            //    GameObject.Find("MassageInfo").GetComponent<Text>().text = "{code:exception,msg:请先支付}";

            //    StopLoading();
            //    return;
            //}
            PicoPaymentSDK.QueryOrder(currentOrderID);
            break;

        case "GetUserAPI":     //查看用户信息
            StartLoading();
            PicoPaymentSDK.GetUserAPI();

            break;
        }
    }