예제 #1
0
        public string TogglePause(string togglePause)
        {   //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
            //sk_test_51Gzaa1HAh8lBnQxza9cOAzY7LbfgQ4FWX2sYqiuHsoVWJg4mNDppueQkAVd0XIPU4GhcrNBca8aemNgr24m4jDv200ooFw0Bhz
            StripeConfiguration.ApiKey = "sk_test_51Gzaa1HAh8lBnQxza9cOAzY7LbfgQ4FWX2sYqiuHsoVWJg4mNDppueQkAVd0XIPU4GhcrNBca8aemNgr24m4jDv200ooFw0Bhz";
            var msg = "";

            if (togglePause == "pause")
            {
                var options = new SubscriptionUpdateOptions
                {
                    PauseCollection = new SubscriptionPauseCollectionOptions
                    {
                        Behavior = "mark_uncollectible",
                    },
                };
                var service = new SubscriptionService();
                service.Update("sub_HZ5QvvcLgLx8vW", options);
                msg = "Subscription paused";
            }

            else if (togglePause == "resume")
            {
                var options = new SubscriptionUpdateOptions();
                options.AddExtraParam("pause_collection", "");
                var service = new SubscriptionService();
                service.Update("sub_HZ5QvvcLgLx8vW", options);
                msg = "Subscription resumed";
            }
            //ViewBag.message = msg;
            return(msg);
        }
예제 #2
0
        public ActionResult continueSubscription()
        {
            StripeConfiguration.ApiKey = "sk_test_51GxEfiHhYK7K9XttqUpv12yjajZLs01TY95VhvzVfPEb5Ed8GaF3GFUV2iuhFZGkBgHoNib4iHBDlpALqWPplth6008EdMnnaw";

            var options = new SubscriptionUpdateOptions();

            options.AddExtraParam("pause_collection", "");
            var service = new SubscriptionService();

            service.Update("sub_HXNOGgEcJT2vvM", options);
            return(Redirect("/Home/Billing"));
        }
예제 #3
0
        public ActionResult Resume()
        {
            try
            {
                StripeConfiguration.ApiKey            = key;
                StripeConfiguration.MaxNetworkRetries = 2;

                var options = new SubscriptionUpdateOptions();
                options.AddExtraParam("pause_collection", "");
                var service = new SubscriptionService();
                service.Update(subscriptionId, options);

                return(View("OrderStatus"));
            }
            catch (StripeException e)
            {
                var x = new
                {
                    status  = "Failed",
                    message = e.Message
                };
                return(this.Json(x));
            }
        }