laravel cashier braintree 过期日期

laravel cashier braintree expiry date

我正在使用 "laravel/cashier-braintree": "~2.0" 包来管理我的 Laravel 5.5.40 应用程序中的订阅。

到目前为止,我已经创建了一个计划并通过多个用户创建了对计划的订阅。我只是找不到一种方法来获取用户的计划到期日期。

基于此 laracast discussionsubscriptions table 中的 ends_at 列默认保持为空,直到用户取消订阅。

我确实尝试了 Customer::find($braintree_id) 方法并得到了一个巨大的客户详细信息对象,其中包含一个 subscriptions 对象,如下所示:

"subscriptions": [
      {
        "addOns": [],
        "balance": "0.00",
        "billingDayOfMonth": 20,
        "billingPeriodEndDate": {
          "date": "2018-09-19 00:00:00.000000",
          "timezone_type": 3,
          "timezone": "UTC"
        },
        "billingPeriodStartDate": {
          "date": "2018-06-20 00:00:00.000000",
          "timezone_type": 3,
          "timezone": "UTC"
        },
        "createdAt": {
          "date": "2018-06-20 10:06:42.000000",
          "timezone_type": 3,
          "timezone": "UTC"
        },
        "updatedAt": {
          "date": "2018-06-21 05:56:43.000000",
          "timezone_type": 3,
          "timezone": "UTC"
        },
        "currentBillingCycle": 1,
        "daysPastDue": null,
        "discounts": [],
        "failureCount": 0,
        "firstBillingDate": {
          "date": "2018-06-20 00:00:00.000000",
          "timezone_type": 3,
          "timezone": "UTC"
        },

那么有没有更好的方法来获取计划订阅到期日期?

完全披露:我在 Braintree 工作。如果您有任何其他问题,请随时联系 support.

现在 subscription response object does not contain an attribute returned regarding the end date for a subscription. You can subtract the currentBillingCycle from the numberOfBillingCycles to find out when the subscription is set to end. I recommend first checking to see whether neverExpires returns 作为 true 看看是否有结束日期。

例如,如果 numberOfBillingCycles 的值为 12,而 currentBillingCycle 的值为 4,则剩余的计费周期数为 8 .