PluginProbe ʕ •ᴥ•ʔ
Code Manager / 1.0.35
Code Manager v1.0.35
1.0.47 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.19 1.0.2 1.0.20 1.0.21 1.0.22 1.0.23 1.0.24 1.0.25 1.0.26 1.0.27 1.0.28 1.0.3 1.0.30 1.0.31 1.0.32 1.0.33 1.0.34 1.0.35 1.0.36 1.0.37 1.0.38 1.0.39 1.0.4 1.0.40 1.0.41 1.0.42 1.0.43 1.0.44 1.0.45 1.0.46 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9
code-manager / freemius / includes / entities / class-fs-subscription.php
code-manager / freemius / includes / entities Last commit date
class-fs-affiliate-terms.php 2 years ago class-fs-affiliate.php 2 years ago class-fs-billing.php 2 years ago class-fs-entity.php 2 years ago class-fs-payment.php 2 years ago class-fs-plugin-info.php 2 years ago class-fs-plugin-license.php 2 years ago class-fs-plugin-plan.php 2 years ago class-fs-plugin-tag.php 2 years ago class-fs-plugin.php 2 years ago class-fs-pricing.php 2 years ago class-fs-scope-entity.php 2 years ago class-fs-site.php 2 years ago class-fs-subscription.php 2 years ago class-fs-user.php 2 years ago index.php 2 years ago
class-fs-subscription.php
147 lines
1 <?php
2 /**
3 * @package Freemius
4 * @copyright Copyright (c) 2015, Freemius, Inc.
5 * @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
6 * @since 1.0.9
7 */
8
9 if ( ! defined( 'ABSPATH' ) ) {
10 exit;
11 }
12
13 class FS_Subscription extends FS_Entity {
14
15 #region Properties
16
17 /**
18 * @var number
19 */
20 public $user_id;
21 /**
22 * @var number
23 */
24 public $install_id;
25 /**
26 * @var number
27 */
28 public $plan_id;
29 /**
30 * @var number
31 */
32 public $license_id;
33 /**
34 * @var float
35 */
36 public $total_gross;
37 /**
38 * @var float
39 */
40 public $amount_per_cycle;
41 /**
42 * @var int # of months
43 */
44 public $billing_cycle;
45 /**
46 * @var float
47 */
48 public $outstanding_balance;
49 /**
50 * @var int
51 */
52 public $failed_payments;
53 /**
54 * @var string
55 */
56 public $gateway;
57 /**
58 * @var string
59 */
60 public $external_id;
61 /**
62 * @var string|null
63 */
64 public $trial_ends;
65 /**
66 * @var string|null Datetime of the next payment, or null if cancelled.
67 */
68 public $next_payment;
69 /**
70 * @since 2.3.1
71 *
72 * @var string|null Datetime of the cancellation.
73 */
74 public $canceled_at;
75 /**
76 * @var string|null
77 */
78 public $vat_id;
79 /**
80 * @var string Two characters country code
81 */
82 public $country_code;
83
84 #endregion Properties
85
86 /**
87 * @param object|bool $subscription
88 */
89 function __construct( $subscription = false ) {
90 parent::__construct( $subscription );
91 }
92
93 static function get_type() {
94 return 'subscription';
95 }
96
97 /**
98 * Check if subscription is active.
99 *
100 * @author Vova Feldman (@svovaf)
101 * @since 1.0.9
102 *
103 * @return bool
104 */
105 function is_active() {
106 if ( $this->is_canceled() ) {
107 return false;
108 }
109
110 return (
111 ! empty( $this->next_payment ) &&
112 strtotime( $this->next_payment ) > WP_FS__SCRIPT_START_TIME
113 );
114 }
115
116 /**
117 * @author Vova Feldman (@svovaf)
118 * @since 2.3.1
119 *
120 * @return bool
121 */
122 function is_canceled() {
123 return ! is_null( $this->canceled_at );
124 }
125
126 /**
127 * Subscription considered to be new without any payments
128 * if the next payment should be made within less than 24 hours
129 * from the subscription creation.
130 *
131 * @author Vova Feldman (@svovaf)
132 * @since 1.0.9
133 *
134 * @return bool
135 */
136 function is_first_payment_pending() {
137 return ( WP_FS__TIME_24_HOURS_IN_SEC >= strtotime( $this->next_payment ) - strtotime( $this->created ) );
138 }
139
140 /**
141 * @author Vova Feldman (@svovaf)
142 * @since 1.1.7
143 */
144 function has_trial() {
145 return ! is_null( $this->trial_ends );
146 }
147 }