Пример #1
0
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    //En Android hay que hacer el init(), esperar a que termine y entonces hacer el QueryInventory
    //En iOS hacemos el RequestProductData directamente
    void Start()
    {
        DontDestroyOnLoad(gameObject);
        dictPrices = new Dictionary <string, string>();

#if UNITY_ANDROID
        GoogleIAB.init(androidPublicKey);
#elif UNITY_IPHONE
        //Request product data
        var androidSkus   = new string[] { item1, item2, item3, item4 };
        var iosProductIds = new string[] { item1, item2, item3, item4 };
        IAP.requestProductData(iosProductIds, androidSkus, productList =>
        {
            Debug.Log("IABManager: Product list received");
            Utils.logObject(productList);

            /*
             * foreach(IAPProduct product in productList){
             *      string s = product.currencyCode;
             *      dictPrices.Add(product.productId, product.currencyCode+" "+product.price);
             *      Debug.Log(product.productId + ": " + product.currencyCode+" "+product.price);
             * }*/
        });
#endif
    }
Пример #2
0
    public void didCompleteWithRecepit(string recepit, string productId)
    {
        //WG.SLog("didCompleteWithRecepit==="+productId);
                #if UNITY_ANDROID
#else
        WGAlertViewController.Self.hiddenConnecting();
        IAP.didFinishLastTransaction(productId);
                #endif
        for (int i = 0; i < szIAPData.Count; i++)
        {
            if (productId.Equals(szIAPData[i].proid) || productId.Equals(szIAPData[i].proid2))
            {
                _dataPlayer.Jewel += szIAPData[i].get_num;
#if Add_AD
                if (!szIAPData[i].proid.Equals("Coins_60"))
                {
                    WGGameWorld.Instance.RemoveAd();
                }
#endif
#if Umeng
                Umeng.GA.Pay(szIAPData[i].cost_num, Umeng.GA.PaySource.AppStore, szIAPData[i].get_num);
#endif
                DataPlayerController.getInstance().saveDataPlayer();
                WGGameUIView.Instance.freshPlayerUI(UI_FRESH.BCOIN);
                WGAlertViewController.Self.showTipView(1001);
            }
        }
    }
Пример #3
0
    void Awake()
    {
#if UNITY_ANDROID
        var key = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAibNcF/DRnzIBlPWzp3lNR3zZYH7Z/b4k8gBZgG3XWLJ/eYTKcUK1vV5hbUx71vO+d4k5eAaOudhD6OlTxi7agex3qaNu45CDBMkS16KzUJBttDzv8WDi7qsbTDBqADXIOpJ5gTWjgTzENgX5RixlZDDlLwX47sjKvxVJgL2oEzjl0F+xquAWY22QuSCFzJzRopxh53V6RCf+SdOtFk2U/uRdoo2VG0R87Fh/3BsVcmp4PUolRKr+jf02/vhm/zhZ8RpzYgJ7kN+qlUXN0ujgJAOFiJbdErGVb45TLFuRN5ybofHa327U5NeOxCasyIhk8tZNGcYvehWaKLtbv42DMQIDAQAB";
        IAP.init(key);
#endif
    }
Пример #4
0
    // Init function, set stuff up here
    public static void Init()
    {
        iap = GameObject.Find("Main Camera").GetComponent <IAP>();
        // initiate some things, buttons?
        // in app purchase login somethings?
        ProductIDs.Add(Constants.PRODUCT_GOLD_10);
        ProductIDs.Add(Constants.PRODUCT_GOLD_50);
        ProductIDs.Add(Constants.PRODUCT_GOLD_110);
        ProductIDs.Add(Constants.PRODUCT_GOLD_250);
        ProductIDs.Add(Constants.PRODUCT_GOLD_750);


        // Will there be some localization thing?
        // This info needs to be the exact same as on the store

        ProductInfoMap.Add(Constants.PRODUCT_GOLD_10, new ProductDescription(Constants.PRODUCT_GOLD_10, "Gold (10)", "$0.99", ProductType.Consumable));

        ProductInfoMap.Add(Constants.PRODUCT_GOLD_50, new ProductDescription(Constants.PRODUCT_GOLD_50, "Gold (50)", "$4.99", ProductType.Consumable));

        ProductInfoMap.Add(Constants.PRODUCT_GOLD_110, new ProductDescription(Constants.PRODUCT_GOLD_110, "Gold (110)", "$9.99", ProductType.Consumable));  // 10% free, most popular

        ProductInfoMap.Add(Constants.PRODUCT_GOLD_250, new ProductDescription(Constants.PRODUCT_GOLD_250, "Gold (250)", "$19.99", ProductType.Consumable)); // 25% free

        ProductInfoMap.Add(Constants.PRODUCT_GOLD_750, new ProductDescription(Constants.PRODUCT_GOLD_750, "Gold (750)", "$49.99", ProductType.Consumable)); // 50% free, best value

        iap.Init(ProductInfoMap);
    }
