Beispiel #1
0
    public void RecordIapTransaction(UnityEngine.Purchasing.Product iap)
    {
        // Check that we have a revenue amount to record.
        if (!string.IsNullOrEmpty(iap.metadata.isoCurrencyCode) && iap.metadata.localizedPrice > 0)
        {
            // Add the Cost of the IAP to a productsSpent object
            var productsSpent = new DeltaDNA.Product()
                                .SetRealCurrency(
                iap.metadata.isoCurrencyCode,
                Product.ConvertCurrency(iap.metadata.isoCurrencyCode, iap.metadata.localizedPrice
                                        )
                );

            // Add the items or currency received to a productsReceived object
            // We have cheated by hardwiring this for this tutorial!
            // Note that the virtualCurrencyType should be one of these 3 values ["PREMIUM","PREMIUM_GRIND","GRIND"]
            var productsReceived = new DeltaDNA.Product()
                                   .AddVirtualCurrency("Coins", "PREMIUM", 100);

            // Create a transaction using the products spent and received objects
            // Note that the transaction type should always be "PURCHASE" for IAPs
            var transactionEvent = new Transaction(
                iap.metadata.localizedTitle,
                "PURCHASE",
                productsReceived,
                productsSpent)
                                   .SetTransactionId(iap.transactionID)
                                   .AddParam("productID", iap.definition.id);

            // Add the transaction receipt if we have one.
            if (iap.hasReceipt)
            {
                // Populate transaction receipt fields dependig on type of receipt
                // https://github.com/deltaDNA/unity-sdk#tracking-revenue
                // https://docs.unity3d.com/Manual/UnityIAPPurchaseReceipts.html

                TransactionReceipt transactionReceipt = new TransactionReceipt();
                transactionReceipt = JsonUtility.FromJson <TransactionReceipt>(iap.receipt);

                if (transactionReceipt.Store == "AppleAppStore")
                {
                    transactionEvent.SetServer("APPLE");
                    transactionEvent.SetReceipt(transactionReceipt.Payload.ToString());
                }
                else if (transactionReceipt.Store == "GooglePlay")
                {
                    GooglePlayReceipt googleReceipt = new GooglePlayReceipt();
                    googleReceipt = JsonUtility.FromJson <GooglePlayReceipt>(transactionReceipt.Payload);

                    transactionEvent.SetServer("GOOGLE");
                    transactionEvent.SetReceipt(googleReceipt.json);
                    transactionEvent.SetReceiptSignature(googleReceipt.signature);
                }
            }

            // Record the transaction event
            DDNA.Instance.RecordEvent(transactionEvent);
            Debug.Log(string.Format("Sent IAP transaction event to DDNA : {0}", iap.definition.id));
        }
    }
Beispiel #2
0
    private static void BuyProductID(string productId)
    {
        if (!IsInitialized)
        {
            MyDebug.LogWarning("BuyProductID FAIL. Not initialized.");
            return;
        }
        if (string.IsNullOrEmpty(productId))
        {
            MyDebug.LogError("BuyProductID FAIL. Empty productId");
            return;
        }

        IAPProduct product = storeController.products.WithID(productId);

        if (product != null && product.availableToPurchase)
        {
            MyDebug.Log($"Purchasing product asychronously: {product.definition.id}");

            currentProductId = productId;

            storeController.InitiatePurchase(product);
        }
        else
        {
            MyDebug.LogError("BuyProductID: FAIL. Not purchasing product, either is not found or is not available for purchase");
        }
    }
            public PurchaseFailedEventArgs(UProduct product, PurchaseFailureReason reason)
            {
                var definition = product.definition;

                ProductId             = definition.id;
                PurchaseFailureReason = reason;
            }
            public ProcessPurchaseEventArgs(PurchaseEventArgs eventArgs)
            {
                var purchasedProduct = eventArgs.purchasedProduct;
                var definition       = purchasedProduct.definition;

                ProductId        = definition.id;
                PurchasedProduct = purchasedProduct;
            }
Beispiel #5
0
 public void PurchError(UnityEngine.Purchasing.Product Product, UnityEngine.Purchasing.PurchaseFailureReason PurchasingUnavailable)
 {
     Debug.LogWarning(PurchasingUnavailable.ToString());
     if (PurchasingUnavailable.ToString().Equals("DuplicateTransaction"))
     {
         RidAdsDoIt();
     }
 }
