예제 #1
0
        //--------------------------------------
        //  UM_AbstractInAppClient
        //--------------------------------------

        protected override void ConnectToService(Action <SA_Result> callback)
        {
            ISN_SKPaymentQueue.Init(result =>
            {
                callback.Invoke(result);
            });
        }
예제 #2
0
    public void init()
    {
        // just make sure we init only once
        if (!IsInitialized)
        {
            ISN_SKPaymentQueue.RegisterProductId(ITEM1);
            ISN_SKPaymentQueue.RegisterProductId(ITEM2);
            ISN_SKPaymentQueue.RegisterProductId(ITEM3);
            ISN_SKPaymentQueue.RegisterProductId(ITEM4);
            ISN_SKPaymentQueue.RegisterProductId(ITEM5);
            ISN_SKPaymentQueue.RegisterProductId(PAGE_1);
            ISN_SKPaymentQueue.RegisterProductId(PAGE_2);
            ISN_SKPaymentQueue.RegisterProductId(PAGE_3);
            ISN_SKPaymentQueue.RegisterProductId(PAGE_4);


            IsInitialized = true;


            ISN_SKPaymentQueue.Init(result => {
                Debug.Log("result.Products.Count " + result.Products.Count);
                Debug.Log("result.InvalidProductIdentifiers.Count " + result.InvalidProductIdentifiers.Count);
            });

            //Since current class is implement's ISN_iSKPaymentTransactionObserver
            //we can add it as the transaction observer
            ISN_SKPaymentQueue.AddTransactionObserver(this);
        }
    }
예제 #3
0
        //--------------------------------------
        //  Private Methods
        //--------------------------------------

        private static void UnlockProducts(ISN_iSKPaymentTransaction transaction)
        {
            //At this point user already paid for content, so we need to provide it
            //Unless, we want to make sure that payment was legit, and nobody trying to hack us
            //In order to do it, we have to use server side verification, you can read more about it here:
            //https://developer.apple.com/library/content/releasenotes/General/ValidateAppStoreReceipt/Chapters/ValidateRemotely.html#//apple_ref/doc/uid/TP40010573-CH104-SW1
            //
            //this step isn't required. Use it only if you want to make sure that payment is 100% legit
            //So far let's just print a Base64 receipt data

            //  Debug.Log("Receipt: " + ISN_SKPaymentQueue.AppStoreReceipt.AsBase64StringString);

            switch (transaction.ProductIdentifier)
            {
            case SMALL_PACK:
                //code for adding small game money amount here
                break;

            case NC_PACK:
                //code for unlocking cool item here
                break;
            }

            //After connect was provided to use we can finally finish the transaction
            ISN_SKPaymentQueue.FinishTransaction(transaction);
        }
예제 #4
0
        public void FinishTransaction(UM_iTransaction transaction)
        {
            var t = (UM_IOSTransaction)transaction;

            var skPaymentTransaction = t.IosTransaction;

            ISN_SKPaymentQueue.FinishTransaction(skPaymentTransaction);
        }
예제 #5
0
        public void AddPayment(string productIdentifier)
        {
            SA_Coroutine.WaitForSeconds(DelayTime, () => {
                var produdct     = ISN_SKPaymentQueue.GetProductById(productIdentifier);
                var tranasaction = new ISN_SKPaymentTransaction(produdct, ISN_SKPaymentTransactionState.Purchased);

                m_transactionUpdated.Invoke(tranasaction);
            });
        }
