1

在 Recurly 网站上查看有效的非续订订阅时,例如

https://xxxxxx.recurly.com/subscriptions/xxxxxxxxba354d5b84812419xxxxxxxx

Recurly 网站显示如下信息:

状态:有效
开始日期:2016 年 2 月 9 日晚上 7:44 UTC
当前期间:2016 年 2 月 9 日 - 2016 年 3 月 9 日
下一张发票:不会续订
计费周期:剩余 0 次续订(共 1 次)
结束日期:2016 年 3 月 9 日世界标准时间下午 7:44

使用 Recurly API 查找相同的订阅,我不知道如何确定订阅是否会续订。这是 PHP,但语言无关紧要:

const TFORMAT = "D d M H:i:s \U\T\C Y";
$sub = Recurly_Subscription::get('xxxxxxxxba354d5b84812419xxxxxxxx');
echo $sub->state;
echo '<br>' . ($sub->activated_at ? $sub->activated_at->format(TFORMAT) : "nope");
echo '<br>' . ($sub->current_period_started_at ? $sub->current_period_started_at->format(TFORMAT) : "nope");
echo '<br>' . ($sub->current_period_ends_at ? $sub->current_period_ends_at->format(TFORMAT) : "nope");
echo '<br>' . ($sub->expires_at ? $sub->expires_at->format(TFORMAT) : "nope");
echo '<br>' . ($sub->canceled_at ? $sub->canceled_at->format(TFORMAT) : "nope");

这输出:


2016 年 2 月 9 日星期二 19:44:48 UTC 2016 年2月 9 日
星期二 19:44:48 UTC 2016 年3 月 9 日星期三 2016 年 3 月 9 日
星期三
19:44:48
不不不

如何确定此订阅是否会续订?

4

2 回答 2

2

将我的请求发送给 Recurly Support 并得到了回复。希望它对将来的某人有所帮助:

具有固定计费周期数的订阅不会续订。此类订阅的订阅详细信息 API 调用将公开以下参数:

  • total_billing_cycles

  • remaining_billing_cycles

这些参数不会在可更新订阅中公开。

因此,通过在详细信息调用中添加(PHP)这些行将识别订阅是否为非续订订阅:

// 测试以确定 total_billing_cycles 参数是否暴露/存在

  if (isset($subscription->total_billing_cycles)) {
    // If true...do something
    echo "This subscription will not renew";
  }

我希望这回答了你的问题。再次感谢你。问候,

伊恩定期支持

于 2016-02-14T03:48:11.840 回答
0

I never used Recurly but it seems like you first have to get the invoice of the subscription.

When you have the invoice, you could use the

<state>open</state>

and

<collection_method>automatic</collection_method>

to calculate, if the subscription will be renewed.

于 2016-02-11T06:13:01.563 回答