Пример #5
0
    // Update is called once per frame
    void Update()
    {
        if (confirmation)
        {
            if (yes.pressed)
            {
                yes.pressed  = false;
                confirmation = false;

#if !UNITY_STANDALONE_OSX && !UNITY_STANDALONE_WIN
                IAP.purchaseConsumableProduct(sku, didSucceed =>
                {
                    Debug.Log("purchasing product " + sku + " result: " + didSucceed);
                });

                //GoogleIAB.purchaseProduct(sku);
#endif
                ShowConfirmation(false);
            }
            else if (no.pressed)
            {
                no.pressed   = false;
                confirmation = false;
                ShowConfirmation(false);
            }
        }
    }
Пример #6
0
 public static void purchaseProductWithId(int index)
 {
     if (Application.internetReachability == NetworkReachability.NotReachable)
     {
         Debug.LogError("No Internet");
     }
     else if (_products != null && Application.internetReachability != NetworkReachability.NotReachable)
     {
                     #if UNITY_ANDROID
         var productId = androidSkus[index];
                     #elif UNITY_IPHONE
         var productId = iosProductIds[index];
                     #endif
         IAP.purchaseConsumableProduct(productId, didSucceed =>
                                       { {
                                             Debug.Log("purchasing product " + productId + " result: " + didSucceed);
                                         } });
     }
     else if (_products == null)
     {
         Debug.LogError("Products not available");
     }
     else
     {
         Debug.LogError("Slow Net Connection");
     }
 }
Пример #7
0
    public void InitialRequest()
    {
//		Debug.Log( "Product list received ");
                #if UNITY_ANDROID
        var key = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmDyHYCirtedxLdvp6VJ2iK1B9f7DLxNBr6cWp7hq52aB7G5MlnFGe+HVH4RwwX3PrjpZcQhod+6qeYCxz+7P0dkvi0izb29OEqNjVIgu6DOu2ghRewdhensxgZV5R+odbTx8rA177pAMuYtsZx5nOF+XvlCkOrsDo2LOXJuayNf1+GcF2FQrK6ekPcD5FvQzFUGFjl5OsebK6u9/WDrozItmpQXSr9UgG81BUj6zHyRtyspU6sXohdDTrhfXptB2nTR4+9syFuudA5fF6uRVHvYBaXoZYXYfqnAOUqDN3BG/uGK8edPsxkax4I20tvWVla7LhboqmqdpfDWoZ5MbaQIDAQAB";
        key = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmDyHYCirtedxLdvp6VJ2iK1B9f7DLxNBr6cWp7hq52aB7G5MlnFGe+HVH4RwwX3PrjpZcQhod+6qeYCxz+7P0dkvi0izb29OEqNjVIgu6DOu2ghRewdhensxgZV5R+odbTx8rA177pAMuYtsZx5nOF+XvlCkOrsDo2LOXJuayNf1+GcF2FQrK6ekPcD5FvQzFUGFjl5OsebK6u9/WDrozItmpQXSr9UgG81BUj6zHyRtyspU6sXohdDTrhfXptB2nTR4+9syFuudA5fF6uRVHvYBaXoZYXYfqnAOUqDN3BG/uGK8edPsxkax4I20tvWVla7LhboqmqdpfDWoZ5MbaQIDAQAB";
        IAP.init(key);
                #endif

//		processingForIAPText.gameObject.SetActive (true);

        IAP.requestProductData(iosProductIds, androidSkus, productList =>
        {
            Debug.Log("Product list received 2");
            Utils.logObject(productList);
            if (productList != null)
            {
                productsReceived = true;
                _products        = productList;
            }
            else
            {
                productsReceived = false;
            }
        });
    }
