1

我正在使用 Recurly PHP API,并试图找出一种方法来确定订阅是否有过期发票,因此订阅过期(即使有过期发票,订阅状态也不会改变并且仍然显示为活动状态)。

要访问我正在使用的订阅:

try{
    $subscriptions = Recurly_SubscriptionList::getForAccount('1');
    foreach ($subscriptions as $subscription) { 
        print $subscription;
    }
}

这将返回:

activated_at="2014-10-08 13:18:27 +00:00", 
collection_method="manual", 
currency="USD", 
current_period_ends_at="2014-11-08 14:00:00 +00:00", 
current_period_started_at="2014-10-08 14:00:00 +00:00", 
invoice=, 
net_terms=0, 
plan="", 
quantity=120, 
state="active", 
subscription_add_ons=[], 
trial_ends_at="2014-10-08 14:00:00 +00:00", 
trial_started_at="2014-10-08 13:18:27 +00:00", 
unit_amount_in_cents=500, 
uuid="VALUE"

$subscription 内是发票,但它是空白的,但是,如果我使用:

print_r($subscription->invoice);

它返回:

Recurly_Stub Object ( [objectType] => invoice [_href:protected] => https://subdomain.recurly.com/v2/invoices/1004 [_client:protected] => [_links:protected] => Array ( ) )

发票 1004 是过期发票,因此我希望能够显示订阅已过期,但我无法访问 _href:protected 值,并且看不到任何其他方法来确定订阅是否包含过期发票?

有谁知道另一种方法来判断订阅是否包含过期发票,或者如果失败了,我如何访问 _href:protected 以便我至少可以针对发票运行获取发票 API 进行检查?

4

1 回答 1

4

简短的版本是你应该调用$subscription->invoice->get(). $subscription->invoice返回一个Recurly_Stub对象,您需要调用它的get()方法来强制它加载整个对象。

我们记录了这一点,但显然我们没有把它放在正确的位置。

不过,退后一步,您可能会发现获取所有过期发票Recurly_InvoiceList::getPastDue()并查找他们的订阅会更快。

于 2014-11-24T22:24:35.000 回答