예제 #1
0
        public void GetLocalPrice(string channel, List <string> productList, MidasGetLocalPriceCallback callback)
        {
            if (!mHasInited)
            {
                Debug.LogError("you should call Initialize first");
                return;
            }

            mMidasGetProductCallback = callback;

            if (productList == null || productList.Count == 0)
            {
                ULog.LogError("productList is empty");
                return;
            }

            string products = Json.Serialize(productList);

            ULog.Log("productList:" + products);
#if UNITY_EDITOR
            ULog.Log("use simulator");
#elif UNITY_ANDROID
            helper = new AndroidJavaClass(helperClass);
            if (helper == null)
            {
            }
            else
            {
                helper.CallStatic("GetProductInfo", channel, products);
            }
#elif UNITY_IOS
            midasSdkGetProductInfo(channel, products);
#endif
        }
예제 #2
0
        public void GetIntroPrice(string channel, List <string> productList, MidasGetIntroPriceCallback callback)
        {
            if (!mHasInited)
            {
                Debug.LogError("you should call Initialize first");
                return;
            }

            mMidasGetIntroPriceCallback = callback;

            if (productList == null || productList.Count == 0)
            {
                ULog.LogError("productList is empty");
                return;
            }

            string products = Json.Serialize(productList);

            ULog.Log("productList:" + products);
#if UNITY_EDITOR
            ULog.Log("use simulator");
#elif UNITY_ANDROID
            ULog.Log("Android not support");
#elif UNITY_IOS
            midasSdkGetIntroPrice(channel, products);
#endif
        }
예제 #3
0
        public void SetLogEnable(bool enable)
        {
            try {
                ULog.setLevel(ULog.Level.Log);
                ULog.Log("SetLogEnable enable:" + enable);

#if UNITY_EDITOR
                ULog.Log("simulator LogEnable");
#elif UNITY_ANDROID
                helper = new AndroidJavaClass(helperClass);
                if (helper == null)
                {
                    ULog.Log("Cannot get Java helper class");
                }
                else
                {
                    helper.CallStatic("SetLogEnable", enable);
                }
#elif UNITY_IOS
                midasSdkLogEnable(enable);
#endif
            } catch (System.Exception e) {
                ULog.LogError("catch exception : " + e.Message);
            }
        }
예제 #4
0
        /// <summary>
        /// Gets the midas SDK version.
        /// </summary>
        ///
        /// <returns>The midas SDK version.</returns>
        public string GetMidasSDKVersion()
        {
            string version = "";

            try {
#if UNITY_EDITOR
                ULog.Log("simulator GetMidasSDKVersion");
#elif UNITY_ANDROID
                helper = new AndroidJavaClass(helperClass);
                if (helper == null)
                {
                    ULog.Log("Cannot get Java helper class");
                }
                else
                {
                    version = helper.CallStatic <string>("GetMidasSDKVersion");
                }
#elif UNITY_IOS
                version = midasSdkGetVersion();
#endif
            } catch (System.Exception e) {
                ULog.LogError("catch exception : " + e.Message);
            }

            return(version);
        }
예제 #5
0
        public void LaunchWeb(APMidasBaseRequest req, MidasPayCallback callback)
        {
            if (!mHasInited)
            {
                Debug.LogError("you should call Initialize first");
                return;
            }

            try {
                mMidasPayCallback = callback;
//				mAPMidasBasePayRequest = req;
                string reqString = req.ToString();
                ULog.Log("LaunchWeb with json : " + reqString);

#if UNITY_EDITOR
                ULog.Log("Simulator LaunchWeb");
#elif UNITY_ANDROID
                helper = new AndroidJavaClass(helperClass);
                if (helper == null)
                {
                    ULog.Log("Cannot get Java helper class");
                }
                else
                {
                    helper.CallStatic("LaunchWeb", reqString);
                }
#elif UNITY_IOS
                ULog.Log("IOS LaunchWeb does not support");
#endif
            } catch (System.Exception e) {
                ULog.LogError("catch exception : " + e.Message);
            }
        }