예제 #6
0
    public void Purchase(string ProductId)
    {
        if (ProductId == "page_1")
        {
            ProductId = "wfw4_page_1";
        }
        if (ProductId == "page_2")
        {
            ProductId = "wfw4_page_2";
        }
        if (ProductId == "page_3")
        {
            ProductId = "wfw4_page_3";
        }
        if (ProductId == "page_4")
        {
            ProductId = "wfw4_page_4";
        }
        if (ProductId == "page_5")
        {
            ProductId = "wfw4_page_5";
        }
        if (ProductId == "page_6")
        {
            ProductId = "wfw4_page_6";
        }
        if (ProductId == "page_7")
        {
            ProductId = "wfw4_page_7";
        }


        if (ProductId == "wfw2_p1")
        {
            ProductId = "wfw4_p1";
        }
        if (ProductId == "wfw2_p2")
        {
            ProductId = "wfw4_p2";
        }
        if (ProductId == "wfw2_p3")
        {
            ProductId = "wfw4_p3";
        }
        if (ProductId == "wfw2_p4")
        {
            ProductId = "wfw4_p4";
        }
        if (ProductId == "wfw2_p5")
        {
            ProductId = "wfw4_p5";
        }

        ISN_SKPaymentQueue.AddPayment(ProductId);
    }
예제 #7
0
    public void Purchase(string ProductId)
    {
        if (ProductId == "wfw_p1")
        {
            ProductId = "wfw_1000";
        }
        if (ProductId == "wfw_p2")
        {
            ProductId = "wfw_2200";
        }
        if (ProductId == "wfw_p3")
        {
            ProductId = "wfw_3600";
        }
        if (ProductId == "wfw_p4")
        {
            ProductId = "wfw_5200";
        }
        if (ProductId == "wfw_p5")
        {
            ProductId = "wfw_7000";
        }

        if (ProductId == "page_1")
        {
            ProductId = "wfw_page1";
        }
        if (ProductId == "page_2")
        {
            ProductId = "wfw_page2";
        }
        if (ProductId == "page_3")
        {
            ProductId = "wfw_page3";
        }
        if (ProductId == "page_4")
        {
            ProductId = "wfw_page4";
        }
        if (ProductId == "page_5")
        {
            ProductId = "wfw_page5";
        }
        if (ProductId == "page_6")
        {
            ProductId = "wfw_page6";
        }
        if (ProductId == "page_7")
        {
            ProductId = "wfw_page7";
        }

        ISN_SKPaymentQueue.AddPayment(ProductId);
    }
예제 #8
0
    //--------------------------------------
    //  ISN_TransactionObserver implementation
    //--------------------------------------

    public void OnTransactionUpdated(ISN_iSKPaymentTransaction transaction)
    {
        //Transactions have been updated.
        //Let's act accordingly
        Debug.Log("transaction JSON: " + JsonUtility.ToJson(transaction));

        Debug.Log("OnTransactionComplete: " + transaction.ProductIdentifier);
        Debug.Log("OnTransactionComplete: state: " + transaction.State);

        switch (transaction.State)
        {
        case ISN_SKPaymentTransactionState.Purchasing:
            //No actions is required here, we probably don't even have a ProductIdentifier
            //but we can use this callback to show preloader for example, since we know that user is currently
            //working on this transaction
            break;

        case ISN_SKPaymentTransactionState.Purchased:
        case ISN_SKPaymentTransactionState.Restored:
            //Our product has been successfully purchased or restored
            //So we need to provide content to our user depends on productIdentifier
            UnlockProducts(transaction);

            break;

        case ISN_SKPaymentTransactionState.Deferred:
            //iOS 8 introduces Ask to Buy, which lets parents approve any purchases initiated by children
            //You should update your UI to reflect this deferred state, and expect another Transaction Complete  to be called again with a new transaction state
            //reflecting the parent’s decision or after the transaction times out. Avoid blocking your UI or gameplay while waiting for the transaction to be updated.
            break;

        case ISN_SKPaymentTransactionState.Failed:
            //Our purchase flow is failed.
            //We can unlock interface and report user that the purchase is failed.
            Debug.Log("Transaction failed with error, code: " + transaction.Error.Code);
            Debug.Log("Transaction failed with error, description: " + transaction.Error.Message);

            //at this point we just need to finish the transaction
            ISN_SKPaymentQueue.FinishTransaction(transaction);
            break;
        }

        if (transaction.State == ISN_SKPaymentTransactionState.Failed)
        {
            Debug.Log("Error code: " + transaction.Error.Code + "\n" + "Error description:" + transaction.Error.Message);
        }
        else
        {
            Debug.Log("product " + transaction.ProductIdentifier + " state: " + transaction.State);
        }
    }
        public void init()  {
            // just make sure we init only ince
            if (!IsInitialized) {
                ISN_SKPaymentQueue.RegisterProductId(SMALL_PACK);
                ISN_SKPaymentQueue.RegisterProductId(NC_PACK);

                IsInitialized = true;


				ISN_SKPaymentQueue.Init((ISN_SKInitResult result) => {
					Debug.Log("result.Products.Count " + result.Products.Count);
					Debug.Log("result.InvalidProductIdentifiers.Count " + result.InvalidProductIdentifiers.Count);

				});

                //Since current class is implement's ISN_iSKPaymentTransactionObserver
                //we can add it as the trarnsaction observer
                ISN_SKPaymentQueue.AddTransactionObserver(this);
            }
        }
