Beispiel #1
0
        public PlanResponse CreatePlan(string planId, decimal amount, string currency, PlanFrequency interval, string name, int? trialPeriodDays = null)
        {
            Require.Argument("planId", planId);
            Require.Argument("amount", amount);
            Require.Argument("currency", currency);
            Require.Argument("interval", interval);
            Require.Argument("name", interval);

            if (trialPeriodDays.HasValue)
                Validate.IsBetween(trialPeriodDays.Value, 0, Int32.MaxValue);

            var request = new RestRequest();
            request.Method = Method.POST;
            request.Resource = "plans";

            int inCents = Convert.ToInt32(amount * 100M);

            request.AddParameter("id", planId);
            request.AddParameter("amount", inCents);
            request.AddParameter("currency", currency);
            request.AddParameter("interval", interval.ToString().ToLowerInvariant());
            request.AddParameter("name", name);
            if (trialPeriodDays.HasValue) request.AddParameter("trial_period_days", trialPeriodDays);

            return Execute<PlanResponse>(request);
        }
Beispiel #2
0
        public StripePlan CreatePlan(string planId, decimal amount, string currency, PlanFrequency interval, string name, int?trialPeriodDays = null)
        {
            Require.Argument("planId", planId);
            Require.Argument("amount", amount);
            Require.Argument("currency", currency);
            Require.Argument("interval", interval);
            Require.Argument("name", interval);

            if (trialPeriodDays.HasValue)
            {
                Validate.IsBetween(trialPeriodDays.Value, 0, Int32.MaxValue);
            }

            var request = new RestRequest();

            request.Method   = Method.POST;
            request.Resource = "plans";

            int inCents = Convert.ToInt32(amount * 100M);

            request.AddParameter("id", planId);
            request.AddParameter("amount", inCents);
            request.AddParameter("currency", currency);
            request.AddParameter("interval", interval.ToString().ToLowerInvariant());
            request.AddParameter("name", name);
            if (trialPeriodDays.HasValue)
            {
                request.AddParameter("trial_period_days", trialPeriodDays);
            }

            return(Execute <StripePlan>(request));
        }
        /// <summary>
        /// You can create plans easily via the plan management page of the Stripe dashboard. Plan creation is also accessible via the API if you need to create plans on the fly.
        /// </summary>
        /// <param name="planId">Unique string of your choice that will be used to identify this plan when subscribing a customer.</param>
        /// <param name="amount">A positive integer in cents (or 0 for a free plan) representing how much to charge (on a recurring basis).</param>
        /// <param name="currency">3-letter ISO code for currency.</param>
        /// <param name="interval">Specifies billing frequency. Either day, week, month or year.</param>
        /// <param name="name">Name of the plan, to be displayed on invoices and in the web interface.</param>
        /// <param name="trialPeriodDays">Specifies a trial period in (an integer number of) days. </param>
        /// <param name="intervalCount">The number of intervals between each subscription billing. For example, interval=month and interval_count=3 bills every 3 months.</param>
        /// <param name="statementDescriptor">An arbitrary string to be displayed on your customer’s credit card statement.</param>
        /// <param name="metaData">A set of key/value pairs that you can attach to a plan object.</param>
        /// <returns>Returns the plan object.</returns>
        public StripeObject CreatePlan(string planId, decimal amount, string currency, PlanFrequency interval, 
            string name, int? trialPeriodDays = null, int? intervalCount = 1, string statementDescriptor = null,
            IDictionary<object, object> metaData = null)
        {
            Require.Argument("planId", planId);
            Require.Argument("amount", amount);
            Require.Argument("currency", currency);
            Require.Argument("interval", interval);
            Require.Argument("name", interval);

            if (trialPeriodDays.HasValue)
                Validate.IsBetween(trialPeriodDays.Value, 0, Int32.MaxValue);

            var request = new RestRequest();
            request.Method = Method.POST;
            request.Resource = "plans";

            int inCents = Convert.ToInt32(amount * 100M);

            request.AddParameter("id", planId);
            request.AddParameter("amount", inCents);
            request.AddParameter("currency", currency);
            request.AddParameter("interval", interval.ToString().ToLowerInvariant());
            request.AddParameter("name", name);

            if (intervalCount.HasValue) request.AddParameter("interval_count", intervalCount);
            if (trialPeriodDays.HasValue) request.AddParameter("trial_period_days", trialPeriodDays);
            if (statementDescriptor.HasValue()) request.AddParameter("statement_descriptor", statementDescriptor);
            if (metaData != null) AddDictionaryParameter(metaData, "metadata", request);

            return ExecuteObject(request);
        }
Beispiel #4
0
        /// <summary>
        /// You can create plans easily via the plan management page of the Stripe dashboard. Plan creation is also accessible via the API if you need to create plans on the fly.
        /// </summary>
        /// <param name="planId">Unique string of your choice that will be used to identify this plan when subscribing a customer.</param>
        /// <param name="amount">A positive integer in cents (or 0 for a free plan) representing how much to charge (on a recurring basis).</param>
        /// <param name="currency">3-letter ISO code for currency.</param>
        /// <param name="interval">Specifies billing frequency. Either day, week, month or year.</param>
        /// <param name="name">Name of the plan, to be displayed on invoices and in the web interface.</param>
        /// <param name="trialPeriodDays">Specifies a trial period in (an integer number of) days. </param>
        /// <param name="intervalCount">The number of intervals between each subscription billing. For example, interval=month and interval_count=3 bills every 3 months.</param>
        /// <param name="statementDescriptor">An arbitrary string to be displayed on your customer’s credit card statement.</param>
        /// <param name="metaData">A set of key/value pairs that you can attach to a plan object.</param>
        /// <returns>Returns the plan object.</returns>
        public StripeObject CreatePlan(string planId, decimal amount, string currency, PlanFrequency interval,
                                       string name, int?trialPeriodDays      = null, int?intervalCount = 1, string statementDescriptor = null,
                                       IDictionary <object, object> metaData = null)
        {
            Require.Argument("planId", planId);
            Require.Argument("amount", amount);
            Require.Argument("currency", currency);
            Require.Argument("interval", interval);
            Require.Argument("name", interval);

            if (trialPeriodDays.HasValue)
            {
                Validate.IsBetween(trialPeriodDays.Value, 0, Int32.MaxValue);
            }

            var request = new RestRequest();

            request.Method   = Method.POST;
            request.Resource = "plans";

            int inCents = Convert.ToInt32(amount * 100M);

            request.AddParameter("id", planId);
            request.AddParameter("amount", inCents);
            request.AddParameter("currency", currency);
            request.AddParameter("interval", interval.ToString().ToLowerInvariant());
            request.AddParameter("name", name);

            if (intervalCount.HasValue)
            {
                request.AddParameter("interval_count", intervalCount);
            }
            if (trialPeriodDays.HasValue)
            {
                request.AddParameter("trial_period_days", trialPeriodDays);
            }
            if (statementDescriptor.HasValue())
            {
                request.AddParameter("statement_descriptor", statementDescriptor);
            }
            if (metaData != null)
            {
                AddDictionaryParameter(metaData, "metadata", request);
            }

            return(ExecuteObject(request));
        }