FS_Subscription

The NextGEN Gallery FS Subscription class.

Defined (1)

The class is defined in the following location(s).

/freemius/includes/entities/class-fs-subscription.php  
  1. class FS_Subscription extends FS_Entity { 
  2.  
  3. #region Properties 
  4.  
  5. /** 
  6. * @var number 
  7. */ 
  8. public $user_id; 
  9. /** 
  10. * @var number 
  11. */ 
  12. public $install_id; 
  13. /** 
  14. * @var number 
  15. */ 
  16. public $plan_id; 
  17. /** 
  18. * @var number 
  19. */ 
  20. public $license_id; 
  21. /** 
  22. * @var float 
  23. */ 
  24. public $total_gross; 
  25. /** 
  26. * @var float 
  27. */ 
  28. public $amount_per_cycle; 
  29. /** 
  30. * @var int # of months 
  31. */ 
  32. public $billing_cycle; 
  33. /** 
  34. * @var float 
  35. */ 
  36. public $outstanding_balance; 
  37. /** 
  38. * @var int 
  39. */ 
  40. public $failed_payments; 
  41. /** 
  42. * @var string 
  43. */ 
  44. public $gateway; 
  45. /** 
  46. * @var string 
  47. */ 
  48. public $external_id; 
  49. /** 
  50. * @var string|null 
  51. */ 
  52. public $trial_ends; 
  53. /** 
  54. * @var string|null Datetime of the next payment, or null if cancelled 
  55. */ 
  56. public $next_payment; 
  57. /** 
  58. * @var string|null 
  59. */ 
  60. public $vat_id; 
  61. /** 
  62. * @var string Two characters country code 
  63. */ 
  64. public $country_code; 
  65.  
  66. #endregion Properties 
  67.  
  68. /** 
  69. * @param object|bool $subscription 
  70. */ 
  71. function __construct( $subscription = false ) { 
  72. parent::__construct( $subscription ); 
  73.  
  74. static function get_type() { 
  75. return 'subscription'; 
  76.  
  77. /** 
  78. * Check if subscription is active. 
  79. * @author Vova Feldman (@svovaf) 
  80. * @since 1.0.9 
  81. * @return bool 
  82. */ 
  83. function is_active() { 
  84. return ! empty( $this->next_payment ) && 
  85. ( strtotime( $this->next_payment ) > WP_FS__SCRIPT_START_TIME ); 
  86.  
  87. /** 
  88. * Subscription considered to be new without any payments 
  89. * if the next payment should be made within less than 24 hours 
  90. * from the subscription creation. 
  91. * @author Vova Feldman (@svovaf) 
  92. * @since 1.0.9 
  93. * @return bool 
  94. */ 
  95. function is_first_payment_pending() { 
  96. return ( WP_FS__TIME_24_HOURS_IN_SEC >= strtotime( $this->next_payment ) - strtotime( $this->created ) ); 
  97.  
  98. /** 
  99. * @author Vova Feldman (@svovaf) 
  100. * @since 1.1.7 
  101. */ 
  102. function has_trial() { 
  103. return ! is_null( $this->trial_ends );