예제 #6
0
        public void Reprovide(MidasReprovideCallback callback)
        {
            if (!mHasInited)
            {
                Debug.LogError("you should call Initialize first");
                return;
            }
            try {
                mMidasReprovidetCallback = callback;

#if UNITY_EDITOR
                ULog.Log("Simulator Reprovide");
#elif UNITY_ANDROID
                helper = new AndroidJavaClass(helperClass);
                if (helper == null)
                {
                    ULog.Log("Cannot get Java helper class");
                }
                else
                {
                    helper.CallStatic("Reprovide", "");
                }
#elif UNITY_IOS
                midasSdkReprovide();
#endif
            }
            catch (System.Exception e) {
                ULog.LogError("catch exception : " + e.Message);
            }
        }
예제 #7
0
        /// <summary>
        /// 拉起支付
        /// </summary>
        ///
        /// <param name="req">Req.</param>
        /// <param name="callback">Callback.</param>
        public void Pay(APMidasBaseRequest req, MidasPayCallback callback)
        {
            if (!mHasInited)
            {
                Debug.LogError("you should call Initialize first");
                return;
            }
            try {
                appExtend         = req.appExtends;             //保存回调的时候,回传给游戏
                mMidasPayCallback = callback;
//				mAPMidasBasePayRequest = req;
                string bizType = req.GetType().Name;
                ULog.Log("PayType = " + bizType);
                string reqString = req.ToString();
                ULog.Log("Pay with json : " + reqString);
#if UNITY_EDITOR
                ULog.Log("Simulator Pay");
#elif UNITY_ANDROID
                helper = new AndroidJavaClass(helperClass);
                if (helper == null)
                {
                    ULog.Log("Cannot get Java helper class");
                }
                else
                {
                    helper.CallStatic("Pay", bizType, reqString);
                }
#elif UNITY_IOS
                midasSdkPay(bizType, reqString);
#endif
            }
            catch (System.Exception e) {
                ULog.LogError("catch exception : " + e.Message);
            }
        }
예제 #8
0
        // for garena
        public void GetGarenaProductInfo(APMidasBaseRequest request, MidasGetLocalPriceCallback callback)
        {
            if (!mHasInited)
            {
                ULog.LogError("you should call Initialize first");
                return;
            }

            mMidasGetProductCallback = callback;
            string reqString = request.ToString();

            ULog.Log("GetGarenaProductInfo with json : " + reqString);
#if UNITY_EDITOR
            ULog.Log("use simulator");
#elif UNITY_ANDROID
            helper = new AndroidJavaClass(helperClass);
            if (helper == null)
            {
            }
            else
            {
                helper.CallStatic("GetProductInfo", reqString);
            }
#elif UNITY_IOS
            string bizType = request.GetType().Name;
            ULog.Log("PayType = " + bizType);

            midasSdkGetGrnProductInfo(bizType, "os_garena", reqString);
#endif
        }
예제 #9
0
        /// <summary>
        /// 初始化接口
        /// </summary>
        ///
        /// <param name="processName">ProcessName.</param>
        public void SetProcess(string processName)
        {
#if UNITY_EDITOR
            ULog.Log("Emulator SetProcess");
#elif UNITY_ANDROID
            ULog.Log("Android SetProcess does not support");
#elif UNITY_IOS
            midasSdkSetProcess(processName);
#endif
        }
예제 #10
0
        public void MidasGetInfoCallback(string json)
        {
            ULog.Log("Got MidasGetInfoFinish message from Java/OC, json = " + json);
            // 接收到Java/OC层发送的消息后,调用MidasPayService对应的方法
            APMidasGetInfoResult result2 = new APMidasGetInfoResult(json);

            ULog.Log("CallBackUtils.MidasGetInfoFinish result.type = " + result2.type);
            ULog.Log("CallBackUtils.MidasGetInfoFinish result.ret = " + result2.ret);
//            ULog.Log("CallBackUtils.MidasGetInfoFinish result.msg = " + result2.msg);

            MidasPayService.Instance.MidasGetInfoFinishCallback(result2.type, result2.ret, json);
        }
