我设置了没有有效期的月度订阅。如果有人取消他的订阅,它会在后台调用以下函数
$subscription->setId('sub_dea86e5c65b2087202e3');
->setRemove(false);
我没有得到有关当前预订期间的信息。如果有人在 9 月 1 日订阅并在 9 月 2 日取消,我无法确定他的订阅是否仍然有效。
由于没有查询 Paymill-API 的内置方法,因此我执行了以下操作:
$subscription = $this->getClientSubscriptions(); //Get subscriptions for the client
if ($subscription)
{
if ( ! $subscription['is_canceled'])
{
$this->client->end_of_period = date('Y-m-d H:i:s', $subscription['next_capture_at']);
/* Set end of period within the database if
subscription is not canceled */
} elseif ($this->client->end_of_period < date('Y-m-d H:i:s'))
{
/* If the subscription has been canceled we can
compare the end of period to the current date
and set the subscription to false since it expired */
$this->client->end_of_period = null;
$subscription = false;
}
$this->client->save();
$this->cache->put($subscription_cache, $subscription, 1440);
/* Save and put it to cache to prevent excessive calls to the paymill-api */
}
如果对此解决方案有任何疑问,我将很乐意回答。