예제 #10
0
    public void Purchase(string ProductId)
    {
        if (ProductId == "page_1")
                ProductId = "wfw_vip3_page_1";
            if (ProductId == "page_2")
                ProductId = "wfw_vip3_page_2";
            if (ProductId == "page_3")
                ProductId = "wfw_vip3_page_3";
            if (ProductId == "page_4")
                ProductId = "wfw_vip3_page_4";

            if (ProductId == "wfw2_p1")
                ProductId = "wfw3vip_1000";
            if (ProductId == "wfw2_p2")
                ProductId = "wfw3vip_2200";
            if (ProductId == "wfw2_p3")
                ProductId = "wfw3vip_3600";
            if (ProductId == "wfw2_p4")
                ProductId = "wfw3vip_5200";
            if (ProductId == "wfw2_p5")
                ProductId = "wfw3vip_7000";

        ISN_SKPaymentQueue.AddPayment(ProductId);
    }
예제 #11
0
    //--------------------------------------
    //  Private Methods
    //--------------------------------------

    private static void UnlockProducts(ISN_iSKPaymentTransaction transaction)
    {
        //At this point user already paid for content, so we need to provide it
        //Unless, we want to make sure that payment was legit, and nobody trying to hack us
        //In order to do it, we have to use server side verification, you can read more about it here:
        //https://developer.apple.com/library/content/releasenotes/General/ValidateAppStoreReceipt/Chapters/ValidateRemotely.html#//apple_ref/doc/uid/TP40010573-CH104-SW1
        //
        //this step isn't required. Use it only if you want to make sure that payment is 100% legit
        //So far let's just print a Base64 receipt data

        //  Debug.Log("Receipt: " + ISN_SKPaymentQueue.AppStoreReceipt.AsBase64StringString);
        string ProductId = transaction.ProductIdentifier;

        switch (ProductId)
        {
        case ITEM1:
            Main.CoinAdd(1000);
            //Consume(ProductId);
            Main.buy();
            break;

        case ITEM2:
            Main.CoinAdd(2200);
            // Consume(ProductId);
            Main.buy();
            break;

        case ITEM3:
            Main.CoinAdd(3600);
            // Consume(ProductId);
            Main.buy();
            break;

        case ITEM4:
            Main.CoinAdd(5200);
            // Consume(ProductId);
            Main.buy();
            break;

        case ITEM5:
            Main.CoinAdd(7000);
            //Consume(ProductId);
            Main.buy();
            break;

        case PAGE_1:
            PlayerPrefs.SetInt("page_1", 1);
            Application.LoadLevelAsync(1);
            break;

        case PAGE_2:
            PlayerPrefs.SetInt("page_2", 1);
            Application.LoadLevelAsync(1);
            break;

        case PAGE_3:
            PlayerPrefs.SetInt("page_3", 1);
            Application.LoadLevelAsync(1);
            break;

        case PAGE_4:
            PlayerPrefs.SetInt("page_4", 1);
            Application.LoadLevelAsync(1);
            break;

        default:
            Debug.LogError("Unknown product Id: " + ProductId);
            break;
        }

        //After connect was provided to use we can finally finish the transaction
        ISN_SKPaymentQueue.FinishTransaction(transaction);
    }
