如何使用 Recurly 找出下一个订阅是什么?

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')

执行此操作后,Recurly(一种订阅管理器产品)会记得在当前周期结束时更改此订阅以拥有新的 plan_code。我的问题是是否有办法询问此订阅对象它将要更改为的 plan_code 是什么?

听起来您想获得待处理的订阅更改。如果您获取特定订阅 UUID 的详细信息,任何未决更改都将嵌套在响应中。查看 https://dev.recurly.com/docs/lookup-subscription-details 了解更多详情。

根据未来的方面查找详细答案。

查找订阅详细信息

查找订阅的详细信息。

待定订阅更改

在查找具有待定更改的订阅时,新的订阅详细信息将在 pending_subscription 节点中。由于即时订阅更改会立即发生,因此待定订阅更改只会显示订阅续订时发生的更改。

定义

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

PHP 例子

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

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

结果格式

<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>

来源递归文档