Exemple #1
0
        public async Task <BuyIntentApiRequest> InsertIntent(string productId)
        {
            BuyIntentApiRequest intent = new BuyIntentApiRequest()
            {
                StoreKey = productId
            };

            await PurchaseApiService.InsertBuyIntent(intent);

            return(intent);
        }
Exemple #2
0
        public async void TryBuy(AvailableTrapApiResult availableTrap)
        {
            progressDialog = ProgressDialog.Show(Activity, Resources.GetString(MyTrap.Droid.Resource.String.loading), Resources.GetString(MyTrap.Droid.Resource.String.registering_purchase));

            try
            {
                BuyIntentApiRequest intent = new BuyIntentApiRequest()
                {
                    AvailableTrapId = availableTrap.Id, StoreKey = availableTrap.KeyGoogle
                };

                await PurchaseApiService.InsertBuyIntent(intent);

                pendingBuyIntent = intent;

                Product product = null;

                foreach (var itemGoogle in products)
                {
                    if (itemGoogle.ProductId == availableTrap.KeyGoogle)
                    {
                        product = itemGoogle;
                        break;
                    }
                }

                if (product != null)
                {
                    //product.ProductId = "android.test.purchased";
                    //product.ProductId = "android.test.canceled";
                    //product.ProductId = "android.test.refunded";

                    //await RegisterPurchase(intent);

                    _serviceConnection.BillingHandler.BuyProduct(product);
                }
            }
            catch (Exception exception)
            {
                InsightsUtils.LogException(exception);
            }

            progressDialog.Cancel();
        }