1

When viewing an active, non-renewing subscription on the Recurly website, such as

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

the Recurly website shows info like this:

Status: Active
Start Date: Feb 9, 2016 7:44 PM UTC
Current Period: Feb 09, 2016 — Mar 09, 2016
Next Invoice: Will not renew
Billing Cycles: 0 renewals remaining (of 1)
End Date: Mar 9, 2016 7:44 PM UTC

Looking up the same subscription using the Recurly API, I cannot figure out how to determine if the subscription will renew. This is PHP, but language doesn't matter:

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");

This outputs:

active
Tue 09 Feb 19:44:48 UTC 2016
Tue 09 Feb 19:44:48 UTC 2016
Wed 09 Mar 19:44:48 UTC 2016
nope
nope

How can I determine if this subscription will renew?

Totes McGoats
  • 111
  • 1
  • 3

2 Answers2

2

Sent my request to Recurly Support and got this reply. Hope it helps someone in the future:

A subscription that has a fixed number of billing cycles does not renew. A subscription details API call of this type of subscription would expose the following parameters:

  • total_billing_cycles

  • remaining_billing_cycles

These parameters are not exposed with a renewable subscription.

Therefore by adding (PHP) these lines in the details call will ID whether the subscription is a non-renewing subscription:

// test to determine if the total_billing_cycles parameter is exposed/present

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

I hope this answers your question. Thank you again. Regards,

Ian Recurly Support

Totes McGoats
  • 111
  • 1
  • 3
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.

Jannik
  • 2,310
  • 6
  • 32
  • 61
  • No. That is invoice-specific. There can be many invoices per subscription. A particular invoice could have been collected at a time when the subscription was recurring, while at present it may no longer be recurring. – Totes McGoats Feb 11 '16 at 08:11