Exemple #1
0
    private void SendNoTemplateEvent()
    {
        Debug.LogWarning("UM: Product tamplate not found");
        UM_PurchaseResult r = new UM_PurchaseResult();

        OnPurchaseFlowFinishedAction(r);
    }
    //--------------------------------------
    // Event Handlers
    //--------------------------------------


    private void IOS_OnTransactionComplete(PurchaseResult responce)
    {
        UM_InAppProduct p = UltimateMobileSettings.Instance.GetProductByIOSId(responce.ProductIdentifier);

        if (p != null)
        {
            UM_PurchaseResult r = new UM_PurchaseResult();
            r.product          = p;
            r.IOS_PurchaseInfo = responce;


            switch (r.IOS_PurchaseInfo.State)
            {
            case PurchaseState.Purchased:
            case PurchaseState.Restored:
                r.isSuccess = true;
                break;

            case PurchaseState.Deferred:
            case PurchaseState.Failed:
                r.isSuccess = false;
                break;
            }

            SendPurchaseFinishedEvent(r);
        }
        else
        {
            SendNoTemplateEvent();
        }
    }
    //--------------------------------------
    // Android Listners
    //--------------------------------------



    void Android_ActionProductPurchased(BillingResult result)
    {
        UM_InAppProduct p = UltimateMobileSettings.Instance.GetProductByAndroidId(result.purchase.SKU);

        if (p != null)
        {
            if (p.IsConsumable && result.isSuccess)
            {
                AndroidInAppPurchaseManager.instance.consume(result.purchase.SKU);
            }
            else
            {
                UM_PurchaseResult r = new UM_PurchaseResult();
                r.isSuccess           = result.isSuccess;
                r.product             = p;
                r.Google_PurchaseInfo = result.purchase;

                SendPurchaseEvent(r);
            }
        }
        else
        {
            SendNoTemplateEvent();
        }
    }
    //--------------------------------------
    // Action Handlers
    //--------------------------------------

    static void ClientPurchaseFinishedHadnler(UM_PurchaseResult result)
    {
        if (!result.product.IsConsumable && result.isSuccess)
        {
            UM_InAppPurchaseManager.SaveNonConsumableItemPurchaseInfo(result.product);
        }
    }
    private void OnPurchaseFlowFinishedAction(UM_PurchaseResult result)
    {
        /*UM_InAppPurchaseManager.OnPurchaseFlowFinishedAction -= OnPurchaseFlowFinishedAction;*/
        if (result.isSuccess)
        {
            Debug.Log("Product " + result.product.id + " purchase Success");
        }
        else
        {
            Debug.Log("Product " + result.product.id + " purchase Failed");
            return;
        }
        string name = result.product.id;

        //spaceship1 ,coin200, coin600,.. coin 2800
        int bikeId = int.Parse(name.Substring(9));

        if (bikeId < 0 || bikeId > 7)
        {
            Debug.LogError("bad BikeId:" + bikeId.ToString());
            return;
        }
        GameData.selectedBike = bikeId;
        GameData.SetBike(bikeId, true);
        if (MainUI.instance != null)
        {
            MainUI.instance.UpdateBikeInfo(0);
        }
    }
Exemple #6
0
    //--------------------------------------
    // Event Handlers
    //--------------------------------------


    private void OnProductPurchased(BillingResult result)
    {
        UM_InAppProduct p = UltimateMobileSettings.Instance.GetProductByAndroidId(result.Purchase.SKU);

        if (p != null)
        {
            if (UltimateMobileSettings.Instance.TransactionsHandlingMode == UM_TransactionsHandlingMode.Automatic)
            {
                if (p.IsConsumable && result.IsSuccess)
                {
                    AndroidInAppPurchaseManager.Client.Consume(result.Purchase.SKU);
                }
            }

            UM_PurchaseResult r = new UM_PurchaseResult();
            r.isSuccess = result.IsSuccess;
            r.product   = p;
            r.SetResponceCode(result.Response);
            r.Google_PurchaseInfo = result.Purchase;

            SendPurchaseFinishedEvent(r);
        }
        else
        {
            SendNoTemplateEvent();
        }
    }
    //--------------------------------------
    // Protected Methods
    //--------------------------------------

    protected void SendNoTemplateEvent()
    {
        Debug.LogWarning("UM: Product tamplate not found");
        UM_PurchaseResult r = new UM_PurchaseResult();

        SendPurchaseFinishedEvent(r);
    }