Beispiel #6
0
 public void BuyCompleteHelpDevNEW(UnityEngine.Purchasing.Product product)
 {
     Debug.Log("PURCHASE WELL");
     PlayerPrefs.SetInt("help", 1);
     MainMenu.mainMenu.HelpAd.SetActive(true);
     Achievements.Benefactor.Unlock();
     //AchivsCommands.GetTheAchiv(Achivs.Benefactor);
 }
Beispiel #7
0
 public void BuyCompleteNoAds(UnityEngine.Purchasing.Product product)
 {
     Debug.Log("PURCHASE WELL");
     PlayerPrefs.SetInt("noads", 1);
     //AchivsCommands.GetTheAchiv(Achivs.NoAd);
     Achievements.NoAds.Unlock();
     MainMenu.mainMenu.btnAd.transform.position = MainMenu.mainMenu.posBtnMoney;
     //MainMenu.mainMenu.btnAd.SetActive(false); //problems
 }
        public void OnPurchaseFailed(UnityEngine.Purchasing.Product product, UnityEngine.Purchasing.PurchaseFailureReason reason)
        {
            IProductIAP productIAP = _products.IsNullOrEmpty() ? null : _products.Find(x => x != null && x.id == product.definition.id);

            if (productIAP == null)
            {
                return;
            }

            "{0} - {1}".LogFormat(this.GetType(), nameof(onPurchaseFailed));
            onPurchaseFailed(productIAP, (PurchaseFailureReason)((int)reason));
        }
Beispiel #9
0
    public void BuyCompleteGetCoinsNew(UnityEngine.Purchasing.Product product)
    {
        Debug.Log("PURCHASE WELL");
        PlayerPrefs.SetInt("GetCoins", 1);
        int coin = PlayerPrefs.GetInt("coins") + 20000;

        PlayerPrefs.SetInt("coins", coin);
        MainMenu.mainMenu.txtCoins.text = coin.ToString();
        Achievements.Get20000coins.Unlock();
        CloudVariables.Coins += 20000;
        Cloud.Storage.Save();
        // AchivsCommands.GetTheAchiv(Achivs.Get20000Coins);
    }
Beispiel #10
0
 public void BuyCompleteSuperShip(UnityEngine.Purchasing.Product product)
 {
     MainMenu.mainMenu.btnHangar[2].transform.position = MainMenu.mainMenu.posBtnMoney;
     PlayerPrefs.SetInt("Ship4", 1);  //сохраняем, что самолет 4 куплен
     CloudVariables.Supership = 1;
     Cloud.Storage.Save();
     Debug.Log(CloudVariables.Supership + "!!!!!!!!!!!!!!!!!!!!!!!");
     MainMenu.mainMenu.shipUnlock[3] = true;
     MainMenu.mainMenu.ChangeShip(3);
     MainMenu.mainMenu.dollar.SetActive(false);
     MainMenu.mainMenu.txtPrices[3].text = "FREE";
     MainMenu.mainMenu.WeaponSpeedUp[3].SetActive(true);
     MainMenu.mainMenu.WeaponSpeedUp[7].SetActive(true);
     MainMenu.mainMenu.WeaponSpeedUp[11].SetActive(true);
     MainMenu.mainMenu.WeaponSpeedUp[15].SetActive(true);
     Achievements.Thirdship.Unlock();
     //AchivsCommands.GetTheAchiv(Achivs.ThirdShip);
 }
 public void ShowStatus(bool isSuccess, UnityEngine.Purchasing.Product product, PurchaseFailureReason reason = PurchaseFailureReason.Unknown)
 {
     if (!autoClose)
     {
         if (isSuccess)
         {
             panel.SetActive(false);
         }
         else
         {
             transactionStatus.text = "Failed";
             if (product != null)
             {
                 buyStatus.text = product.definition.id + "\n" + reason.ToString() + "\n\n<color=#005ed2>Double tap to close.</color>";
             }
             autoClose = true;
         }
         timeStamp = Time.time;
     }
 }