예제 #12
0
 public void RestoreCompletedTransactions()
 {
     ISN_SKPaymentQueue.RestoreCompletedTransactions();
 }
예제 #13
0
        //--------------------------------------
        //  UM_iInAppClient
        //--------------------------------------

        public void AddPayment(string productId)
        {
            ISN_SKPaymentQueue.AddPayment(productId);
        }
예제 #14
0
 protected override void ObserveTransactions()
 {
     ISN_SKPaymentQueue.AddTransactionObserver(this);
 }
예제 #15
0
        //--------------------------------------
        //  UM_AbstractInAppClient
        //--------------------------------------

        protected override void ConnectToService(Action <SA_iResult> callback)
        {
            ISN_SKPaymentQueue.Init(callback.Invoke);
        }
        void OnGUI()
        {
            UpdateToStartPos();

            GUI.Label(new Rect(StartX, StartY, Screen.width, 40), "In-App Purchases", style);



            StartY += YLableStep;
            if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Load Store"))
            {
                s_paymentManager.init();
            }


            if (ISN_SKPaymentQueue.IsReady)
            {
                GUI.enabled = true;
            }
            else
            {
                GUI.enabled = false;
            }


            StartX  = XStartPos;
            StartY += YButtonStep;

            if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Perform Buy #1"))
            {
                var CurrencySymbol = ISN_SKPaymentQueue.GetProductById(ISN_PaymentManagerExample.SMALL_PACK).PriceLocale.CurrencySymbol;

                Debug.Log(CurrencySymbol);
                //ISN_SKPaymentQueue.AddPayment(ISN_PaymentManagerExample.SMALL_PACK);
            }

            StartX += XButtonStep;
            if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Perform Buy #2"))
            {
                ISN_SKPaymentQueue.AddPayment(ISN_PaymentManagerExample.NC_PACK);
            }

            StartX += XButtonStep;
            if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Restore Purchases"))
            {
                ISN_SKPaymentQueue.RestoreCompletedTransactions();
            }


            StartX += XButtonStep;
            if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Is Payments Enabled On device"))
            {
                Debug.Log("Is Payments Enabled: " + ISN_SKPaymentQueue.CanMakePayments);
            }


            StartX  = XStartPos;
            StartY += YButtonStep;
            StartY += YLableStep;

            GUI.enabled = true;
            GUI.Label(new Rect(StartX, StartY, Screen.width, 40), "Local Receipt Validation", style);

            StartY += YLableStep;
            if (GUI.Button(new Rect(StartX, StartY, buttonWidth + 10, buttonHeight), "Print Load Receipt"))
            {
                var receipt = ISN_SKPaymentQueue.AppStoreReceipt;

                Debug.Log("Receipt loaded, byte array length: " + receipt.Data.Length + " Would you like to veriday it with Apple Sandbox server?");
                Debug.Log("Receipt As Base64 String" + receipt.AsBase64String);
            }

            StartX += XButtonStep;
            if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Refresh Receipt"))
            {
                //Thiss is optional values for test evironment,
                //for production evironment use properties = null

                var properties = new ISN_SKReceiptDictionary();
                properties.Add(ISN_SKReceiptProperty.IsExpired, 0);
                properties.Add(ISN_SKReceiptProperty.IsRevoked, 1);

                var request = new ISN_SKReceiptRefreshRequest(properties);
                request.Start((result) => {
                    Debug.Log("Receipt Refresh Result: " + result.IsSucceeded);
                    if (result.HasError)
                    {
                        Debug.Log(result.Error.Code + " / " + result.Error.Message);
                    }
                });
            }


            StartX  = XStartPos;
            StartY += YButtonStep;
            StartY += YLableStep;

            GUI.enabled = true;
            GUI.Label(new Rect(StartX, StartY, Screen.width, 40), "Store Review Controller", style);

            StartY += YLableStep;
            if (GUI.Button(new Rect(StartX, StartY, buttonWidth + 10, buttonHeight), "Request Review"))
            {
                ISN_SKStoreReviewController.RequestReview();
            }
        }