Пример #8
0
 public void GetPurchaseStatus()
 {
     if (iapProcessing != IAPName.None)
     {
         int statusCode = IAP.purchaseStatus(null);
         iapLockPanel.UpdateSpinner();
         if (statusCode == 0)
         {
         }
         else if (statusCode == 1)
         {
             Debug.Log("statusCode:" + statusCode);
             GameApp.GetInstance().GetGameState().DeliverIAPItem(iapProcessing);
             cashPanel.SetCash(GameApp.GetInstance().GetGameState().GetCash());
             iapLockPanel.Hide();
             iapProcessing = IAPName.None;
         }
         else
         {
             Debug.Log("statusCode:" + statusCode);
             iapLockPanel.Hide();
             iapProcessing = IAPName.None;
         }
     }
 }
Пример #9
0
    private void Start()
    {
        Instance = this;

        if (storeController == null)
        {
            InitializedPurchasing();
        }
    }
Пример #10
0
        /// <summary>
        /// Handels IAP for  Oculus
        /// </summary>
        /// <param name="index">The index of the item to purchase</param>
        public void BuyItem(int index)
        {
#if UNITY_EDITOR
            // Give access to all assets if in editor, as checkout is not supported
            DownloadAllAvailable(false);
#else
            IAP.LaunchCheckoutFlow(skus[index]).OnComplete(LaunchCheckoutFlowCallback);
#endif
        }
Пример #11
0
    // Function item purchase
    public void PurchaseIAP(string id, string goodId, int goodCount)
    {
        IAP iap = GetIAPByID(id);

        if (iap != null)
        {
            iap_reward = () => { Purchase(0, goodId, goodCount); };
            BuyProductID(iap.id);
        }
    }
Пример #12
0
    /// <summary>
    /// Awake is called when the script instance is being loaded.
    /// </summary>
    void Awake()
    {
        if (main == null)
        {
            main = this;
        }

        //IAP 初始化
        IAP iap = IAP.main;
    }
Пример #13
0
 public static IAP getInstance()
 {
     if (s_instance == null)
     {
         GameObject obj = new GameObject();
         obj.name   = "Bridge";
         s_instance = obj.AddComponent <IAP>();
     }
     return(s_instance);
 }
Пример #14
0
    void Start()
    {
        var androidSkus   = new string[] { "csgms_remove_ads" };
        var iosProductIds = new string[] { "csgms_remove_ads" };

        IAP.requestProductData(iosProductIds, androidSkus, productList =>
        {
            Debug.Log("Product list received");
            Utils.logObject(productList);
        });
    }
Пример #15
0
    void OnMouseDown()
    {
        IAP.purchaseNonconsumableProduct(productId, (didSucceed, error) => {
            Debug.Log("purchasing product " + productId + " result: " + didSucceed);

            if (!didSucceed)
            {
                Debug.Log("purchase error: " + error);
            }
        });
    }
Пример #16
0
    public void BuyProduct(IAP iap)
    {
        IAPUnit mIap = mInAppProducts.Find(f => (f.mIap == iap));

        #if UNITY_ANDROID
        GoogleIAB.purchaseProduct(mIap.IAP_Id);
        #endif

        #if UNITY_IOS
        StoreKitBinding.purchaseProduct(mIap.IAP_Id, 1);
        #endif
    }
Пример #17
0
 void OnGUI()
 {
     if (GUI.Button(new Rect(100, 100, 100, 80), "ItemList"))
     {
         string list = "{\"items\":[\"item0\",\"item1\",\"item2\"]}";
         IAP.getInstance().getItemList(list, listBack);
     }
     if (GUI.Button(new Rect(400, 100, 100, 80), "pay"))
     {
         IAP.getInstance().pay("item0", payBack);
     }
     GUI.Label(new Rect(100, 400, 800, 800), m_data);
 }
Пример #18
0
    void OnMouseDown()
    {
#if UNITY_ANDROID
        var skus = new string[] { "csgms_remove_ads" };
        GoogleIAB.queryInventory(skus);
#endif
#if UNITY_IOS
        IAP.restoreCompletedTransactions(productId =>
        {
            Debug.Log("restored purchased product: " + productId);
        });
#endif
    }
Пример #19
0
        protected override Variable Evaluate(ParsingScript script)
        {
            bool            isList = false;
            List <Variable> args   = Utils.GetArgs(script,
                                                   Constants.START_ARG, Constants.END_ARG, out isList);

            Utils.CheckArgs(args.Count, 1, m_name);
            string productId = args[0].AsString();

            string description = IAP.GetDescription(productId);

            return(new Variable(description));
        }