Beispiel #12
0
 public void OnPurchaseFailed(UnityEngine.Purchasing.Product i, PurchaseFailureReason p)
 {
     if (p == PurchaseFailureReason.UserCancelled)
     {
         Mediator.SendMassage("closeView", "preloader");
         processInfoList.Remove(GetProcessInfo(i.definition.id));
         return;
     }
     if (GetProcessInfo(i.definition.id) == null)
     {
         return;
     }
     PopUpsManager.ShowPopUps(LanguageManager.GetInstance().GetString("purchaseFailed"),
                              LanguageManager.GetInstance().GetString("purchaseTryAgain"),
                              delegate {
         PopUpsManager.HidePopUps();
         Mediator.SendMassage("closeView", "preloader");
     },
                              LanguageManager.GetInstance().GetString("close"));
     processInfoList.Remove(GetProcessInfo(i.definition.id));
 }
Beispiel #13
0
 public void OnFailPurchase(UnityEngine.Purchasing.Product product, UnityEngine.Purchasing.PurchaseFailureReason reason)
 {
 }
 // jintaeks 2019/04/09 14:53
 public void BuyComplete(UnityEngine.Purchasing.Product product)
 {
     Debug.Log("Purchase Complete");
 }
Beispiel #15
0
 public void BuyComplete(UnityEngine.Purchasing.Product product)
 {
     PlayerPrefs.SetInt("wichAvatarIsOn", product.id);         //I added it as product.id for this example, you will need to decide how you will do it.
     Application.LoadLevel("Scene/Room3");
 }
            void IStoreListener.OnPurchaseFailed(UProduct product, PurchaseFailureReason reason)
            {
                var eventArgs = new PurchaseFailedEventArgs(product, reason);

                PurchaseFailed(this, eventArgs);
            }
Beispiel #17
0
 public void OnPurchaseFailed(UnityEngine.Purchasing.Product i, PurchaseFailureReason p)
 {
     throw new System.NotImplementedException();
 }
Beispiel #18
0
 public void OnPurchaseFailed(Product item, PurchaseFailureReason r)
 {
     Debug.Log("UnityIAP.OnPurchaseFailed(" + item + ", " + r + ")");
 }
 public PurchaseFailedEventArgs(NativeProduct product, PurchaseFailureReason reason)
 {
     NativeProduct         = product;
     PurchaseFailureReason = reason;
 }
Beispiel #20
0
 public void PurchaseComplete(UnityEngine.Purchasing.Product product)
 {
     Debug.Log("Purchase Complete");
     UIScript.Instance.UnlockGameOver();
     UIScript.Instance.UnlockFullScore();
 }
 private void FailedPurchase(UnityEngine.Purchasing.Product product, UnityEngine.Purchasing.PurchaseFailureReason failureReason)
 {
     ErrorBuy.SetActive(true);
 }
Beispiel #22
0
 public void DonateFailed(UnityEngine.Purchasing.Product product, UnityEngine.Purchasing.PurchaseFailureReason failureReason)
 {
     Debug.Log("PURCHASE FAILED");
 }
Beispiel #23
0
 public void BuyComplete(UnityEngine.Purchasing.Product product)
 {
     Debug.Log("PURCHASE COMPLETE");
 }
Beispiel #24
0
 public void BuyComplete(UnityEngine.Purchasing.Product product)
 {
     GameData.getInstance().coin += 1000;
     PlayerPrefs.SetInt("coin", GameData.getInstance().coin);
     GameData.getInstance().main.txtCoin.text = GameData.getInstance().coin.ToString();
 }
Beispiel #25
0
 public void OnCompletePurchase(UnityEngine.Purchasing.Product product)
 {
     iapPacks.Add(product.definition.id);
 }
Beispiel #26
0
 public void PurchaseFailed(UnityEngine.Purchasing.Product product,
                            UnityEngine.Purchasing.PurchaseFailureReason failure)
 {
     Debug.Log("Purchase Failed");
 }
 public void BuyComplete(UnityEngine.Purchasing.Product product)
 {
     PlayerPrefs.SetInt("adFree", 1);
     Destroy(this.gameObject);
 }
 public ProcessPurchaseEventArgs(NativeProduct nativeProduct)
 {
     NativeProduct = nativeProduct;
 }
Beispiel #29
0
 public void BuyFailedSuperShip(UnityEngine.Purchasing.Product product, UnityEngine.Purchasing.PurchaseFailureReason failureReason)
 {
     Debug.Log("PURCHASE FAILED");
 }
Beispiel #30
0
 public void DonateCompleted(UnityEngine.Purchasing.Product product)
 {
     Debug.Log("PURCHASE COMPLETE");
     thanksObj.SetActive(true);
 }