Exemplo n.º 1
0
        public void Pay(EB.IAP.Item item, EB.IAP.Transaction transaction, Action <int, object> callback)
        {
            EB.Debug.Log("TencentSDKManager.Pay");
            if (!mInitialized)
            {
                EB.Debug.LogError("TencentSDKManager.Pay: not initialized");
                var callbackData = new Hashtable();
                callbackData.Add("flag", TencentPayState.PAYSTATE_PAYERROR);
                callback(TencentPayRet.RET_FAIL, TencentPayState.PAYSTATE_PAYERROR);
                return;
            }

            var extraInfo = JSON.Parse(transaction.payload);
            int balance   = EB.Dot.Integer("balance", extraInfo, 0);

            if (balance < item.cost)
            {
                mPayCallback += callback;
                TencentSDK.Pay(zoneId, (item.cost * 10).ToString());
            }
            else
            {
                var callbackData = new Hashtable();
                callbackData.Add("payState", TencentPayState.PAYSTATE_PAYSUCC);
                callback(TencentPayRet.RET_SUCC, callbackData);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 仅限支付使用
        /// </summary>
        /// <param name="callback"></param>
        public object GetLoginRecordWithoutPlatform()
        {
            EB.Debug.Log("TencentSDKManager.GetLoginRecordWithoutPlatform");
            string jsonString = TencentSDK.GetLoginRecord();

            EB.Debug.Log("TencentSDKManager.GetLoginRecord:jsonString = {0}", jsonString);
            return(JSON.Parse(jsonString));
        }
Exemplo n.º 3
0
        public object GetLoginRecord(string platform)
        {
            EB.Debug.Log("TencentSDKManager.GetLoginRecord:platform = {0}", platform);
            mPlatform = platform;
            string jsonString = TencentSDK.GetLoginRecord();

            EB.Debug.Log("TencentSDKManager.GetLoginRecord:jsonString = {0}", jsonString);
            return(JSON.Parse(jsonString));
        }
Exemplo n.º 4
0
        public void Logout()
        {
            EB.Debug.Log("TencentSDKManager.Logout");
            if (!mInitialized)
            {
                EB.Debug.LogWarning("TencentSDKManager.Logout TencentSDK has not been inited");
                return;
            }

            if (mLogined)
            {
                TencentSDK.Logout();
                mLogined = false;
                DeletePlatform();
            }
        }
Exemplo n.º 5
0
 public void InitSDK(object initData, Action <string, bool> callback)
 {
     if (mInitialized)
     {
         EB.Debug.LogWarning("TencentSDKManager.InitializeSDK: Initialized");
         callback(null, true);
         return;
     }
     if (Application.platform != RuntimePlatform.Android)
     {
         callback(null, false);
         return;
     }
     zoneId              = EB.Dot.String("zoneId", initData, zoneId);
     mInitCallback      += callback;
     Hub.RunInBackground = true;
     new GameObject("tencent_plugin_listener", typeof(SparxTencentSDKManager));
     TencentSDK.InitSDK();
 }
Exemplo n.º 6
0
        public void Login(string platform, Action <string, object> callback)
        {
            EB.Debug.Log("TencentSDKManager.Login platform = {0}", platform);
            if (!mInitialized)
            {
                callback("TencentSDK has not been inited", null);
                return;
            }
            mPlatform       = platform;
            mLoginCallback += callback;

            var loginRecordData = GetLoginRecord(mPlatform);

            if (loginRecordData != null)
            {
                string accessToken = Dot.String("accessToken", loginRecordData, string.Empty);
                string openId      = Dot.String("openId", loginRecordData, string.Empty);
                if (string.IsNullOrEmpty(accessToken) || string.IsNullOrEmpty(openId))
                {
                    Hub.RunInBackground = true;
                    TencentSDK.Login(platform);
                }
                else
                {
                    Hashtable loginData = new Hashtable();
                    loginData.Add("pltform", TencentSDKManager.QQPlatform);
                    loginData.Add("accessToken", accessToken);
                    loginData.Add("openId", openId);
                    EB.Debug.Log("TencentSDKManager.Login loginData = {0}", JSON.Stringify(loginData));
                    mLoginCallback(null, loginData);
                    SavePlatform(mPlatform);
                    mLogined = true;
                }
            }
            else
            {
                Hub.RunInBackground = true;
                TencentSDK.Login(platform);
            }
        }