Beispiel #1
0
 private void ReadFromStorage(IAPProductsStorage storage)
 {
     for (int i = 0; i < storage.IAPProducts.Count; i++)
     {
         var iapProductData = storage.IAPProducts[i];
         var iapProduct     = IAPProduct.CreateIapProductByData(iapProductData);
         AddProduct(iapProduct);
     }
 }
Beispiel #2
0
        public void RemoveProduct(IAPProduct product)
        {
            if (product == null)
            {
                return;
            }

            iapProducts.Remove(product.ProductKey);
        }
Beispiel #3
0
        public void BuyProduct(IAPProduct iapProduct)
        {
            var product = storeController.products.WithID(iapProduct.ProductKey);

            if (product != null && product.availableToPurchase)
            {
                storeController.InitiatePurchase(product);
            }
        }
Beispiel #4
0
        public void AddProduct(IAPProduct product)
        {
            if (product == null)
            {
                return;
            }

            if (!iapProducts.ContainsKey(product.ProductKey))
            {
                iapProducts.Add(product.ProductKey, product);
            }
        }
        public static IAPProduct CreateIapProductByData(IAPProductData data)
        {
            var iapProduct = new IAPProduct()
            {
                ProductKey    = data.productKey,
                StoreKey      = data.storeKey,
                Price         = data.price,
                ProductType   = data.productType,
                GPProductKey  = data.gpProductKey,
                IOSProductKey = data.iosProductKey
            };

            iapProduct.Init();
            return(iapProduct);
        }
Beispiel #6
0
 public void OnPurchaseError(IAPProduct product)
 {
     EventManager.Call <IIAPHandler>(x => x.ResultTransaction(product, TransactionResult.ERROR));
 }
Beispiel #7
0
 public void OnPurchaseCanceled(IAPProduct product)
 {
     EventManager.Call <IIAPHandler>(x => x.ResultTransaction(product, TransactionResult.CANCEL));
 }
Beispiel #8
0
 public void OnPurchasePending(IAPProduct product)
 {
     EventManager.Call <IIAPHandler>(x => x.ResultTransaction(product, TransactionResult.PENDING));
 }
Beispiel #9
0
 public void OnPurchaseAuthorized(IAPProduct product)
 {
     EventManager.Call <IIAPHandler>(x => x.ResultTransaction(product, TransactionResult.AUTHORIZED));
 }
Beispiel #10
0
 public void BuyProduct(IAPProduct product)
 {
     Store.BuyProduct(product);
     EventManager.Call <IIAPHandler>(x => x.SendTransaction(product));
 }
Beispiel #11
0
 public void ConfirmPurchase(IAPProduct product)
 {
     storeController.ConfirmPendingPurchase(product.Product);
 }