yjl101
yjl101

Reputation: 17

How to find out what is the next subscription using Recurly?

recurly_account = Recurly::Account.find "xxx account code"
subscription = recurly_account.subscriptions[0]
subscription.update_attributes(:plan_code => "desired subscription type",
:timeframe => 'renewal')

After doing this, Recurly (a subscription manager product) will remember to change this subscription to have the new plan_code when the current cycle ends. My question is whether there is a way to ask this subscription object what is the plan_code that it is going to change to?

Upvotes: 1

Views: 260

Answers (2)

Ashish Chaturvedi
Ashish Chaturvedi

Reputation: 1379

Find details answer as per future aspects.

Lookup Subscription Details

Lookup a subscription's details.

PENDING SUBSCRIPTION CHANGES

When looking up a subscription that has pending changes, the new subscription details will be in a pending_subscription node. Since immediate subscription changes take place immediately, pending subscription changes will only show for changes occurring when the subscription renews.

Definition

https://:subdomain.recurly.com/v2/subscriptions/:uuid

PHP Examples

try {
  $subscription = Recurly_Subscription::get('44f83d7cba354d5b84812419f923ea96');

  print "Subscription: $subscription";
} catch (Recurly_NotFoundError $e) {
  print "Subscription Not Found: $e";
}

Result Format

<subscription href="https://your-subdomain.recurly.com/v2/subscriptions/44f83d7cba354d5b84812419f923ea96">
  <account href="https://your-subdomain.recurly.com/v2/accounts/1"/>
  <invoice href="https://your-subdomain.recurly.com/v2/invoices/1108"/>
  <plan href="https://your-subdomain.recurly.com/v2/plans/gold">
    <plan_code>gold</plan_code>
    <name>Gold plan</name>
  </plan>
  <uuid>44f83d7cba354d5b84812419f923ea96</uuid>
  <state>active</state>
  <unit_amount_in_cents type="integer">800</unit_amount_in_cents>
  <currency>EUR</currency>
  <quantity type="integer">1</quantity>
  <activated_at type="datetime">2011-05-27T07:00:00Z</activated_at>
  <canceled_at nil="nil"></canceled_at>
  <expires_at nil="nil"></expires_at>
  <current_period_started_at type="datetime">2011-06-27T07:00:00Z</current_period_started_at>
  <current_period_ends_at type="datetime">2010-07-27T07:00:00Z</current_period_ends_at>
  <trial_started_at nil="nil"></trial_started_at>
  <trial_ends_at nil="nil"></trial_ends_at>
  <tax_in_cents type="integer">80</tax_in_cents>
  <tax_type>usst</tax_type>
  <tax_region>CA</tax_region>
  <tax_rate type="float">0.0875</tax_rate>
  <po_number nil="nil"></po_number>
  <net_terms type="integer">0</net_terms>
  <subscription_add_ons type="array">
  </subscription_add_ons>
  <a name="cancel" href="https://your-subdomain.recurly.com/v2/subscriptions/44f83d7cba354d5b84812419f923ea96/cancel" method="put"/>
  <a name="terminate" href="https://your-subdomain.recurly.com/v2/subscriptions/44f83d7cba354d5b84812419f923ea96/terminate" method="put"/>
  <a name="postpone" href="https://your-subdomain.recurly.com/v2/subscriptions/44f83d7cba354d5b84812419f923ea96/postpone" method="put"/>
</subscription>

Source Recurly Docs

Upvotes: 0

Rachel Davis
Rachel Davis

Reputation: 1804

It sounds like you want to get pending subscription changes. If you GET the details of a specific subscription UUID, any pending changes will be nested within the response. Take a look at https://dev.recurly.com/docs/lookup-subscription-details for more details.

Upvotes: 2

Related Questions