Since there is no built-in way to query the Paymill-API I've done the following:
$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 */
}
If there are any question for this solution I'll be happy to answer them.