/**
  * Cancel site trial.
  *
  * @author Vova Feldman (@svovaf)
  * @since  1.0.9
  *
  * @uses   FS_Api
  */
 private function _cancel_trial()
 {
     $this->_logger->entrance();
     if (!$this->is_trial()) {
         $this->_admin_notices->add(__fs('trial-cancel-no-trial-message', $this->_slug), __fs('oops', $this->_slug) . '...', 'error');
         return;
     }
     $api = $this->get_api_site_scope();
     $site = $api->call('trials.json', 'delete');
     $trial_cancelled = false;
     if (!isset($site->error)) {
         $prev_trial_ends = $this->_site->trial_ends;
         // Update new site plan id.
         $this->_site->trial_ends = $site->trial_ends;
         $trial_cancelled = $prev_trial_ends != $site->trial_ends;
     } else {
         // handle different error cases.
     }
     if ($trial_cancelled) {
         // Remove previous sticky message about upgrade (if exist).
         $this->_admin_notices->remove_sticky('plan_upgraded');
         $this->_admin_notices->add(sprintf(__fs('trial-cancel-message', $this->_slug), $this->_storage->trial_plan->title));
         $this->_admin_notices->remove_sticky(array('trial_started', 'trial_promotion', 'plan_upgraded'));
         // Store site updates.
         $this->_store_site();
         // Clear trial plan information.
         unset($this->_storage->trial_plan);
     } else {
         $this->_admin_notices->add(__fs('trial-cancel-failure-message', $this->_slug), __fs('oops', $this->_slug) . '...', 'error');
     }
 }
 /**
  * Cancel site trial.
  *
  * @author Vova Feldman (@svovaf)
  * @since  1.0.9
  *
  * @uses   FS_Api
  */
 private function _cancel_trial()
 {
     $this->_logger->entrance();
     if (!$this->is_trial()) {
         $this->_admin_notices->add(__fs('trial-cancel-no-trial-message', $this->_slug), __fs('oops', $this->_slug) . '...', 'error');
         return;
     }
     $api = $this->get_api_site_scope();
     $site = $api->call('trials.json', 'delete');
     $trial_cancelled = false;
     if (!$this->is_api_error($site)) {
         $prev_trial_ends = $this->_site->trial_ends;
         if ($this->is_paid_trial()) {
             $this->_license->expiration = $site->trial_ends;
             $this->_license->is_cancelled = true;
             $this->_update_site_license($this->_license);
             $this->_store_licenses();
             // Clear subscription reference.
             $this->_sync_site_subscription(null);
         }
         // Update site info.
         $this->_site = new FS_Site($site);
         $this->_enrich_site_plan();
         $trial_cancelled = $prev_trial_ends != $site->trial_ends;
     } else {
         // handle different error cases.
     }
     if ($trial_cancelled) {
         // Remove previous sticky messages about upgrade or trial (if exist).
         $this->_admin_notices->remove_sticky(array('trial_started', 'trial_promotion', 'plan_upgraded'));
         // Store site updates.
         $this->_store_site();
         // Clear trial plan information.
         unset($this->_storage->trial_plan);
         if (!$this->is_addon() || !$this->deactivate_premium_only_addon_without_license(true)) {
             $this->_admin_notices->add(sprintf(__fs('trial-cancel-message', $this->_slug), $this->_storage->trial_plan->title));
         }
     } else {
         $this->_admin_notices->add(__fs('trial-cancel-failure-message', $this->_slug), __fs('oops', $this->_slug) . '...', 'error');
     }
 }
Example #3
0
 /**
  * Cancel site trial.
  *
  * @author Vova Feldman (@svovaf)
  * @since  1.0.9
  *
  * @uses   FS_Api
  */
 private function _cancel_trial()
 {
     $this->_logger->entrance();
     if (!$this->is_trial()) {
         $this->_admin_notices->add(__('It looks like you are not in trial mode anymore so there\'s nothing to cancel :)', WP_FS__SLUG), __('Oops...'), 'error');
         return;
     }
     $api = $this->get_api_site_scope();
     $site = $api->call('trials.json', 'delete');
     $trial_cancelled = false;
     if (!isset($site->error)) {
         $prev_trial_ends = $this->_site->trial_ends;
         // Update new site plan id.
         $this->_site->trial_ends = $site->trial_ends;
         $trial_cancelled = $prev_trial_ends != $site->trial_ends;
     } else {
         // handle different error cases.
     }
     if ($trial_cancelled) {
         // Remove previous sticky message about upgrade (if exist).
         $this->_admin_notices->remove_sticky('plan_upgraded');
         $this->_admin_notices->add(sprintf(__('Your %s Plan trial was successfully cancelled.', WP_FS__SLUG), $this->_storage->trial_plan->title));
         $this->_admin_notices->remove_sticky(array('trial_started', 'trial_promotion', 'plan_upgraded'));
         // Store site updates.
         $this->_store_site();
         // Clear trial plan information.
         unset($this->_storage->trial_plan);
     } else {
         $this->_admin_notices->add(__('Seems like we are having some temporary issue with your trial cancellation. Please try again in few minutes.', WP_FS__SLUG), __('Oops...'), 'error');
     }
 }