Exemple #8
0
 private void OnPurchaseFlowFinishedAction(UM_PurchaseResult result)
 {
     UM_InAppPurchaseManager.Client.OnPurchaseFinished -= OnPurchaseFlowFinishedAction;
     if (result.isSuccess)
     {
         UM_ExampleStatusBar.text = "Product " + result.product.id + " purchase Success";
         PlayerPrefs.SetString("no_ads", "yes");
         inactiveButton();
         if (PlayerPrefs.GetString("Music") != "off")
         {
             transform.GetChild(0).GetComponent <AudioSource> ().clip = successAudio;
             transform.GetChild(0).GetComponent <AudioSource> ().Play();
         }
     }
     else
     {
         UM_ExampleStatusBar.text = "Product " + result.product.id + " purchase Failed";
         if (PlayerPrefs.GetString("Music") != "off")
         {
             transform.GetChild(0).GetComponent <AudioSource> ().clip = failAudio;
             transform.GetChild(0).GetComponent <AudioSource> ().Play();
         }
         new MobileNativeMessage("Oops!", "Something went wrong! Bad connection =/");
     }
 }
Exemple #9
0
    private void SendNoTemplateEvent()
    {
        Debug.LogWarning("UM: Product tamplate not found");
        UM_PurchaseResult r = new UM_PurchaseResult();

        OnPurchaseFlowFinishedAction(r);
        dispatch(ON_PURCHASE_FLOW_FINISHED, r);
    }
Exemple #10
0
    private void FakePurchaseEvent(UM_InAppProduct product)
    {
        UM_PurchaseResult r = new UM_PurchaseResult();

        r.isSuccess = true;
        r.product   = product;
        SendPurchaseEvent(r);
    }
    //--------------------------------------
    // Event Handlers
    //--------------------------------------

    private void OnPurchaseComplete(bool IsSucceeded)
    {
        UM_PurchaseResult r = new UM_PurchaseResult();

        r.isSuccess = IsSucceeded;
        r.product   = _CurrentProduct;

        SendPurchaseFinishedEvent(r);
    }
 private void OnPurchaseFlowFinishedAction(UM_PurchaseResult result)
 {
     UM_InAppPurchaseManager.OnPurchaseFlowFinishedAction -= OnPurchaseFlowFinishedAction;
     if (result.isSuccess)
     {
         UM_ExampleStatusBar.text = "Product " + result.product.id + " purchase Success";
     }
     else
     {
         UM_ExampleStatusBar.text = "Product " + result.product.id + " purchase Failed";
     }
 }
 private void OnPurchaseFlowFinishedAction(UM_PurchaseResult result)
 {
     UM_InAppPurchaseManager.OnPurchaseFlowFinishedAction -= OnPurchaseFlowFinishedAction;
     if (result.isSuccess)
     {
         Debug.Log("Product " + result.product.id + " purchase Success");
     }
     else
     {
         Debug.Log("Product " + result.product.id + " purchase Failed");
     }
 }
 private void OnPurchaseComplete(UM_PurchaseResult res)
 {
     if (res.isSuccess)
     {
         restoredProductsCash.Add(res.product.id);
         currentRestoredItem.Value = res.product.id;
         Fsm.Event(ItemRestoredEvent);
     }
     else
     {
         Fsm.Event(failEvent);
     }
 }
    //--------------------------------------
    //  GET/SET
    //--------------------------------------

    //--------------------------------------
    //  EVENTS
    //--------------------------------------

    private void OnPurchaseFinished(CEvent e)
    {
        UM_PurchaseResult result = e.data as UM_PurchaseResult;

        if (result.isSuccess)
        {
            UM_ExampleStatusBar.text = "Product " + result.product.id + " purchase Success";
        }
        else
        {
            UM_ExampleStatusBar.text = "Product " + result.product.id + " purchase Failed";
        }
    }
