2015-09-04 215 views
1

我已經設置了沒有有效日期的按月訂閱。如果有人取消其訂閱它調用場景如何:通過Paymill取消訂閱後終止訂閱

$subscription->setId('sub_dea86e5c65b2087202e3'); 
      ->setRemove(false); 

我沒有得到任何有關被黃牌警告本期信息背後的以下功能。如果某人在9月1日訂閱並在9月2日取消,我無法查明,如果他的訂閱仍然有效。

回答

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 */ 
} 

如果有此解決方案的任何問題,我會很樂意回答他們。