Example #1
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,
            };
        }
        public static PlanListFilterOptions ToPlanListFilter(this StripePlanListOptions stripePlanOptions)
        {
            var planFilter = new PlanListFilterOptions
            {
                Active        = stripePlanOptions.Active,
                EndingBefore  = stripePlanOptions.EndingBefore,
                StartingAfter = stripePlanOptions.StartingAfter,
                ProductId     = stripePlanOptions.ProductId,
                Limit         = stripePlanOptions.Limit
            };

            if (stripePlanOptions.Created != null)
            {
                planFilter.CreatedBefore = stripePlanOptions.Created.LessThanOrEqual;
                planFilter.CreatedAfter  = stripePlanOptions.Created.GreaterThanOrEqual;
            }
            return(planFilter);
        }
        /**** TO STRIPE ****/
        public static StripePlanListOptions ToStripePlanListOptions(this PlanListFilterOptions planFilter)
        {
            var stripePlanOption = new StripePlanListOptions
            {
                Active        = planFilter.Active,
                EndingBefore  = planFilter.EndingBefore,
                StartingAfter = planFilter.StartingAfter,
                ProductId     = planFilter.ProductId,
                Limit         = planFilter.Limit,
                Created       = new StripeDateFilter
                {
                    GreaterThanOrEqual = planFilter.CreatedAfter,
                    LessThanOrEqual    = planFilter.CreatedBefore
                }
            };

            return(stripePlanOption);
        }