public void CanWeSubscribe()
        {
            Account acc = zth.MakeTestAccount();
            Contact con = zth.MakeTestContact();
            PaymentMethod pay = zth.MakeTestPaymentMethod();

            String productRatePlanId = zth.CreateRatePlanToSubscribe();
            PreviewOptions po = new PreviewOptions();
            SubscribeOptions so = new SubscribeOptions();
            ProductRatePlanHolder prph = new ProductRatePlanHolder();

            ProductRatePlan prp = new ProductRatePlan();
            prp.Id = productRatePlanId;

            prph.ProductRatePlan = prp;

            ResponseHolder queryRes = zs.Query("SELECT id, ChargeModel FROM ProductRatePlanCharge WHERE productrateplanid = '" + productRatePlanId + "'");
            ProductRatePlanCharge prpc = (ProductRatePlanCharge)queryRes.Objects[0];
            prpc.DefaultQuantity = 11;

            ProductRatePlanChargeHolder prpch = new ProductRatePlanChargeHolder();
            prpch.ProductRatePlanCharge = prpc;

            prph.ProductRatePlanCharges = new List<ProductRatePlanChargeHolder> { prpch };

            SubscribeResponseHolder subResp = sm.Subscribe(acc, con, pay, new List<ProductRatePlanHolder> { prph }, zth.MakeTestSubscription(), po, so);
            Assert.True(subResp.Success);
        }
Ejemplo n.º 2
0
        public ProductRatePlan MakeTestProductRatePlan(String pid)
        {
            ProductRatePlan prp = new ProductRatePlan();
            prp.Name = "ApiTestRatePlan";
            prp.ProductId = pid;
            prp.EffectiveStartDateSpecified = true;
            prp.EffectiveStartDate = new DateTime(2000, 1, 1);
            prp.EffectiveEndDateSpecified = true;
            prp.EffectiveEndDate = new DateTime(2050, 1, 1);

            return prp;
        }
Ejemplo n.º 3
0
        // BUGBUG: deal with expiration later
        public ProductRatePlan[] queryRatePlansByProduct(String productId)
        {
            QueryResult result = binding.query("select Id, Name FROM ProductRatePlan where ProductId = '" + productId + "'");
            zObject[] recs = (zObject[])result.records;
            ProductRatePlan[] res = null;
            if (result.size > 0 && recs != null && recs.Length > 0)
            {
                res = new ProductRatePlan[recs.Length];
                for (int i = 0; i < recs.Length; i++)
                {
                    res[i] = (ProductRatePlan)recs[i];
                }

            }
            return res;
        }
        public ProductRatePlanHolder CreateRatePlanWithOneTimeCharge(Product product, string ratePlanName, decimal price)
        {
            var existingRatePlan = GetProductRatePlanByName(product.Id, ratePlanName);
            if (existingRatePlan != null)
            {
                throw ZuoraException.ProductPlanAlreadyExists(product, ratePlanName);
            }
            var prp = new ProductRatePlan()
                          {
                              ProductId = product.Id,
                              Name = ratePlanName,
                              EffectiveStartDate = DateTime.Now
                          };
            var r = zs.Create(prp);
            if (!r.Success)
            {
                throw ZuoraException.RatePlanCreationError(product, ratePlanName).WithZuoraError(r);
            }
            var prpId = r.Id;

            var prpc = new ProductRatePlanCharge()
                           {
                               ProductRatePlanId = prpId,
                               ChargeModel = Constants.PRODUCT_RATE_PLAN_CHARGE_MODEL_FLAT_FEE,
                               ChargeType = Constants.PRODUCT_RATE_PLAN_CHARGE_TYPE_ONE_TIME,
                               Name = Constants.PRODUCT_RATE_PLAN_CHARGE_DEFAULT_NAME,
                               TriggerEvent = Constants.PRODUCT_RATE_PLAN_CHARGE_TRIGGER_EVENT_CONTRACT_EFFECTIVE,
                               ProductRatePlanChargeTierData = new ProductRatePlanChargeTier[]
            {
                                                                       new ProductRatePlanChargeTier()
                {
                                                                               Active = true,
                                                                               Currency = Constants.CURRENCY_USD,
                                                                               Price = price,
                                                                               PriceSpecified = true, // BUGBUGBUG (maxm): shouldn't need to be included
                                                                           }
                                                                   }
                           };

            r = zs.Create(prpc);
            if (!r.Success)
                    {
                DeleteRatePlan(prpId);
                throw ZuoraException.RatePlanCreationError(product, ratePlanName).WithZuoraError(r);
                    }
            var prpcId = r.Id;
            ClearCache();
            return GetRatePlan(prpId);
        }
        public ResponseHolder DisableRatePlan(String productRatePlanId, DateTime date)
        {
            ProductRatePlan prp = new ProductRatePlan();
            prp.Id = productRatePlanId;
            prp.EffectiveEndDateSpecified = true;
            prp.EffectiveEndDate = date;

            return zs.Update(new List<zObject> { prp })[0];
        }
        public void CanWeSubscribeWithoutChargeInfo()
        {
            Account acc = zth.MakeTestAccount();
            Contact con = zth.MakeTestContact();
            PaymentMethod pay = zth.MakeTestPaymentMethod();

            String productRatePlanId = zth.CreateRatePlanToSubscribe();
            PreviewOptions po = new PreviewOptions();
            SubscribeOptions so = new SubscribeOptions();
            ProductRatePlanHolder prph = new ProductRatePlanHolder();

            ProductRatePlan prp = new ProductRatePlan();
            prp.Id = productRatePlanId;

            prph.ProductRatePlan = prp;

            SubscribeResponseHolder subResp = sm.Subscribe(acc, con, pay, new List<ProductRatePlanHolder> { prph }, zth.MakeTestSubscription(), po, so);
            Assert.True(subResp.Success);
        }
        public void CanWeSubscribeToMultipleRatePlansWithExistingAccount()
        {
            String accId = zth.MakeSubscription(true).SubRes.AccountId;
            String productRatePlanId = zth.CreateRatePlanToSubscribe();
            PreviewOptions po = new PreviewOptions();
            SubscribeOptions so = new SubscribeOptions();

            ProductRatePlanHolder prph = new ProductRatePlanHolder();

            ProductRatePlan prp = new ProductRatePlan();
            prp.Id = productRatePlanId;

            prph.ProductRatePlan = prp;

            ResponseHolder queryRes = zs.Query("SELECT id, ChargeModel FROM ProductRatePlanCharge WHERE productrateplanid = '" + productRatePlanId + "'");
            ProductRatePlanCharge prpc = (ProductRatePlanCharge)queryRes.Objects[0];
            prpc.DefaultQuantity = 11;

            ProductRatePlanChargeHolder prpch = new ProductRatePlanChargeHolder();
            prpch.ProductRatePlanCharge = prpc;

            prph.ProductRatePlanCharges = new List<ProductRatePlanChargeHolder> { prpch };

            SubscribeResponseHolder subResp = sm.SubscribeWithExisitingAccount(accId, new List<ProductRatePlanHolder> { prph, prph }, zth.MakeTestSubscription(), po, so);
            Assert.True(subResp.Success);
        }