PluginProbe
Buttonizer – Floating Menus, Sticky Buttons, & Popup Builder / 3.6.0
Buttonizer – Floating Menus, Sticky Buttons, & Popup Builder v3.6.0
3.6.0 3.5.0 trunk 1.0.10 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.6.1 1.0.7 1.0.8 1.0.9 1.1 1.1.1 1.2 1.3 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.5 1.5.1 All 110 releases
← All changes | freemius/includes/entities/class-fs-payment.php +159 -85 1.4.5 → 3.6.0 View file →
@@ -1,94 +1,168 @@
1 1 <?php
2 - /**
3 - * @package Freemius
4 - * @copyright Copyright (c) 2016, Freemius, Inc.
5 - * @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
6 - * @since 1.0.0
7 - */
2 + /**
3 + * @package Freemius
4 + * @copyright Copyright (c) 2016, Freemius, Inc.
5 + * @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
6 + * @since 1.0.0
7 + */
8 8
9 - if ( ! defined( 'ABSPATH' ) ) {
10 - exit;
11 - }
9 + if ( ! defined( 'ABSPATH' ) ) {
10 + exit;
11 + }
12 12
13 - class FS_Payment extends FS_Entity {
13 + class FS_Payment extends FS_Entity {
14 14
15 - #region Properties
15 + #region Properties
16 16
17 - /**
18 - * @var number
19 - */
20 - public $plugin_id;
21 - /**
22 - * @var number
23 - */
24 - public $user_id;
25 - /**
26 - * @var number
27 - */
28 - public $install_id;
29 - /**
30 - * @var number
31 - */
32 - public $subscription_id;
33 - /**
34 - * @var number
35 - */
36 - public $plan_id;
37 - /**
38 - * @var number
39 - */
40 - public $license_id;
41 - /**
42 - * @var float
43 - */
44 - public $gross;
45 - /**
46 - * @var number
47 - */
48 - public $bound_payment_id;
49 - /**
50 - * @var string
51 - */
52 - public $external_id;
53 - /**
54 - * @var string
55 - */
56 - public $gateway;
57 - /**
58 - * @var string ISO 3166-1 alpha-2 - two-letter country code.
59 - *
60 - * @link http://www.wikiwand.com/en/ISO_3166-1_alpha-2
61 - */
62 - public $country_code;
63 - /**
64 - * @var string
65 - */
66 - public $vat_id;
67 - /**
68 - * @var float Actual Tax / VAT in $$$
69 - */
70 - public $vat;
17 + /**
18 + * @var number
19 + */
20 + public $plugin_id;
21 + /**
22 + * @var number
23 + */
24 + public $user_id;
25 + /**
26 + * @var number
27 + */
28 + public $install_id;
29 + /**
30 + * @var number
31 + */
32 + public $subscription_id;
33 + /**
34 + * @var number
35 + */
36 + public $plan_id;
37 + /**
38 + * @var number
39 + */
40 + public $license_id;
41 + /**
42 + * @var float
43 + */
44 + public $gross;
45 + /**
46 + * @author Leo Fajardo (@leorw)
47 + * @since 2.3.0
48 + *
49 + * @var string One of the following: `usd`, `gbp`, `eur`.
50 + */
51 + public $currency;
52 + /**
53 + * @var number
54 + */
55 + public $bound_payment_id;
56 + /**
57 + * @var string
58 + */
59 + public $external_id;
60 + /**
61 + * @var string
62 + */
63 + public $gateway;
64 + /**
65 + * @var string ISO 3166-1 alpha-2 - two-letter country code.
66 + *
67 + * @link http://www.wikiwand.com/en/ISO_3166-1_alpha-2
68 + */
69 + public $country_code;
70 + /**
71 + * @var string
72 + */
73 + public $vat_id;
74 + /**
75 + * @var float Actual Tax / VAT in $$$
76 + */
77 + public $vat;
78 + /**
79 + * @var int Payment source.
80 + */
81 + public $source = 0;
71 82
72 - #endregion Properties
83 + #endregion Properties
73 84
74 - /**
75 - * @param object|bool $payment
76 - */
77 - function __construct( $payment = false ) {
78 - parent::__construct( $payment );
79 - }
85 + const CURRENCY_USD = 'usd';
86 + const CURRENCY_GBP = 'gbp';
87 + const CURRENCY_EUR = 'eur';
80 88
81 - static function get_type() {
82 - return 'payment';
83 - }
89 + /**
90 + * @param object|bool $payment
91 + */
92 + function __construct( $payment = false ) {
93 + parent::__construct( $payment );
94 + }
84 95
85 - /**
86 - * @author Vova Feldman (@svovaf)
87 - * @since 1.0.0
88 - *
89 - * @return bool
90 - */
91 - function is_refund() {
92 - return ( parent::is_valid_id( $this->bound_payment_id ) && 0 > $this->gross );
93 - }
94 - }
96 + static function get_type() {
97 + return 'payment';
98 + }
99 +
100 + /**
101 + * @author Vova Feldman (@svovaf)
102 + * @since 1.0.0
103 + *
104 + * @return bool
105 + */
106 + function is_refund() {
107 + return ( parent::is_valid_id( $this->bound_payment_id ) && 0 > $this->gross );
108 + }
109 +
110 + /**
111 + * Checks if the payment was migrated from another platform.
112 + *
113 + * @author Vova Feldman (@svovaf)
114 + * @since 2.0.2
115 + *
116 + * @return bool
117 + */
118 + function is_migrated() {
119 + return ( 0 != $this->source );
120 + }
121 +
122 + /**
123 + * Returns the gross in this format:
124 + * `{symbol}{amount | 2 decimal digits} {currency | uppercase}`
125 + *
126 + * Examples: £9.99 GBP, -£9.99 GBP.
127 + *
128 + * @author Leo Fajardo (@leorw)
129 + * @since 2.3.0
130 + *
131 + * @return string
132 + */
133 + function formatted_gross()
134 + {
135 + return (
136 + ( $this->gross < 0 ? '-' : '' ) .
137 + $this->get_symbol() .
138 + number_format( abs( $this->gross ), 2, '.', ',' ) . ' ' .
139 + strtoupper( $this->currency )
140 + );
141 + }
142 +
143 + /**
144 + * A map between supported currencies with their symbols.
145 + *
146 + * @var array<string,string>
147 + */
148 + static $CURRENCY_2_SYMBOL;
149 +
150 + /**
151 + * @author Leo Fajardo (@leorw)
152 + * @since 2.3.0
153 + *
154 + * @return string
155 + */
156 + private function get_symbol() {
157 + if ( ! isset( self::$CURRENCY_2_SYMBOL ) ) {
158 + // Lazy load.
159 + self::$CURRENCY_2_SYMBOL = array(
160 + self::CURRENCY_USD => '$',
161 + self::CURRENCY_GBP => '&pound;',
162 + self::CURRENCY_EUR => '&euro;',
163 + );
164 + }
165 +
166 + return self::$CURRENCY_2_SYMBOL[ $this->currency ];
167 + }
168 + }