Beispiel #1
0
 public void OnInitializeFailed(InitializationFailureReason error)
 {
     // Purchasing set-up has not succeeded. Check error for reason. Consider sharing this reason with the user.
     if (m_enableDebug)
     {
         GDebug.LogError("OnInitializeFailed InitializationFailureReason:" + error);
     }
 }
Beispiel #2
0
        public void OnPurchaseFailed(Product product, PurchaseFailureReason failureReason)
        {
            GStateManager.Instance.EnableLoadingSpinner(false);
            IsPurchasing = false;
            // A product purchase attempt did not succeed. Check failureReason for more detail. Consider sharing
            // this reason with the user to guide their troubleshooting actions.
            if (m_enableDebug)
            {
                GDebug.LogError(string.Format("OnPurchaseFailed: FAIL. Product: '{0}', PurchaseFailureReason: {1}", product.definition.storeSpecificId, failureReason));
            }

            if (m_failureCallback != null)
            {
                m_failureCallback.Invoke(-1, -1, "{'reason':'" + failureReason.ToString() + "' }", product);
            }
        }
Beispiel #3
0
        public static char ValidateInput(string text, int charIndex, char addedChar)
        {
            try
            {
                string toString = "";
                toString += addedChar;

                string[] parts = Regex.Split(toString, @"[^a-zA-Z \d]");    //Accepts only A-Z a-z 0-9 and spaces
                if (parts.Length > 0 && parts[0].Length > 0)
                {
                    return(parts[0][0]);
                }
                else
                {
                    return('\0');
                }
            }
            catch (System.Exception ex)
            {
                GDebug.LogError(ex.ToString());
                return('\0');
            }
        }
Beispiel #4
0
        private void handlePurchase(string storeProductId, SuccessCallback in_success = null, FailureCallback in_failure = null)
        {
#if BUY_CURRENCY_ENABLED
            // dont process while purchasing
            if (IsPurchasing)
            {
                return;
            }

            m_successCallback = in_success;
            m_failureCallback = in_failure;

            // If Purchasing has been initialized ...
            if (IsInitialized())
            {
#if !STEAMWORKS_ENABLED
                // ... look up the Product reference with the general product identifier and the Purchasing
                // system's products collection.

                Product product = m_StoreController.products.WithID(storeProductId);

                // If the look up found a product for this device's store and that product is ready to be sold ...
                if (product != null && product.availableToPurchase)
                {
                    if (m_enableDebug)
                    {
                        GDebug.Log(string.Format("Purchasing product asychronously: '{0}'", product.definition.id));
                    }

                    // ... buy the product. Expect a response either through ProcessPurchase or OnPurchaseFailed
                    // asynchronously.
                    GStateManager.Instance.EnableLoadingSpinner(true);
                    IsPurchasing = true;
                    m_StoreController.InitiatePurchase(product);
                }
                // Otherwise ...
                else
                {
                    // ... report the product look-up failure situation
                    if (m_enableDebug)
                    {
                        GDebug.LogError("BuyProductIDBuyProductID: FAIL. Not purchasing product, either it's not found or it's not available for purchase.");
                    }

                    if (m_failureCallback != null)
                    {
                        m_failureCallback.Invoke(-1, -1, "{'reason':'BuyProductID: FAIL. Not purchasing product, either it's not found or it's not available for purchase.'}", null);
                    }
                }
#else
                // simulate a successful initiate purchase
                handleProcessPurchase(storeProductId, "");
#endif
            }
            // Otherwise ...
            else
            {
                // ... report the fact Purchasing has not succeeded initializing yet. Consider waiting longer or
                // retrying initiailization.
                if (m_enableDebug)
                {
                    GDebug.LogError("BuyProductID FAIL. Not initialized.");
                }

                if (m_failureCallback != null)
                {
                    m_failureCallback.Invoke(-1, -1, "{'reason':'BuyProductID FAIL. Not initialized.'}", null);
                }
            }
#endif
        }
Beispiel #5
0
        private void handleProcessPurchase(string in_storeId, string in_receipt = null)
        {
            GStateManager.Instance.EnableLoadingSpinner(false);
            IsPurchasing = false;

            IAPProduct product = GetIAPProductByStoreId(in_storeId);

            if (product != null)
            {
                if (m_enableDebug)
                {
                    GDebug.Log(string.Format("PurchaseProcessingResult with id: {0}", product.StoreProductId));
                }

                //TODO: ADD MORE PLATFORMS[SMRJ]
#if UNITY_IOS
                Dictionary <string, object> jsonMessage = (Dictionary <string, object>)JsonReader.Deserialize(in_receipt);// args.purchasedProduct.receipt);
                // itunes
                Dictionary <string, object> receipt = new Dictionary <string, object>();
                receipt["receipt"] = (string)jsonMessage["Payload"];
                GCore.Wrapper.Client.AppStoreService.VerifyPurchase("itunes", JsonWriter.Serialize(receipt), m_successCallback, m_failureCallback);
#elif UNITY_ANDROID
                Dictionary <string, object> jsonMessage = (Dictionary <string, object>)JsonReader.Deserialize(in_receipt);// args.purchasedProduct.receipt);
                // ANDROID
                Dictionary <string, object> payload = (Dictionary <string, object>)JsonReader.Deserialize((string)jsonMessage["Payload"]);
                Dictionary <string, object> json    = (Dictionary <string, object>)JsonReader.Deserialize((string)payload["json"]);

                Dictionary <string, object> receipt = new Dictionary <string, object>();
                receipt["productId"] = json["productId"];
                receipt["orderId"]   = json["orderId"];
                receipt["token"]     = json["purchaseToken"];
                //receipt["developerPayload"] = json["developerPayload"];

                GCore.Wrapper.Client.AppStoreService.VerifyPurchase("googlePlay", JsonWriter.Serialize(receipt), m_successCallback, m_failureCallback);
#elif UNITY_WEBGL
                // TODO: need to confirm integration
                Dictionary <string, object> jsonMessage = (Dictionary <string, object>)JsonReader.Deserialize(in_receipt);//args.purchasedProduct.receipt);
                Dictionary <string, object> receipt     = new Dictionary <string, object>();
                receipt["signedRequest"] = (string)jsonMessage["Payload"];
                GCore.Wrapper.Client.AppStoreService.VerifyPurchase("facebook", JsonWriter.Serialize(receipt), m_successCallback, m_failureCallback);
#elif STEAMWORKS_ENABLED
                // STEAM
                Dictionary <string, object> purchaseData = new Dictionary <string, object>();
                purchaseData[BrainCloudConsts.JSON_LANGUAGE] = "en"; // TODO get proper language
                purchaseData[BrainCloudConsts.JSON_ITEM_ID]  = product.StoreProductId;

                // steam is a two step process, where you start a purchase, and then finalize it, but we keep these callbacks for later,
                // after processing the start purhcase succesfully
                GCore.Wrapper.Client.AppStoreService.StartPurchase("steam", JsonWriter.Serialize(purchaseData), onSteamStartPurchaseSuccess, m_failureCallback);
#endif
            }
            else
            {
                if (m_enableDebug)
                {
                    GDebug.LogError(string.Format("ProcessPurchase: FAIL. Unrecognized product: '{0}'", in_storeId));
                }

                if (m_failureCallback != null)
                {
                    m_failureCallback.Invoke(-1, -1, "{'reason':'ProcessPurchase: FAIL. Unrecognized product' }", null);
                }
            }
        }