Stripe payments 条带API-下一个付款日期

Stripe payments 条带API-下一个付款日期,stripe-payments,Stripe Payments,我正在使用stripe API向我的客户签署每月定期账单 鉴于此响应,我如何显示他们下次付款的到期时间: "subscription": { "current_period_end": 1306060846, "status": "trialing", "plan": { "interval": "month", "amount": 1000, "trial_period_days": 0, "object": "plan"

我正在使用stripe API向我的客户签署每月定期账单

鉴于此响应,我如何显示他们下次付款的到期时间:

"subscription": {
    "current_period_end": 1306060846,
    "status": "trialing",
    "plan": {
      "interval": "month",
      "amount": 1000,
      "trial_period_days": 0,
      "object": "plan",
      "id": "Basic"
    },
    "current_period_start": 1305974416,
    "start": 1305974416,
    "object": "subscription",
    "trial_start": 1305974416,
    "trial_end": 1306060846,
    "customer": "O8ygDbcWW9aswmxctU9z",
  },
  "id": "O8ygDbcWW9aswmxctU9z"
}
您可以使用php中的date函数将其转换为日期格式

更新:自2019年年中起,对于当前未试用的订阅,您将在
订阅
对象中找到下一个计费周期的Unix时间戳,即
当前周期

$timestamp = "2306060846";
$next_payment_date = date('Y-m-d',$timestamp));

它以Y-m-d格式为您提供时间

您可以按如下方式检查订阅状态:

customer = Stripe::Customer.retrieve("cus_7G9REJXtaW05QY")
subscription = customer.subscriptions.retrieve("sub_7HFIqkWIDqEhho")

if subscription.status == 'trialing'
  next_payment_date = Time.at(subscription.trial_end).strftime("%B %d, %Y")
end
跟踪结束后,您可以从订阅中检查
当前\u期间\u结束
属性

next_payment_date = Time.at(subscription.current_period_end).strftime("%B %d, %Y")
此外,如果您只有一个月的试用期,您可以使用
当前\u期间\u结束
。这在所有情况下都适用

PS:对于状态检查,单词是
trialing
而不是
trialing
,如果我没有错,说明Stripe团队存在拼写错误。:-)


据我所知,这是不完全可能的<代码>试用结束(如果设置)将是第一个付款日期<代码>当前\u期间\u结束将是下一次充电尝试,但如果出现下降,下一次充电将按照设置中的计划进行(例如,1天后重试,3天后重试,取消)。您必须跟踪拒绝情况,并使用设置中的规则计算下一个付款日期。

我如何展开我的回答?这是否正确?这是一篇老文章,也许它曾经是对的,但它似乎不正确。听起来更像是
当前周期结束
(一个时间戳)更有可能在@rtf执行itAgreed,目前它的
当前周期结束
这个时间戳是UTC吗?
next_payment_date = Time.at(subscription.current_period_end).strftime("%B %d, %Y")