Exemple #16
0
    //--------------------------------------
    // IOS Listners
    //--------------------------------------


    private void IOS_OnTransactionComplete(IOSStoreKitResponse responce)
    {
        UM_InAppProduct p = UltimateMobileSettings.Instance.GetProductByIOSId(responce.productIdentifier);

        if (p != null)
        {
            UM_PurchaseResult r = new UM_PurchaseResult();
            r.product          = p;
            r.IOS_PurchaseInfo = responce;
            SendPurchaseEvent(r);
        }
        else
        {
            SendNoTemplateEvent();
        }
    }
Exemple #17
0
    private void WP8_OnProductPurchased(WP8PurchseResponce resp)
    {
        UM_InAppProduct p = UltimateMobileSettings.Instance.GetProductByWp8Id(resp.ProductId);

        if (p != null)
        {
            UM_PurchaseResult r = new UM_PurchaseResult();
            r.product          = p;
            r.WP8_PurchaseInfo = resp;

            SendPurchaseEvent(r);
        }
        else
        {
            SendNoTemplateEvent();
        }
    }
Exemple #18
0
    private void OnPurchaseFlowFinishedAction(UM_PurchaseResult result)
    {
        UM_InAppPurchaseManager.Client.OnPurchaseFinished -= OnPurchaseFlowFinishedAction;
        if (result.isSuccess)
        {
            UM_ExampleStatusBar.text = "Product " + result.product.id + " purchase Success";
            switch (coins_amount)
            {
            case "100_coins":
                addCoins = 100;
                break;

            case "300_coins":
                addCoins = 300;
                break;

            case "500_coins":
                addCoins = 500;
                break;

            case "1000_coins":
                addCoins = 1000;
                break;
            }
            PlayerPrefs.SetInt("Coins", PlayerPrefs.GetInt("Coins") + addCoins);
            coins.text = PlayerPrefs.GetInt("Coins").ToString();

            if (PlayerPrefs.GetString("Music") != "off")
            {
                transform.GetChild(0).GetComponent <AudioSource> ().clip = successAudio;
                transform.GetChild(0).GetComponent <AudioSource> ().Play();
            }
        }
        else
        {
            UM_ExampleStatusBar.text = "Product " + result.product.id + " purchase Failed";


            if (PlayerPrefs.GetString("Music") != "off")
            {
                transform.GetChild(0).GetComponent <AudioSource> ().clip = failAudio;
                transform.GetChild(0).GetComponent <AudioSource> ().Play();
            }
        }
    }
    private void OnProductConsumed(BillingResult result)
    {
        UM_InAppProduct p = UltimateMobileSettings.Instance.GetProductByAndroidId(result.Purchase.SKU);

        if (p != null)
        {
            UM_PurchaseResult r = new UM_PurchaseResult();
            r.isSuccess = result.IsSuccess;
            r.product   = p;
            r.SetResponceCode(result.Response);
            r.Google_PurchaseInfo = result.Purchase;
            SendPurchaseFinishedEvent(r);
        }
        else
        {
            SendNoTemplateEvent();
        }
    }
Exemple #20
0
    private void Android_OnProductConsumed(CEvent e)
    {
        BillingResult result = e.data as BillingResult;

        UM_InAppProduct p = UltimateMobileSettings.Instance.GetProductByAndroidId(result.purchase.SKU);

        if (p != null)
        {
            UM_PurchaseResult r = new UM_PurchaseResult();
            r.isSuccess           = result.isSuccess;
            r.product             = p;
            r.Google_PurchaseInfo = result.purchase;
            SendPurchaseEvent(r);
        }
        else
        {
            SendNoTemplateEvent();
        }
    }
