Example #1
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
        }
Example #2
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
        }
Example #3
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);
        }
Example #4
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
        }
Example #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);
            }
        }
Example #6
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);
            }
        }
Example #7
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);
            }
        }
Example #8
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);
            }
        }
Example #9
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);
            }
        }
Example #10
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);
        }
Example #11
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);
     }
 }
Example #12
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);
            }
        }
Example #13
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);
            }
        }