예제 #11
0
        /// <summary>
        /// 初始化接口
        /// </summary>
        ///
        /// <param name="idc">Idc.</param>
        /// <param name="env">Env.</param>
        /// <param name="req">Req.</param>
        /// <param name="callback">Callback.</param>
        public void Initialize(string idc, string env, string idcInfo, APMidasBaseRequest req, MidasInitCallback callback)
        {
            if (mHasInited)
            {
                return;
            }


            mMidasInitCallback = callback;

            try
            {
#if UNITY_EDITOR
                ULog.Log("Emulator Initialize");
                ULog.Log("MidasUnityV" + unityVersion);
#elif UNITY_ANDROID
                //TODO:设置android版本号
                ULog.Log("MidasUnityV" + unityVersion);
#elif UNITY_IOS
//				req.iapInitExtra.Add("app_reserve_3","MidasUnityV"+unityVersion);
#endif

                string reqString = req.ToString();
                ULog.Log("Initialize req json = " + reqString);

#if UNITY_EDITOR
                ULog.Log("Emulator Initialize");
#elif UNITY_ANDROID
                mHasInited = true;
                helper     = new AndroidJavaClass(helperClass);
                if (helper == null)
                {
                    ULog.Log("Cannot get Java helper class");
                }
                else
                {
                    helper.CallStatic("Initialize", idc, env, idcInfo, reqString);
                }
#elif UNITY_IOS
                if (idc.Length == 0)
                {
                    idc = "local";
                }
                mHasInited = midasSdkInitWithIdcInfo(idc, env, idcInfo, reqString);
#endif
            }
            catch (System.Exception e) {
                ULog.LogError("catch exception : " + e.Message);
            }
        }
예제 #12
0
        public void ScanGoogleInventory(int serverId, int roleId, MidasQueryPromotionCallback callback)
        {
            mMidasQueryPromotionCallback = callback;

#if UNITY_EDITOR
            ULog.Log("use simulator");
#elif UNITY_ANDROID
            helper = new AndroidJavaClass(helperClass);
            if (helper == null)
            {
            }
            else
            {
                helper.CallStatic("ScanGoogleInventory", serverId, roleId);
            }
#elif UNITY_IOS
#endif
        }
예제 #13
0
        /// <summary>
        /// 返回IOS平台的内购开关是否已打开,Android平台对这个固定返回True
        /// </summary>
        ///
        /// <returns>The midas SDK version.</returns>
        public bool IsPayEnable()
        {
            bool enable = true;

            try {
#if UNITY_EDITOR
                ULog.Log("simulator IsIAPEnable");
#elif UNITY_ANDROID
                ULog.Log("android IsIAPEnable");
                // Android不作处理,返回默认值True
                enable = true;
#elif UNITY_IOS
                enable = midasSdkPayEnable();
#endif
            } catch (System.Exception e) {
                ULog.LogError("catch exception : " + e.Message);
            }

            return(enable);
        }
예제 #14
0
 public void SetPath(string path)
 {
     try {
                         #if UNITY_EDITOR
         ULog.Log("Emulator SetPath");
                         #elif UNITY_ANDROID
         helper = new AndroidJavaClass(helperClass);
         if (helper == null)
         {
             ULog.Log("Cannot get Java helper class");
         }
         else
         {
             helper.CallStatic("SetPath", path);
         }
                         #elif UNITY_IOS
                         #endif
     } catch (System.Exception e) {
         ULog.LogError("catch exception : " + e.Message);
     }
 }
예제 #15
0
        // type = "wechat"
        public void CouponsRollBack(string s)
        {
            try {
                ULog.Log("CouponsRollBack s = " + s);

#if UNITY_EDITOR
                ULog.Log("Simulator CouponsRollBack");
#elif UNITY_ANDROID
                helper = new AndroidJavaClass(helperClass);
                if (helper == null)
                {
                    ULog.Log("Cannot get Java helper class");
                }
                else
                {
                    helper.CallStatic("CouponsRollBack", s);
                }
#elif UNITY_IOS
#endif
            } catch (System.Exception e) {
                ULog.LogError("catch exception : " + e.Message);
            }
        }
