Ejemplo n.º 1
0
        public static void RestorePurchases()
        {
            CheckIfInitialised();

            if (registeredProducts == null)
            {
                Console.LogError(Constants.kDebugTag, "[EditorStore] Restore purchases can be done only after getting products information from store.");
                return;
            }

            List <BillingTransaction> _restoredTransactions = new List <BillingTransaction>();

            foreach (BillingProduct _curProduct in registeredProducts)
            {
                if (IsProductPurchased(_curProduct.ProductIdentifier))
                {
                    BillingTransaction _transaction = CreateTransactionObject(_curProduct.ProductIdentifier, eBillingTransactionState.RESTORED, null);

                    // Add it to list of restored transactions
                    _restoredTransactions.Add(_transaction);
                }
            }

            PostTransactionEvent(kRestoreFinishedEventName, _restoredTransactions.ToArray());
        }
Ejemplo n.º 2
0
        public static void RestoreCompletedTransactions()
        {
            CheckIfInitialised();

            if (registeredProducts == null)
            {
                Console.LogError(Constants.kDebugTag, "[EditorStore] Restore purchases can be done only after getting products information from store.");
                return;
            }

            List <BillingTransaction> _restoredTransactions = new List <BillingTransaction>();

            foreach (BillingProduct _curProduct in registeredProducts)
            {
                if (IsProductPurchased(_curProduct.ProductIdentifier))
                {
                    BillingTransaction _transaction = GetTransactionDetails(_curProduct.ProductIdentifier, eBillingTransactionState.RESTORED, null);

                    // Add it to list of restored transactions
                    _restoredTransactions.Add(_transaction);
                }
            }

            // Send callback
            SendFinishedTransactionCallback(_restoredTransactions.ToArray());
        }
Ejemplo n.º 3
0
        public static void BuyProduct(string _productID)
        {
            CheckIfInitialised();

            BillingProduct _buyProduct = GetProduct(_productID);

            if (_buyProduct == null)
            {
                OnTransactionFailed(_productID, "The operation could not be completed because given product id information not found.");
                return;
            }

            if (NPBinding.UI != null)
            {
                string _message = string.Format("Do you want to buy {0} for {1}?", _buyProduct.Name, _buyProduct.LocalizedPrice);

                NPBinding.UI.ShowAlertDialogWithMultipleButtons("Confirm your purchase", _message, new string[] { "Cancel", "Buy" },
                                                                (string _buttonPressed) => {
                    if (_buttonPressed.Equals("Buy"))
                    {
                        OnConfirmingPurchase(_buyProduct);
                    }
                    else
                    {
                        OnTransactionFailed(_productID, "The operation could not be completed because user cancelled purchase.");
                    }
                });
            }
            else
            {
                Console.LogWarning(Constants.kDebugTag, "[EditorStore] Native UI component is null");
                return;
            }
        }
Ejemplo n.º 4
0
        private static void CheckIfInitialised()
        {
#if UNITY_ANDROID
            if (string.IsNullOrEmpty(NPSettings.Billing.Android.PublicKey))
            {
                Console.LogError(Constants.kDebugTag, "[EditorStore] Please add public key in NPSettings for Billing to work on Android.");
            }
#endif
        }
Ejemplo n.º 5
0
 public static void CustomVerificationFinished(BillingTransaction _transaction)
 {
     Console.LogError(Constants.kDebugTag, Constants.kFeatureNotSupported);
 }