【问题标题】:Retrieve all subscriptions Stripe with an end date of certain day检索结束日期为某一天的所有订阅 Stripe
【发布时间】:2021-06-13 00:15:00
【问题描述】:

尝试拉入结束日期等于某个日期(不包括小时、分钟或秒)的所有订阅

因此,如果我有两个订阅的结束日期是今天,那么 2021 年 3 月 15 日我想加入以下订阅 -3/15/2021 下午 4:27:13 -3/15/2021 下午 5:27:13

var options = new SubscriptionListOptions
        {
            CurrentPeriodEnd = DateTime.Now,
        };

        var service = new SubscriptionService();
        StripeList<Subscription> subscriptions = service.List(options);
        foreach (Subscription sub in subscriptions)
        {
            string customerId = sub.CustomerId;
        }

这是我目前所拥有的。我正在考虑在今天上午 12:00 到晚上 11:59 之间做一个 CurrentPeriodEnd,但它必须是一个等于内部才能传递参数

非常感谢任何帮助。谢谢!

【问题讨论】:

    标签: c# stripe-payments


    【解决方案1】:

    在进一步查看当前期间结束后,它实际上是一个 AnyOf

    所以我的新代码行是

    CurrentPeriodEnd = new DateRangeOptions() { GreaterThanOrEqual = DateTime.Today, LessThan = DateTime.Today.AddDays(1)},
    

    【讨论】:

      【解决方案2】:

      正如the docs 所说:

      该值可以是带有整数 Unix 时间戳的字符串,也可以是带有以下选项的字典...

      为此,您可以使用该选项字典来提供gtelte 来限定您要查找的日期,借用example from the library repository

      var CurrentPeriodEndOptions = new DateRangeOptions
        {
          LessThanOrEqual = DateTime.Parse("2021-03-16T00:00:00.0000000Z"),
          GreaterThanOrEqual = DateTime.Parse("2021-03-15T00:00:00.0000000Z"),
        },
      var options = new SubscriptionListOptions
      {
        CurrentPeriodEnd = CurrentPeriodEndOptions,
      };
      var service = new SubscriptionService();
      StripeList<Subscription> subscriptions = service.List(
        options
      );
      

      您需要在代码中对返回的结果应用任何进一步的过滤。

      【讨论】:

        猜你喜欢
        • 2017-01-07
        • 2014-09-27
        • 2021-06-17
        • 2022-01-25
        • 1970-01-01
        • 1970-01-01
        • 2021-06-02
        • 1970-01-01
        • 2015-02-15
        相关资源
        最近更新 更多