public List <StorePurchase> GetPurchases(PurchasesInformation pInfo)
        {
            int failedTrns = 0;
            List <StorePurchase> purchases = new List <StorePurchase>();
            Exception            lastExcp  = null;

            foreach (var p in pInfo.Purchases)
            {
                try
                {
                    StorePurchase sP = GetPurchase(p.ProductIdentifier, p);
                    purchases.Add(sP);
                }
                catch (Exception e)
                {
                    failedTrns++;
                    lastExcp = e;
                }
            }
            if (lastExcp != null && failedTrns == pInfo.Purchases.Count)
            {
                throw lastExcp;
            }
            return(purchases);
        }
        public List <StorePurchase> GetPurchases(PurchasesInformation pInfo)
        {
            List <StorePurchase> list = new List <StorePurchase>();

            foreach (PurchaseResult p in pInfo.Purchases)
            {
                p.TransactionData = pInfo.AppleReceipt;
                try {
                    StorePurchase sp = this.GetPurchase(p.ProductIdentifier, p);
                    if (!list.Contains(sp))
                    {
                        list.Add(sp);
                    }
                }
                catch
                {
                }
            }
            list.RemoveAll(sp => sp.ProductType == (int)ProductType.Subscription && sp.PurchaseStatus != PurchaseStatus.Valid);
            return(list);
        }
Пример #3
0
        public String GetPurchases(GxUserType gxStoreConfig, GxUserType purchasesInformation)
        {
            GxSimpleCollection <GxUserType> gxStorePurchases = new GxSimpleCollection <GxUserType>();

            PurchasesInformation pInformation = JSONHelper.Deserialize <PurchasesInformation>(purchasesInformation.ToJSonString());;

            IStoreManager storeMgr;

            ErrCode = GetManager(gxStoreConfig, pInformation.PurchasePlatform, out storeMgr);
            if (storeMgr != null)
            {
                Type type = Type.GetType("GeneXus.Core.genexus.sd.store.SdtStorePurchase, GeneXus.Core.Common", true);
                List <StorePurchase> purchases = storeMgr.GetPurchases(pInformation);
                foreach (StorePurchase p in purchases)
                {
                    GxUserType storePurchase = (GxUserType)Activator.CreateInstance(type);
                    storePurchase.FromJSonString(p.ToJson());
                    gxStorePurchases.Add(storePurchase);
                }
            }
            return(gxStorePurchases.ToJSonString(false));
        }