如何:在Paymill取消订阅后结束订阅

时间:2015-09-04 06:58:59

标签: php laravel paymill

我已经设置了每月订阅,没有有效日期。如果有人取消了他在幕后调用以下功能的订阅

grunt.registerTask('phpcs_extra', function() {
    // do stuff
}

grunt.registerTask('phpcs_docs', function() {
    // do stuff
}

grunt.registerTask('phpcs_core', function() {
    // do stuff
}

我没有得到有关当前预订时间的信息。如果有人在9月1日订阅并在9月2日取消,我无法查明,如果他的订阅仍然有效。

1 个答案:

答案 0 :(得分:1)

由于没有内置的方式来查询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 */
}

如果对此解决方案有任何疑问,我将很乐意回答这些问题。