如何使用Recurly找出下一个订阅的内容?

时间:2015-09-03 21:10:43

标签: 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?

2 个答案:

答案 0 :(得分:2)

听起来您希望等待订阅更改。如果获取特定订阅UUID的详细信息,则任何挂起的更改都将嵌套在响应中。有关详细信息,请查看https://dev.recurly.com/docs/lookup-subscription-details

答案 1 :(得分:0)

根据未来方面查找详细信息。

查询订阅详情

查找订阅的详细信息。

暂停订阅更改

在查找具有挂起更改的订阅时,新订阅详细信息将位于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>

来源Recurly Docs