Пример #20
0
    void Start()
    {
        instance = this;
        AudioManager.Instance.SetClipInLoopSource(AudioManager.Instance.storeIndex);
        iap = GetComponent <IAP>();

        activeSkinName = DataManager.instance.skinName;

        for (int i = 0; i < blockSprites.Count; i++)
        {
            bool status = PlayerPrefs2.GetBool(blockSprites[i].name);

            GameObject gObject = Instantiate(skinButton) as GameObject;
            gObject.name = blockSprites[i].name;
            gObject.transform.SetParent(buttonContentPanel.transform, false);

            if (status)
            {
                gObject.GetComponent <Image>().sprite = blockSprites[i];
            }
            else
            {
                gObject.GetComponent <Image>().sprite = blockSpritesLocked[i];
            }
            gObject.GetComponent <StoreButton>().isUnlocked = status;

            if (gObject.name == activeSkinName)
            {
                gObject.transform.GetChild(0).gameObject.SetActive(true);
            }
            else
            {
                gObject.transform.GetChild(0).gameObject.SetActive(false);
            }
        }

        string price = "";

        iap.GetProductPrice("skins");

        if (price == null)
        {
            skinPriceMessage.text = "Check your internet connection for skin prices.";
        }
        else
        {
            skinPriceMessage.text = "Each skin price is " + price;
        }
    }
Пример #21
0
    // Use this for initialization
    void Start()
    {
        int count = WGDataController.Instance.szShopData.Count;

        for (int i = 0; i < count; i++)
        {
            MDShopData sd = WGDataController.Instance.szShopData[i];
            if (sd.type == MDShopData.JEWEL)
            {
                szIAPData.Add(sd);
            }
        }
        IOSInterface.self._iapDelegate = this;
        IAP.RequestProducts();
    }
Пример #22
0
    public void OnBuyWithMDShopData(MDShopData data)
    {
#if UNITY_ANDROID
        sCurBuy = "" + data.proid2;

        YeHuoSDK.YHPay(sCurBuy, (float)data.cost_num, data.get_num, (success) => {
            if (success)
            {
                for (int i = 0; i < szIAPData.Count; i++)
                {
                    if (sCurBuy.Equals(szIAPData[i].proid2))
                    {
                        _dataPlayer.Jewel += szIAPData[i].get_num;

                        DataPlayerController.getInstance().saveDataPlayer();
                        WGGameUIView.Instance.freshPlayerUI(UI_FRESH.BCOIN);
                        WGAlertViewController.Self.showTipView(1001);
                    }
                }
            }
        });
#else
        WGAlertViewController.Self.showConnecting();
                #if TEST
        mnIvokeBlock.InvokeBlock(0.3f, () => {
            didCompleteWithRecepit("", data.proid);
        });
                #elif TBSDK
        if (TBSDK.TBIsLogined())
        {
            string order = data.proid + "_" + Core.nData.sysTime + "_" + TBSDK.TBUserID();

            Debug.Log(order);

            ShopOrderManager.getInstance().SetOrderDes(order, data.proid);
            ShopOrderManager.getInstance().setOrderStatu(order, ShopOrderManager.BuyingStates);
            ShopOrderManager.getInstance().saveShopOrder();
            TBSDK.TBPayRMB(data.cost_num, order, data.proid);
        }
        else
        {
            TBSDK.TBLogin(0);
        }
                #else
        IAP.payForProIdentifier(data.proid);
                #endif
#endif
    }
