Php 如何:在使用Paymill取消订阅后获取订阅的结尾
我已经设定了每月订阅,没有有效期。如果有人在后台取消调用以下函数的订阅Php 如何:在使用Paymill取消订阅后获取订阅的结尾,php,laravel,paymill,Php,Laravel,Paymill,我已经设定了每月订阅,没有有效期。如果有人在后台取消调用以下函数的订阅 $subscription->setId('sub_dea86e5c65b2087202e3'); ->setRemove(false); 我没有得到关于当前预订期间的任何信息。如果有人在9月1日订阅并在9月2日取消,我无法确定他的订阅是否仍然有效。由于没有内置的方式来查询Paymill API,我已执行以下操作: $subscription = $this->getClient
$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 */
}
$subscription=$this->getClientSubscriptions()//获取客户端的订阅
if(订阅费)
{
如果(!$subscription['is_cancelled'])
{
$this->client->end_of_period=date('Y-m-d H:i:s',$subscription['next_capture_at']);
/*如果需要,请在数据库中设置周期结束
订阅未被取消*/
}elseif($this->client->end\u of_periodclient->end\u of_period=null;
$subscription=false;
}
$this->client->save();
$this->cache->put($subscription\u cache,$subscription,1440);
/*保存并将其放入缓存,以防止对paymill api的过度调用*/
}
如果这个解决方案有任何问题,我很乐意回答