# tablepress/2.2.4/libraries/freemius/includes/entities/class-fs-subscription.php

TablePress – Tables in WordPress made easy, version 2.2.4. 147 lines.

- Page: https://pluginprobe.com/plugins/tablepress/2.2.4/code/libraries/freemius/includes/entities/class-fs-subscription.php
- Raw: https://pluginprobe.com/plugins/tablepress/2.2.4/raw/libraries/freemius/includes/entities/class-fs-subscription.php
- Modified: 2022-12-19T11:32:06+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/tablepress/2.2.4/code/libraries/freemius/includes/entities/class-fs-subscription.php#L10-L20`.

```php
<?php
	/**
	 * @package     Freemius
	 * @copyright   Copyright (c) 2015, Freemius, Inc.
	 * @license     https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
	 * @since       1.0.9
	 */

	if ( ! defined( 'ABSPATH' ) ) {
		exit;
	}

	class FS_Subscription extends FS_Entity {

		#region Properties

		/**
		 * @var number
		 */
		public $user_id;
		/**
		 * @var number
		 */
		public $install_id;
		/**
		 * @var number
		 */
		public $plan_id;
		/**
		 * @var number
		 */
		public $license_id;
		/**
		 * @var float
		 */
		public $total_gross;
		/**
		 * @var float
		 */
		public $amount_per_cycle;
		/**
		 * @var int # of months
		 */
		public $billing_cycle;
		/**
		 * @var float
		 */
		public $outstanding_balance;
		/**
		 * @var int
		 */
		public $failed_payments;
		/**
		 * @var string
		 */
		public $gateway;
		/**
		 * @var string
		 */
		public $external_id;
		/**
		 * @var string|null
		 */
		public $trial_ends;
		/**
		 * @var string|null Datetime of the next payment, or null if cancelled.
		 */
		public $next_payment;
		/**
		 * @since 2.3.1
		 *
		 * @var string|null Datetime of the cancellation.
		 */
		public $canceled_at;
		/**
		 * @var string|null
		 */
		public $vat_id;
		/**
		 * @var string Two characters country code
		 */
		public $country_code;

		#endregion Properties

		/**
		 * @param object|bool $subscription
		 */
		function __construct( $subscription = false ) {
			parent::__construct( $subscription );
		}

		static function get_type() {
			return 'subscription';
		}

		/**
		 * Check if subscription is active.
		 *
		 * @author Vova Feldman (@svovaf)
		 * @since  1.0.9
		 *
		 * @return bool
		 */
		function is_active() {
			if ( $this->is_canceled() ) {
				return false;
			}

			return (
				! empty( $this->next_payment ) &&
				strtotime( $this->next_payment ) > WP_FS__SCRIPT_START_TIME
			);
		}

		/**
		 * @author Vova Feldman (@svovaf)
		 * @since  2.3.1
		 *
		 * @return bool
		 */
		function is_canceled() {
			return ! is_null( $this->canceled_at );
		}

		/**
		 * Subscription considered to be new without any payments
		 * if the next payment should be made within less than 24 hours
		 * from the subscription creation.
		 *
		 * @author Vova Feldman (@svovaf)
		 * @since  1.0.9
		 *
		 * @return bool
		 */
		function is_first_payment_pending() {
			return ( WP_FS__TIME_24_HOURS_IN_SEC >= strtotime( $this->next_payment ) - strtotime( $this->created ) );
		}

		/**
		 * @author Vova Feldman (@svovaf)
		 * @since  1.1.7
		 */
		function has_trial() {
			return ! is_null( $this->trial_ends );
		}
	}
```