예제 #16
0
        public void GetInfo(string reqType, APMidasBaseRequest req, MidasGetInfoCallback callback)
        {
            if (!mHasInited)
            {
                Debug.LogError("you should call Initialize first");
                return;
            }
            try {
                mMidasGetInfoCallback = callback;
//				mAPMidasBasePayRequest = req;
                string bizType = req.GetType().Name;
                ULog.Log("PayType = " + bizType);
                string reqString = req.ToString();
                ULog.Log("GetInfo with json : " + reqString);

#if UNITY_EDITOR
                ULog.Log("Simulator GetInfo");
#elif UNITY_ANDROID
                helper = new AndroidJavaClass(helperClass);
                if (helper == null)
                {
                    ULog.Log("Cannot get Java helper class");
                }
                else
                {
                    helper.CallStatic("GetInfo", reqType, bizType, reqString);
                }
#elif UNITY_IOS
                // IOS bizTy=APMidasGameRequest
                midasSdkGetInfo(reqType, bizType, reqString);
#endif
            }
            catch (System.Exception e) {
                ULog.LogError("catch exception : " + e.Message);
            }
        }
예제 #17
0
        public JsonSerializable(object json)
        {
            if (json == null)
            {
                throw new ArgumentNullException("json cannot be null");
            }
            Dictionary <string, object> dict = json as Dictionary <string, object>;

            if (dict == null)
            {
                throw new ArgumentException("we take Dictionary<string,object> only");
            }
            foreach (FieldInfo field in JsonInfo.GetInfo(this))
            {
                object[] props = field.GetCustomAttributes(typeof(JsonProp), true);
                if (props == null || props.Length < 1)
                {
                    continue;
                }
                object[]     listProps = field.GetCustomAttributes(typeof(JsonListProp), true);
                JsonProp     prop      = props[0] as JsonProp;
                JsonListProp list      = null;
                if (listProps != null && listProps.Length > 0)
                {
                    list = (JsonListProp)listProps[0];
                }
                if (prop == null)
                {
                    continue;
                }
                try{
                    object value = null;
                    if (dict.TryGetValue(prop.Name, out value))
                    {
                        if (list != null)
                        {
                            IList iList = value as IList;
                            if (iList == null)
                            {
                                continue;                                        // iList = (IList)Activator.CreateInstance(typeof(List<object>));
                            }
                            object currentList = field.GetValue(this);
                            IList  castedList  = null;
                            if (currentList == null)
                            {
                                castedList = (IList)Activator.CreateInstance(field.FieldType);
                            }
                            if (castedList == null)
                            {
                                continue;
                            }
                            foreach (object item in iList)
                            {
                                //object tmpJson = MiniJSON.Json.Deserialize((string)item);
                                object tmpJson = item;
                                //Debug.Log("type : " + tmpJson.GetType() + ", " + tmpJson.ToString());
                                if (tmpJson != null && typeof(Dictionary <string, object>).IsAssignableFrom(tmpJson.GetType()))
                                {
                                    //Debug.Log("item : " + item);
                                    object convt = Activator.CreateInstance(list.ElementType, new System.Object[] { item });
                                    castedList.Add(convt);
                                }
                                else
                                {
                                    castedList.Add(Convert.ChangeType(item, list.ElementType));
                                }
                            }
                            field.SetValue(this, castedList);
                        }
                        else if (typeof(JsonSerializable).IsAssignableFrom(field.FieldType))
                        {
                            object convertedValue = JsonInfo.InstantiateType(field.FieldType, value);
                            if (convertedValue == null)
                            {
                                continue;
                            }
                            field.SetValue(this, convertedValue);
                        }
                        else
                        {
                            field.SetValue(this, Convert.ChangeType(value, field.FieldType));
                        }
                    }
                }catch (FieldAccessException e) {
                    ULog.Log(e.Message);
                }catch (TargetException e) {
                    ULog.Log(e.Message);
                }catch (ArgumentException e) {
                    ULog.Log(e.Message);
                }
            }
        }
예제 #18
0
 public void MidasLoginExpiredCallback()
 {
     ULog.Log("Got MidasLoginExpiredCallback message from Java/OC");
     // 接收到Java/OC层发送的消息后,调用MidasPayService对应的方法
     MidasPayService.Instance.MidasLoginExpiredCallback();
 }
예제 #19
0
 public void MidasPayCallback(string result)
 {
     ULog.Log("CallBackUtils.MidasPayCallback message from Java/OC = " + result);
     // 接收到Java/OC层发送的消息后,调用MidasPayService对应的方法
     MidasPayService.Instance.MidasPayCallback(result);
 }