Пример #23
0
        private void LoadLogFiles()
        {
            Debug.Log("Loading AvailableFractals.json");
            AppSession.AvailableFractals = FractalLog.LoadLog(LogNames.AvailableFractals, FractalLog.OpLocation.Resources).Fractals;

            Debug.Log("Loading DownloadedFractals from playerprefs");
            AppSession.DownloadedFractals = FractalLog.LoadLog(LogNames.DownloadedFractals).Fractals;
            Debug.Log("Downloaded Fractal Count: " + AppSession.DownloadedFractals.Count);
            if (AppSession.FirstTimeUser || (!AppSession.FirstTimeUser && AppSession.DownloadedFractals.Count == 0))
            {
                AddPreinstalledExperiences();
            }
            Debug.Log("Downloaded Fractal Count: " + AppSession.DownloadedFractals.Count);

            IAP.GetViewerPurchases().OnComplete(message =>
            {
                if (message == null || message.IsError)
                {
                    Debug.Log("Player purchases could not be retrieved. Defaulting to local copy of purchases.");
                    AppSession.PurchasedFractals = PlayerPrefs.HasKey(LogNames.PurchasedFractals)
                        ? FractalLog.LoadLog(LogNames.PurchasedFractals).Fractals
                        : new List <Fractal>();
                }
                else
                {
                    var list = new List <Fractal>();

                    for (var i = 0; i < message.Data.Count; i++)
                    {
                        var data    = message.Data[i];
                        var fractal = new Fractal
                        {
                            Name = FractalLog.GetElementBySku(AppSession.AvailableFractals, data.Sku).Name,
                            Sku  = data.Sku,
                            Type = 1
                        };
                        list.Add(fractal);
                    }
                    AppSession.PurchasedFractals = list;
                    Debug.Log("Purchased fractals length:" + list.Count);
                    PlayerPrefs.SetString(LogNames.PurchasedFractals, JsonUtility.ToJson(list));
                    PlayerPrefs.Save();
                }
            });
            _logFilesLoaded = true;
        }
Пример #24
0
    public void HandleEvent(UIControl control, int command, float wparam, float lparam)
    {
        for (int i = 0; i < BUTTON_NUM; i++)
        {
            if (control == itemButton[i] && !soldoutLogo[i].Visible)
            {
                AudioPlayer.PlayAudio(ArenaMenuUI.GetInstance().GetComponent <AudioSource>());
                IAP.NowPurchaseProduct(itemList[0][i + page * 3].ID, "1");
                iapProcessing = (IAPName)i + page * 3;
                Debug.Log("IAP ID:" + itemList[0][i + page * 3].ID);
                iapLockPanel.Show();
            }
        }

        if (control == returnButton)
        {
            AudioPlayer.PlayAudio(ArenaMenuUI.GetInstance().GetComponent <AudioSource>());
            Hide();
            if (fromPanel != null)
            {
                fromPanel.Show();
            }
            else
            {
                ArenaMenuUI ui = GameObject.Find("ArenaMenuUI").GetComponent <ArenaMenuUI>();
                ui.GetPanel(MenuName.ARENA).Show();
            }
        }
        else if (control == leftArrowButton)
        {
            if (page > 0)
            {
                page--;
                UpdateItemsUI();
            }
        }
        else if (control == rightArrowButton)
        {
            if (page < 1)
            {
                page++;
                UpdateItemsUI();
            }
        }
    }
Пример #25
0
        public override void Purchase(IAP iap)
        {
            if (string.IsNullOrEmpty(urlPrefix))
            {
                LogError("IAP - Purchase has failed. Facebook Url dont setup");
                iapManager.PurchaseFailed();
                return;
            }

            this.iap = iap;

#if FACEBOOK
            Facebook.Unity.FB.Canvas.Pay(product: server.links.hosting + urlPrefix + iap.name, callback: result =>
            {
                //{ payment_id: 848929916459082, quantity: "2", status: "completed", signed_request: "7QYHzKqKByA7fjiqJUh2bxFvEdqdvn0n_y1zYiyN6tg.eyJhbGCJxdWFudGl0eSI6IjEiLCJzdGF0dXMiOiJjb21wbGV0ZWQifQ" }

                // {"code":400,"body":{"error":{"message":"An active access token must be used to query information about the current user.","type":"OAuthException","code":2500}}}

                if (result == null)
                {
                    LogError("IAP - Purchase Failed");
                    iapManager.PurchaseFailed();
                }
                else if (!string.IsNullOrEmpty(result.Error))
                {
                    LogError("IAP - Purchase Failed: " + result.Error);
                    iapManager.PurchaseFailed();
                }
                else if (result.Cancelled)
                {
                    Log("IAP - Purchase Failed: " + result.RawResult);
                    iapManager.PurchaseFailed();
                }
                else
                {
                    LogDebug("IAP - Purchase Success: " + result.RawResult);

                    iapManager.PurchaseSucceed(new PurchaseData(
                                                   iap,
                                                   (string)result.ResultDictionary["payment_id"],
                                                   (string)result.ResultDictionary["signed_request"]));
                }
            });
#endif
        }