Exemple #21
0
    //--------------------------------------
    // Event Handlers
    //--------------------------------------


    private void HandleAmazonPurchaseProductReceived(AMN_PurchaseResponse response)
    {
        Debug.Log("[Amazon] HandleAmazonPurchaseProductReceived");

        UM_InAppProduct p = UltimateMobileSettings.Instance.GetProductByAmazonId(response.Sku);

        if (p != null)
        {
            UM_PurchaseResult result = new UM_PurchaseResult();
            result.Amazon_PurchaseInfo = response;
            result.product             = p;
            result.isSuccess           = response.isSuccess;

            SendPurchaseFinishedEvent(result);
        }
        else
        {
            SendNoTemplateEvent();
        }
    }
        private void OnTransactionComplete(UM_PurchaseResult result)
        {
            if (!result.product.id.Equals(ProductID))
            {
                return;
            }

            UM_InAppPurchaseManager.OnPurchaseFlowFinishedAction -= OnTransactionComplete;

            if (result.isSuccess)
            {
                Fsm.Event(purchasedEvent);
            }
            else
            {
                Fsm.Event(failEvent);
            }

            Finish();
        }
    public void RestorePurchases()
    {
        foreach (UM_InAppProduct product in UM_InAppPurchaseManager.InAppProducts)
        {
            if (product.IsPurchased)
            {
                UM_PurchaseResult r = new UM_PurchaseResult();
                r.isSuccess = true;
                r.product   = _CurrentProduct;

                SendPurchaseFinishedEvent(r);
            }
        }

        SA.Common.Util.General.Invoke(UnityEngine.Random.Range(0.5f, 3f), () => {
            UM_BaseResult result = new UM_BaseResult();
            result.IsSucceeded   = true;

            SendRestoreFinishedEvent(result);
        });
    }
    //--------------------------------------
    // Private Methods
    //--------------------------------------

    private void SendPurchaseEvent(UM_PurchaseResult result)
    {
        switch (Application.platform)
        {
        case RuntimePlatform.OSXEditor:
        case RuntimePlatform.WindowsEditor:
        case RuntimePlatform.Android:
            break;

        case RuntimePlatform.IPhonePlayer:

            switch (result.IOS_PurchaseInfo.State)
            {
            case InAppPurchaseState.Purchased:
            case InAppPurchaseState.Restored:
                result.isSuccess = true;
                break;

            case InAppPurchaseState.Deferred:
            case InAppPurchaseState.Failed:
                result.isSuccess = false;
                break;
            }
            break;

        case RuntimePlatform.WP8Player:
            result.isSuccess = result.WP8_PurchaseInfo.IsSuccses;
            break;
        }


        if (!result.product.IsConsumable && result.isSuccess)
        {
            Debug.Log("UM: Purchase saved to PlayerPrefs");
            SaveNonConsumableItemPurchaseInfo(result.product);
        }

        OnPurchaseFlowFinishedAction(result);
        dispatch(ON_PURCHASE_FLOW_FINISHED, result);
    }
	private void OnPurchaseFlowFinishedAction (UM_PurchaseResult result) {
		UM_InAppPurchaseManager.OnPurchaseFlowFinishedAction -= OnPurchaseFlowFinishedAction;
		if(result.isSuccess) {
			Debug.Log("Product " + result.product.id + " purchase Success");
		} else  {
				Debug.Log("Product " + result.product.id + " purchase Failed");
		}
	}
Exemple #26
0
 protected void SendPurchaseFinishedEvent(UM_PurchaseResult e)
 {
     OnPurchaseFinished(e);
 }
 private void OnPurchaseFlowFinishedAction(UM_PurchaseResult result)
 {
     UM_InAppPurchaseManager.OnPurchaseFlowFinishedAction -= OnPurchaseFlowFinishedAction;
     if(result.isSuccess) {
         UM_ExampleStatusBar.text = "Product " + result.product.id + " purchase Success";
     } else  {
         UM_ExampleStatusBar.text = "Product " + result.product.id + " purchase Failed";
     }
 }