Esempio n. 1
0
        /// <summary>
        /// Purchase a specific product or subscription
        /// </summary>
        /// <param name="productId">Sku or ID of product</param>
        /// <param name="itemType">Type of product being requested</param>
        /// <param name="payload">Developer specific payload</param>
        /// <param name="verifyPurchase">Verify purchase implementation</param>
        /// <returns></returns>
        /// <exception cref="InAppBillingPurchaseException">If an error occurs during processing</exception>
        public override async Task <InAppBillingPurchase> PurchaseAsync(string productId, ItemType itemType, string payload, IInAppBillingVerifyPurchase verifyPurchase = null)
        {
            //var licinfo = CurrentApp.LicenseInformation;
            // Get purchase result from store or simulator
            var purchaseResult = await CurrentAppMock.RequestProductPurchaseAsync(InTestingMode, productId);

            var recStr = await CurrentAppMock.GetProductReceiptAsync(InTestingMode, productId);



            //await GetPurchasesAsync(ItemType.InAppPurchase, null, null);
            if (purchaseResult == null)
            {
                return(null);
            }
            if (string.IsNullOrWhiteSpace(purchaseResult.ReceiptXml))
            {
                return(null);
            }

            // Transform it to InAppBillingPurchase
            InAppBillingPurchase purchase = purchaseResult.ReceiptXml.ToInAppBillingPurchase(purchaseResult.Status).FirstOrDefault();

            if (verifyPurchase == null)
            {
                return(purchase);
            }

            var validated = await verifyPurchase.VerifyPurchase(purchaseResult.ReceiptXml, string.Empty, purchase.ProductId, purchase.Id);

            return(validated ? purchase : null);
        }
Esempio n. 2
0
        protected override async Task <IEnumerable <InAppBillingPurchase> > GetPurchasesAsync(ItemType itemType, IInAppBillingVerifyPurchase verifyPurchase, string verifyOnlyProductId)
        {
            await CurrentAppMock.GetProductReceiptAsync(InTestingMode, "vsg1_sd");

            // Get list of product receipts from store or simulator
            var xmlReceipt = await CurrentAppMock.GetAppReceiptAsync(InTestingMode);

            // Transform it to list of InAppBillingPurchase
            return(xmlReceipt.ToInAppBillingPurchase(ProductPurchaseStatus.AlreadyPurchased));
        }