public void TestUpdatePlan()
        {
            StripeSDKMain           stripe = new StripeSDKMain();
            StripePlanUpdateOptions stripePlanUpdateOptions = new StripePlanUpdateOptions()
            {
                Name = "Full"
            };

            Serializer serializer = new Serializer();

            var stripePlanUpdateOptionsJSON = serializer.Serialize <StripePlanUpdateOptions>(stripePlanUpdateOptions);

            string Response  = "";
            string Errors    = "";
            int    ErrorCode = 0;

            var Api_Key = GetApiKey();

            string planId = GetPlanId();

            stripe.UpdatePlan(Api_Key, planId, stripePlanUpdateOptionsJSON, ref Response, ref Errors, ref ErrorCode);

            if (ErrorCode == 0)
            {
                Console.WriteLine(Response);
            }
            else
            {
                Console.WriteLine(Errors);
            }
        }
Exemplo n.º 2
0
        public StripePlanServiceTest()
        {
            this.service = new StripePlanService();

            this.createOptions = new StripePlanCreateOptions()
            {
                Amount   = 123,
                Currency = "usd",
                Interval = "month",
                Nickname = "Plan Nickmame",
                Product  = new StripePlanProductCreateOptions
                {
                    Name = "Product Name",
                },
            };

            this.updateOptions = new StripePlanUpdateOptions()
            {
                Metadata = new Dictionary <string, string>()
                {
                    { "key", "value" },
                },
            };

            this.listOptions = new StripePlanListOptions()
            {
                Limit = 1,
            };
        }
Exemplo n.º 3
0
        public plans_fixture()
        {
            PlanCreateOptions = new StripePlanCreateOptions()
            {
                // Add a space at the end to ensure the ID is properly URL encoded
                // when passed in the URL for other methods
                Id       = "test-plan-" + Guid.NewGuid().ToString() + " ",
                Name     = "plan-name",
                Amount   = 5000,
                Currency = "usd",
                Interval = "month",
            };

            PlanUpdateOptions = new StripePlanUpdateOptions {
                Name = "plan-name-2"
            };

            var service = new StripePlanService(Cache.ApiKey);

            Plan          = service.Create(PlanCreateOptions);
            PlanRetrieved = service.Get(Plan.Id);
            PlanUpdated   = service.Update(Plan.Id, PlanUpdateOptions);
            PlansList     = service.List();
            PlanDeleted   = service.Delete(Plan.Id);
        }
        public void UpdateSubscription(string id, string planName)
        {
            var updatedPlan = new StripePlanUpdateOptions();

            updatedPlan.Name = planName;

            var        planService = new StripePlanService();
            StripePlan response    = planService.Update(id, updatedPlan);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Updates the given plan
        /// NOTE: Due to limitatons with Stripe, this can only update the name of the plan
        /// </summary>
        /// <param name="plan"></param>
        public static void UpdatePlan(IStripeSubscriptionPlan plan)
        {
            StripePlanUpdateOptions options = new StripePlanUpdateOptions();

            options.Name = plan.Title;

            StripePlanService planService = new StripePlanService();

            planService.Update(plan.PaymentSystemId, options);

            System.Diagnostics.Trace.TraceInformation("Updated plan in stripe: '{0}' with id '{1}'", plan.Title, plan.PaymentSystemId);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Updates the given plan
        /// NOTE: Due to limitatons with Stripe, this can only update the name of the plan
        /// </summary>
        /// <param name="plan"></param>
        public static StripePlan UpdatePlan(IPlanEntity plan)
        {
            StripePlanUpdateOptions options = new StripePlanUpdateOptions();

            options.Name = plan.Title;

            StripePlanService planService = new StripePlanService();
            StripePlan        updatedPlan = planService.Update(plan.PaymentSystemId, options);

            Logger.Log <StripeManager>("Updated plan in stripe: '{0}' with id '{1}'", LogLevel.Information, plan.Title, plan.PaymentSystemId);

            return(updatedPlan);
        }
Exemplo n.º 7
0
        public ActionResult Edit(PlanEditViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var planService = new StripePlanService();
            var options     = new StripePlanUpdateOptions
            {
                Name = model.Name,
                StatementDescriptor = model.StatementDescriptor
            };

            planService.Update(model.Id, options);

            return(RedirectToAction("Details", new { id = model.Id }));
        }
        public void UpdatePlan(string Api_Key, string planId, string stripePlanUpdateOptionsJSON, ref string Response, ref string Errors, ref int ErrorCode)
        {
            try
            {
                StripeConfiguration.SetApiKey(Api_Key);

                Serializer serializer = new Serializer();
                StripePlanUpdateOptions stripePlanUpdateOptions = serializer.Deserialize <StripePlanUpdateOptions>(stripePlanUpdateOptionsJSON);


                var        stripePlanService = new StripePlanService();
                StripePlan stripePlan        = stripePlanService.Update(planId, stripePlanUpdateOptions);
                Response  = stripePlan.StripeResponse.ResponseJson;
                ErrorCode = 0;
            }
            catch (StripeException e)
            {
                ErrorCode = 1;
                Serializer  serializer  = new Serializer();
                StripeError stripeError = e.StripeError;
                Errors = serializer.Serialize <StripeError>(stripeError);
            }
        }