Passed
Push — master ( 0612be...57280a )
by Brian
05:11
created
includes/class-wpinv-session-handler.php 1 patch
Indentation   +274 added lines, -274 removed lines patch added patch discarded remove patch
@@ -12,125 +12,125 @@  discard block
 block discarded – undo
12 12
  */
13 13
 class WPInv_Session_Handler extends WPInv_Session {
14 14
 
15
-	/**
16
-	 * Cookie name used for the session.
17
-	 *
18
-	 * @var string cookie name
19
-	 */
20
-	protected $_cookie;
21
-
22
-	/**
23
-	 * Stores session expiry.
24
-	 *
25
-	 * @var int session due to expire timestamp
26
-	 */
27
-	protected $_session_expiring;
28
-
29
-	/**
30
-	 * Stores session due to expire timestamp.
31
-	 *
32
-	 * @var string session expiration timestamp
33
-	 */
34
-	protected $_session_expiration;
35
-
36
-	/**
37
-	 * True when the cookie exists.
38
-	 *
39
-	 * @var bool Based on whether a cookie exists.
40
-	 */
41
-	protected $_has_cookie = false;
42
-
43
-	/**
44
-	 * Table name for session data.
45
-	 *
46
-	 * @var string Custom session table name
47
-	 */
48
-	protected $_table;
49
-
50
-	/**
51
-	 * Constructor for the session class.
52
-	 */
53
-	public function __construct() {
54
-
55
-	    $this->_cookie = apply_filters( 'wpinv_cookie', 'wpinv_session_' . COOKIEHASH );
15
+    /**
16
+     * Cookie name used for the session.
17
+     *
18
+     * @var string cookie name
19
+     */
20
+    protected $_cookie;
21
+
22
+    /**
23
+     * Stores session expiry.
24
+     *
25
+     * @var int session due to expire timestamp
26
+     */
27
+    protected $_session_expiring;
28
+
29
+    /**
30
+     * Stores session due to expire timestamp.
31
+     *
32
+     * @var string session expiration timestamp
33
+     */
34
+    protected $_session_expiration;
35
+
36
+    /**
37
+     * True when the cookie exists.
38
+     *
39
+     * @var bool Based on whether a cookie exists.
40
+     */
41
+    protected $_has_cookie = false;
42
+
43
+    /**
44
+     * Table name for session data.
45
+     *
46
+     * @var string Custom session table name
47
+     */
48
+    protected $_table;
49
+
50
+    /**
51
+     * Constructor for the session class.
52
+     */
53
+    public function __construct() {
54
+
55
+        $this->_cookie = apply_filters( 'wpinv_cookie', 'wpinv_session_' . COOKIEHASH );
56 56
         add_action( 'init', array( $this, 'init' ), -1 );
57
-		add_action( 'wp_logout', array( $this, 'destroy_session' ) );
58
-		add_action( 'wp', array( $this, 'set_customer_session_cookie' ), 10 );
59
-		add_action( 'shutdown', array( $this, 'save_data' ), 20 );
60
-
61
-	}
62
-
63
-	/**
64
-	 * Init hooks and session data.
65
-	 *
66
-	 * @since 3.3.0
67
-	 */
68
-	public function init() {
69
-		$this->init_session_cookie();
70
-
71
-		if ( ! is_user_logged_in() ) {
72
-			add_filter( 'nonce_user_logged_out', array( $this, 'nonce_user_logged_out' ), 10, 2 );
73
-		}
74
-	}
75
-
76
-	/**
77
-	 * Setup cookie and customer ID.
78
-	 *
79
-	 * @since 3.6.0
80
-	 */
81
-	public function init_session_cookie() {
82
-		$cookie = $this->get_session_cookie();
83
-
84
-		if ( $cookie ) {
85
-			$this->_customer_id        = $cookie[0];
86
-			$this->_session_expiration = $cookie[1];
87
-			$this->_session_expiring   = $cookie[2];
88
-			$this->_has_cookie         = true;
89
-			$this->_data               = $this->get_session_data();
90
-
91
-			// If the user logs in, update session.
92
-			if ( is_user_logged_in() && get_current_user_id() != $this->_customer_id ) {
93
-				$this->_customer_id = get_current_user_id();
94
-				$this->_dirty       = true;
95
-				$this->save_data();
96
-				$this->set_customer_session_cookie( true );
97
-			}
98
-
99
-			// Update session if its close to expiring.
100
-			if ( time() > $this->_session_expiring ) {
101
-				$this->set_session_expiration();
102
-				$this->update_session_timestamp( $this->_customer_id, $this->_session_expiration );
103
-			}
104
-		} else {
105
-			$this->set_session_expiration();
106
-			$this->_customer_id = $this->generate_customer_id();
107
-			$this->_data        = $this->get_session_data();
108
-		}
109
-	}
110
-
111
-	/**
112
-	 * Sets the session cookie on-demand (usually after adding an item to the cart).
113
-	 *
114
-	 * Since the cookie name (as of 2.1) is prepended with wp, cache systems like batcache will not cache pages when set.
115
-	 *
116
-	 * Warning: Cookies will only be set if this is called before the headers are sent.
117
-	 *
118
-	 * @param bool $set Should the session cookie be set.
119
-	 */
120
-	public function set_customer_session_cookie( $set ) {
121
-		if ( $set ) {
122
-			$to_hash           = $this->_customer_id . '|' . $this->_session_expiration;
123
-			$cookie_hash       = hash_hmac( 'md5', $to_hash, wp_hash( $to_hash ) );
124
-			$cookie_value      = $this->_customer_id . '||' . $this->_session_expiration . '||' . $this->_session_expiring . '||' . $cookie_hash;
125
-			$this->_has_cookie = true;
126
-
127
-			if ( ! isset( $_COOKIE[ $this->_cookie ] ) || $_COOKIE[ $this->_cookie ] !== $cookie_value ) {
128
-				$this->setcookie( $this->_cookie, $cookie_value, $this->_session_expiration, $this->use_secure_cookie(), true );
129
-			}
130
-		}
131
-	}
132
-
133
-	public function setcookie($name, $value, $expire = 0, $secure = false, $httponly = false){
57
+        add_action( 'wp_logout', array( $this, 'destroy_session' ) );
58
+        add_action( 'wp', array( $this, 'set_customer_session_cookie' ), 10 );
59
+        add_action( 'shutdown', array( $this, 'save_data' ), 20 );
60
+
61
+    }
62
+
63
+    /**
64
+     * Init hooks and session data.
65
+     *
66
+     * @since 3.3.0
67
+     */
68
+    public function init() {
69
+        $this->init_session_cookie();
70
+
71
+        if ( ! is_user_logged_in() ) {
72
+            add_filter( 'nonce_user_logged_out', array( $this, 'nonce_user_logged_out' ), 10, 2 );
73
+        }
74
+    }
75
+
76
+    /**
77
+     * Setup cookie and customer ID.
78
+     *
79
+     * @since 3.6.0
80
+     */
81
+    public function init_session_cookie() {
82
+        $cookie = $this->get_session_cookie();
83
+
84
+        if ( $cookie ) {
85
+            $this->_customer_id        = $cookie[0];
86
+            $this->_session_expiration = $cookie[1];
87
+            $this->_session_expiring   = $cookie[2];
88
+            $this->_has_cookie         = true;
89
+            $this->_data               = $this->get_session_data();
90
+
91
+            // If the user logs in, update session.
92
+            if ( is_user_logged_in() && get_current_user_id() != $this->_customer_id ) {
93
+                $this->_customer_id = get_current_user_id();
94
+                $this->_dirty       = true;
95
+                $this->save_data();
96
+                $this->set_customer_session_cookie( true );
97
+            }
98
+
99
+            // Update session if its close to expiring.
100
+            if ( time() > $this->_session_expiring ) {
101
+                $this->set_session_expiration();
102
+                $this->update_session_timestamp( $this->_customer_id, $this->_session_expiration );
103
+            }
104
+        } else {
105
+            $this->set_session_expiration();
106
+            $this->_customer_id = $this->generate_customer_id();
107
+            $this->_data        = $this->get_session_data();
108
+        }
109
+    }
110
+
111
+    /**
112
+     * Sets the session cookie on-demand (usually after adding an item to the cart).
113
+     *
114
+     * Since the cookie name (as of 2.1) is prepended with wp, cache systems like batcache will not cache pages when set.
115
+     *
116
+     * Warning: Cookies will only be set if this is called before the headers are sent.
117
+     *
118
+     * @param bool $set Should the session cookie be set.
119
+     */
120
+    public function set_customer_session_cookie( $set ) {
121
+        if ( $set ) {
122
+            $to_hash           = $this->_customer_id . '|' . $this->_session_expiration;
123
+            $cookie_hash       = hash_hmac( 'md5', $to_hash, wp_hash( $to_hash ) );
124
+            $cookie_value      = $this->_customer_id . '||' . $this->_session_expiration . '||' . $this->_session_expiring . '||' . $cookie_hash;
125
+            $this->_has_cookie = true;
126
+
127
+            if ( ! isset( $_COOKIE[ $this->_cookie ] ) || $_COOKIE[ $this->_cookie ] !== $cookie_value ) {
128
+                $this->setcookie( $this->_cookie, $cookie_value, $this->_session_expiration, $this->use_secure_cookie(), true );
129
+            }
130
+        }
131
+    }
132
+
133
+    public function setcookie($name, $value, $expire = 0, $secure = false, $httponly = false){
134 134
         if ( ! headers_sent() ) {
135 135
             setcookie( $name, $value, $expire, COOKIEPATH ? COOKIEPATH : '/', COOKIE_DOMAIN, $secure, apply_filters( 'wpinv_cookie_httponly', $httponly, $name, $value, $expire, $secure ) );
136 136
         } elseif ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
@@ -139,86 +139,86 @@  discard block
 block discarded – undo
139 139
         }
140 140
     }
141 141
 
142
-	/**
143
-	 * Should the session cookie be secure?
144
-	 *
145
-	 * @since 3.6.0
146
-	 * @return bool
147
-	 */
148
-	protected function use_secure_cookie() {
142
+    /**
143
+     * Should the session cookie be secure?
144
+     *
145
+     * @since 3.6.0
146
+     * @return bool
147
+     */
148
+    protected function use_secure_cookie() {
149 149
         $is_https = false !== strstr( get_option( 'home' ), 'https:' );
150
-		return apply_filters( 'wpinv_session_use_secure_cookie', $is_https && is_ssl() );
151
-	}
152
-
153
-	/**
154
-	 * Return true if the current user has an active session, i.e. a cookie to retrieve values.
155
-	 *
156
-	 * @return bool
157
-	 */
158
-	public function has_session() {
159
-		return isset( $_COOKIE[ $this->_cookie ] ) || $this->_has_cookie || is_user_logged_in(); // @codingStandardsIgnoreLine.
160
-	}
161
-
162
-	/**
163
-	 * Set session expiration.
164
-	 */
165
-	public function set_session_expiration() {
166
-		$this->_session_expiring   = time() + intval( apply_filters( 'wpinv_session_expiring', 60 * 60 * 47 ) ); // 47 Hours.
167
-		$this->_session_expiration = time() + intval( apply_filters( 'wpinv_session_expiration', 60 * 60 * 48 ) ); // 48 Hours.
168
-	}
169
-
170
-	/**
171
-	 * Generates session ids.
172
-	 *
173
-	 * @return string
174
-	 */
175
-	public function generate_customer_id() {
176
-		require_once ABSPATH . 'wp-includes/class-phpass.php';
177
-		$hasher      = new PasswordHash( 8, false );
178
-		return md5( $hasher->get_random_bytes( 32 ) );
179
-	}
180
-
181
-	/**
182
-	 * Get the session cookie, if set. Otherwise return false.
183
-	 *
184
-	 * Session cookies without a customer ID are invalid.
185
-	 *
186
-	 * @return bool|array
187
-	 */
188
-	public function get_session_cookie() {
189
-		$cookie_value = isset( $_COOKIE[ $this->_cookie ] ) ? wp_unslash( $_COOKIE[ $this->_cookie ] ) : false; // @codingStandardsIgnoreLine.
190
-
191
-		if ( empty( $cookie_value ) || ! is_string( $cookie_value ) ) {
192
-			return false;
193
-		}
194
-
195
-		list( $customer_id, $session_expiration, $session_expiring, $cookie_hash ) = explode( '||', $cookie_value );
196
-
197
-		if ( empty( $customer_id ) ) {
198
-			return false;
199
-		}
200
-
201
-		// Validate hash.
202
-		$to_hash = $customer_id . '|' . $session_expiration;
203
-		$hash    = hash_hmac( 'md5', $to_hash, wp_hash( $to_hash ) );
204
-
205
-		if ( empty( $cookie_hash ) || ! hash_equals( $hash, $cookie_hash ) ) {
206
-			return false;
207
-		}
208
-
209
-		return array( $customer_id, $session_expiration, $session_expiring, $cookie_hash );
210
-	}
211
-
212
-	/**
213
-	 * Get session data.
214
-	 *
215
-	 * @return array
216
-	 */
217
-	public function get_session_data() {
218
-		return $this->has_session() ? (array) $this->get_session( $this->_customer_id ) : array();
219
-	}
220
-
221
-	public function generate_key($customer_id){
150
+        return apply_filters( 'wpinv_session_use_secure_cookie', $is_https && is_ssl() );
151
+    }
152
+
153
+    /**
154
+     * Return true if the current user has an active session, i.e. a cookie to retrieve values.
155
+     *
156
+     * @return bool
157
+     */
158
+    public function has_session() {
159
+        return isset( $_COOKIE[ $this->_cookie ] ) || $this->_has_cookie || is_user_logged_in(); // @codingStandardsIgnoreLine.
160
+    }
161
+
162
+    /**
163
+     * Set session expiration.
164
+     */
165
+    public function set_session_expiration() {
166
+        $this->_session_expiring   = time() + intval( apply_filters( 'wpinv_session_expiring', 60 * 60 * 47 ) ); // 47 Hours.
167
+        $this->_session_expiration = time() + intval( apply_filters( 'wpinv_session_expiration', 60 * 60 * 48 ) ); // 48 Hours.
168
+    }
169
+
170
+    /**
171
+     * Generates session ids.
172
+     *
173
+     * @return string
174
+     */
175
+    public function generate_customer_id() {
176
+        require_once ABSPATH . 'wp-includes/class-phpass.php';
177
+        $hasher      = new PasswordHash( 8, false );
178
+        return md5( $hasher->get_random_bytes( 32 ) );
179
+    }
180
+
181
+    /**
182
+     * Get the session cookie, if set. Otherwise return false.
183
+     *
184
+     * Session cookies without a customer ID are invalid.
185
+     *
186
+     * @return bool|array
187
+     */
188
+    public function get_session_cookie() {
189
+        $cookie_value = isset( $_COOKIE[ $this->_cookie ] ) ? wp_unslash( $_COOKIE[ $this->_cookie ] ) : false; // @codingStandardsIgnoreLine.
190
+
191
+        if ( empty( $cookie_value ) || ! is_string( $cookie_value ) ) {
192
+            return false;
193
+        }
194
+
195
+        list( $customer_id, $session_expiration, $session_expiring, $cookie_hash ) = explode( '||', $cookie_value );
196
+
197
+        if ( empty( $customer_id ) ) {
198
+            return false;
199
+        }
200
+
201
+        // Validate hash.
202
+        $to_hash = $customer_id . '|' . $session_expiration;
203
+        $hash    = hash_hmac( 'md5', $to_hash, wp_hash( $to_hash ) );
204
+
205
+        if ( empty( $cookie_hash ) || ! hash_equals( $hash, $cookie_hash ) ) {
206
+            return false;
207
+        }
208
+
209
+        return array( $customer_id, $session_expiration, $session_expiring, $cookie_hash );
210
+    }
211
+
212
+    /**
213
+     * Get session data.
214
+     *
215
+     * @return array
216
+     */
217
+    public function get_session_data() {
218
+        return $this->has_session() ? (array) $this->get_session( $this->_customer_id ) : array();
219
+    }
220
+
221
+    public function generate_key($customer_id){
222 222
         if(!$customer_id){
223 223
             return;
224 224
         }
@@ -226,68 +226,68 @@  discard block
 block discarded – undo
226 226
         return 'wpi_trans_'.$customer_id;
227 227
     }
228 228
 
229
-	/**
230
-	 * Save data.
231
-	 */
232
-	public function save_data() {
233
-		// Dirty if something changed - prevents saving nothing new.
234
-		if ( $this->_dirty && $this->has_session() ) {
229
+    /**
230
+     * Save data.
231
+     */
232
+    public function save_data() {
233
+        // Dirty if something changed - prevents saving nothing new.
234
+        if ( $this->_dirty && $this->has_session() ) {
235 235
 
236 236
             set_transient( $this->generate_key($this->_customer_id), $this->_data, $this->_session_expiration);
237 237
 
238
-			$this->_dirty = false;
239
-		}
240
-	}
241
-
242
-	/**
243
-	 * Destroy all session data.
244
-	 */
245
-	public function destroy_session() {
246
-		$this->delete_session( $this->_customer_id );
247
-		$this->forget_session();
248
-	}
249
-
250
-	/**
251
-	 * Forget all session data without destroying it.
252
-	 */
253
-	public function forget_session() {
254
-		$this->setcookie( $this->_cookie, '', time() - YEAR_IN_SECONDS, $this->use_secure_cookie(), true );
255
-
256
-		wpinv_empty_cart();
257
-
258
-		$this->_data        = array();
259
-		$this->_dirty       = false;
260
-		$this->_customer_id = $this->generate_customer_id();
261
-	}
262
-
263
-	/**
264
-	 * When a user is logged out, ensure they have a unique nonce by using the customer/session ID.
265
-	 *
266
-	 * @param int $uid User ID.
267
-	 * @return string
268
-	 */
269
-	public function nonce_user_logged_out( $uid ) {
270
-
271
-		// Check if one of our nonces.
272
-		if ( substr( $uid, 0, 5 ) === 'wpinv' || substr( $uid, 0, 7 ) === 'getpaid' ) {
273
-			return $this->has_session() && $this->_customer_id ? $this->_customer_id : $uid;
274
-		}
275
-
276
-		return $uid;
277
-	}
278
-
279
-	/**
280
-	 * Returns the session.
281
-	 *
282
-	 * @param string $customer_id Customer ID.
283
-	 * @param mixed  $default Default session value.
284
-	 * @return string|array
285
-	 */
286
-	public function get_session( $customer_id, $default = false ) {
287
-
288
-		if ( defined( 'WP_SETUP_CONFIG' ) ) {
289
-			return array();
290
-		}
238
+            $this->_dirty = false;
239
+        }
240
+    }
241
+
242
+    /**
243
+     * Destroy all session data.
244
+     */
245
+    public function destroy_session() {
246
+        $this->delete_session( $this->_customer_id );
247
+        $this->forget_session();
248
+    }
249
+
250
+    /**
251
+     * Forget all session data without destroying it.
252
+     */
253
+    public function forget_session() {
254
+        $this->setcookie( $this->_cookie, '', time() - YEAR_IN_SECONDS, $this->use_secure_cookie(), true );
255
+
256
+        wpinv_empty_cart();
257
+
258
+        $this->_data        = array();
259
+        $this->_dirty       = false;
260
+        $this->_customer_id = $this->generate_customer_id();
261
+    }
262
+
263
+    /**
264
+     * When a user is logged out, ensure they have a unique nonce by using the customer/session ID.
265
+     *
266
+     * @param int $uid User ID.
267
+     * @return string
268
+     */
269
+    public function nonce_user_logged_out( $uid ) {
270
+
271
+        // Check if one of our nonces.
272
+        if ( substr( $uid, 0, 5 ) === 'wpinv' || substr( $uid, 0, 7 ) === 'getpaid' ) {
273
+            return $this->has_session() && $this->_customer_id ? $this->_customer_id : $uid;
274
+        }
275
+
276
+        return $uid;
277
+    }
278
+
279
+    /**
280
+     * Returns the session.
281
+     *
282
+     * @param string $customer_id Customer ID.
283
+     * @param mixed  $default Default session value.
284
+     * @return string|array
285
+     */
286
+    public function get_session( $customer_id, $default = false ) {
287
+
288
+        if ( defined( 'WP_SETUP_CONFIG' ) ) {
289
+            return array();
290
+        }
291 291
 
292 292
         $key = $this->generate_key($customer_id);
293 293
         $value = get_transient($key);
@@ -296,30 +296,30 @@  discard block
 block discarded – undo
296 296
             $value = $default;
297 297
         }
298 298
 
299
-		return maybe_unserialize( $value );
300
-	}
299
+        return maybe_unserialize( $value );
300
+    }
301 301
 
302
-	/**
303
-	 * Delete the session from the cache and database.
304
-	 *
305
-	 * @param int $customer_id Customer ID.
306
-	 */
307
-	public function delete_session( $customer_id ) {
302
+    /**
303
+     * Delete the session from the cache and database.
304
+     *
305
+     * @param int $customer_id Customer ID.
306
+     */
307
+    public function delete_session( $customer_id ) {
308 308
 
309 309
         $key = $this->generate_key($customer_id);
310 310
 
311
-		delete_transient($key);
312
-	}
311
+        delete_transient($key);
312
+    }
313 313
 
314
-	/**
315
-	 * Update the session expiry timestamp.
316
-	 *
317
-	 * @param string $customer_id Customer ID.
318
-	 * @param int    $timestamp Timestamp to expire the cookie.
319
-	 */
320
-	public function update_session_timestamp( $customer_id, $timestamp ) {
314
+    /**
315
+     * Update the session expiry timestamp.
316
+     *
317
+     * @param string $customer_id Customer ID.
318
+     * @param int    $timestamp Timestamp to expire the cookie.
319
+     */
320
+    public function update_session_timestamp( $customer_id, $timestamp ) {
321 321
 
322 322
         set_transient( $this->generate_key($customer_id), maybe_serialize( $this->_data ), $timestamp);
323 323
 
324
-	}
324
+    }
325 325
 }
Please login to merge, or discard this patch.
templates/subscriptions/subscription-details.php 1 patch
Indentation   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -43,64 +43,64 @@  discard block
 block discarded – undo
43 43
 				<td class="w-75">
44 44
 					<?php
45 45
 
46
-						switch ( $key ) {
46
+                        switch ( $key ) {
47 47
 
48
-							case 'status':
49
-								echo sanitize_text_field( $subscription->get_status_label() );
50
-								break;
48
+                            case 'status':
49
+                                echo sanitize_text_field( $subscription->get_status_label() );
50
+                                break;
51 51
 
52
-							case 'start_date':
53
-								echo sanitize_text_field( getpaid_format_date_value( $subscription->get_date_created() ) );
54
-								break;
52
+                            case 'start_date':
53
+                                echo sanitize_text_field( getpaid_format_date_value( $subscription->get_date_created() ) );
54
+                                break;
55 55
 
56
-							case 'expiry_date':
57
-								echo sanitize_text_field( getpaid_format_date_value( $subscription->get_next_renewal_date() ) );
58
-								break;
56
+                            case 'expiry_date':
57
+                                echo sanitize_text_field( getpaid_format_date_value( $subscription->get_next_renewal_date() ) );
58
+                                break;
59 59
 
60
-							case 'initial_amount':
61
-								echo wpinv_price( $subscription->get_initial_amount(), $subscription->get_parent_payment()->get_currency() );
60
+                            case 'initial_amount':
61
+                                echo wpinv_price( $subscription->get_initial_amount(), $subscription->get_parent_payment()->get_currency() );
62 62
 
63
-								if ( $subscription->has_trial_period() ) {
63
+                                if ( $subscription->has_trial_period() ) {
64 64
 
65
-									echo "<small class='text-muted'>&nbsp;";
66
-									printf(
67
-										_x( '( %1$s trial )', 'Subscription trial period. (e.g.: 1 month trial)', 'invoicing' ),
68
-										sanitize_text_field( $subscription->get_trial_period() )
69
-									);
70
-									echo '</small>';
65
+                                    echo "<small class='text-muted'>&nbsp;";
66
+                                    printf(
67
+                                        _x( '( %1$s trial )', 'Subscription trial period. (e.g.: 1 month trial)', 'invoicing' ),
68
+                                        sanitize_text_field( $subscription->get_trial_period() )
69
+                                    );
70
+                                    echo '</small>';
71 71
 
72
-								}
72
+                                }
73 73
 								
74
-								break;
74
+                                break;
75 75
 
76
-							case 'recurring_amount':
77
-								$frequency = getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' );
78
-								$amount    = wpinv_price( $subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency() );
79
-								echo strtolower( "<strong style='font-weight: 500;'>$amount</strong> / <span class='getpaid-item-recurring-period'>$frequency</span>" );
80
-								break;
76
+                            case 'recurring_amount':
77
+                                $frequency = getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' );
78
+                                $amount    = wpinv_price( $subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency() );
79
+                                echo strtolower( "<strong style='font-weight: 500;'>$amount</strong> / <span class='getpaid-item-recurring-period'>$frequency</span>" );
80
+                                break;
81 81
 
82
-							case 'item':
83
-								$item = get_post( $subscription->get_product_id() );
82
+                            case 'item':
83
+                                $item = get_post( $subscription->get_product_id() );
84 84
 
85
-								if ( ! empty( $item ) ) {
86
-									echo esc_html( get_the_title( $item ) );
87
-								} else {
88
-									echo sprintf( __( 'Item #%s', 'invoicing' ), $subscription->get_product_id() );
89
-								}
85
+                                if ( ! empty( $item ) ) {
86
+                                    echo esc_html( get_the_title( $item ) );
87
+                                } else {
88
+                                    echo sprintf( __( 'Item #%s', 'invoicing' ), $subscription->get_product_id() );
89
+                                }
90 90
 
91
-								break;
91
+                                break;
92 92
 
93
-							case 'payments':
93
+                            case 'payments':
94 94
 
95
-								$max_activations = (int) $subscription->get_bill_times();
96
-								echo (int) $subscription->get_times_billed() . ' / ' . ( empty( $max_activations ) ? "&infin;" : $max_activations );
95
+                                $max_activations = (int) $subscription->get_bill_times();
96
+                                echo (int) $subscription->get_times_billed() . ' / ' . ( empty( $max_activations ) ? "&infin;" : $max_activations );
97 97
 
98
-								break;
98
+                                break;
99 99
 
100
-						}
101
-						do_action( "getpaid_render_single_subscription_column_$key", $subscription );
100
+                        }
101
+                        do_action( "getpaid_render_single_subscription_column_$key", $subscription );
102 102
 
103
-					?>
103
+                    ?>
104 104
 				</td>
105 105
 
106 106
 			</tr>
@@ -117,17 +117,17 @@  discard block
 block discarded – undo
117 117
 <span class="form-text">
118 118
 
119 119
 	<?php
120
-		if ( $subscription->can_cancel() ) {
121
-			printf(
122
-				'<a href="%s" class="btn btn-danger btn-sm" onclick="return confirm(\'%s\')">%s</a>&nbsp;&nbsp;',
123
-				esc_url( $subscription->get_cancel_url() ),
124
-				esc_attr__( 'Are you sure you want to cancel this subscription?', 'invoicing' ),
125
-				__( 'Cancel Subscription', 'invoicing' )
126
-			);
127
-		}
128
-
129
-		do_action( 'getpaid-single-subscription-page-actions', $subscription );
130
-	?>
120
+        if ( $subscription->can_cancel() ) {
121
+            printf(
122
+                '<a href="%s" class="btn btn-danger btn-sm" onclick="return confirm(\'%s\')">%s</a>&nbsp;&nbsp;',
123
+                esc_url( $subscription->get_cancel_url() ),
124
+                esc_attr__( 'Are you sure you want to cancel this subscription?', 'invoicing' ),
125
+                __( 'Cancel Subscription', 'invoicing' )
126
+            );
127
+        }
128
+
129
+        do_action( 'getpaid-single-subscription-page-actions', $subscription );
130
+    ?>
131 131
 
132 132
 	<a href="<?php echo esc_url( getpaid_get_tab_url( 'gp-subscriptions', get_permalink( (int) wpinv_get_option( 'invoice_subscription_page' ) ) ) ); ?>" class="btn btn-secondary btn-sm"><?php _e( 'Go Back', 'invoicing' ); ?></a>
133 133
 </span>
134 134
\ No newline at end of file
Please login to merge, or discard this patch.
templates/subscriptions/subscriptions-table-row.php 1 patch
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -13,42 +13,42 @@
 block discarded – undo
13 13
 
14 14
 foreach ( array_keys( $widget->get_subscriptions_table_columns() ) as $column ) :
15 15
 
16
-	$class = sanitize_html_class( $column );
17
-	echo "<td class='getpaid-subscriptions-table-column-$class'>";
16
+    $class = sanitize_html_class( $column );
17
+    echo "<td class='getpaid-subscriptions-table-column-$class'>";
18 18
 
19
-		do_action( "getpaid_subscriptions_before_frontend_subscription_table_$column", $subscription );
19
+        do_action( "getpaid_subscriptions_before_frontend_subscription_table_$column", $subscription );
20 20
 
21
-		switch( $column ) :
21
+        switch( $column ) :
22 22
 
23
-			case 'subscription':
24
-				$subscription_id = (int) $subscription->get_id();
25
-				$url             = esc_url( $subscription->get_view_url() );
26
-				$id_label        = sprintf(
27
-					esc_attr_x( '#%s', 'subscription id', 'invoicing' ),
28
-					$subscription->get_id()
29
-				);
30
-				echo $widget->add_row_actions( "<a href='$url' class='font-weight-bold text-decoration-none'>$id_label</a>", $subscription );
31
-				break;
23
+            case 'subscription':
24
+                $subscription_id = (int) $subscription->get_id();
25
+                $url             = esc_url( $subscription->get_view_url() );
26
+                $id_label        = sprintf(
27
+                    esc_attr_x( '#%s', 'subscription id', 'invoicing' ),
28
+                    $subscription->get_id()
29
+                );
30
+                echo $widget->add_row_actions( "<a href='$url' class='font-weight-bold text-decoration-none'>$id_label</a>", $subscription );
31
+                break;
32 32
 
33
-			case 'status':
34
-				echo sanitize_text_field( $subscription->get_status_label() );
35
-				break;
33
+            case 'status':
34
+                echo sanitize_text_field( $subscription->get_status_label() );
35
+                break;
36 36
 
37
-			case 'renewal-date':
38
-				$renewal = getpaid_format_date_value( $subscription->get_next_renewal_date() );
39
-				echo $subscription->is_active() ? sanitize_text_field( $renewal ) : "&mdash;";
40
-				break;
37
+            case 'renewal-date':
38
+                $renewal = getpaid_format_date_value( $subscription->get_next_renewal_date() );
39
+                echo $subscription->is_active() ? sanitize_text_field( $renewal ) : "&mdash;";
40
+                break;
41 41
 
42
-			case 'amount':
43
-				$frequency = getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' );
44
-				$amount    = wpinv_price( $subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency() );
45
-				echo wp_kses_post( "<span>$amount</span> / <span class='getpaid-item-recurring-period'>$frequency</span>" );
46
-				break;
42
+            case 'amount':
43
+                $frequency = getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' );
44
+                $amount    = wpinv_price( $subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency() );
45
+                echo wp_kses_post( "<span>$amount</span> / <span class='getpaid-item-recurring-period'>$frequency</span>" );
46
+                break;
47 47
 
48
-		endswitch;
48
+        endswitch;
49 49
 
50
-		do_action( "getpaid_subscriptions_frontend_subscription_table_$column", $subscription );
50
+        do_action( "getpaid_subscriptions_frontend_subscription_table_$column", $subscription );
51 51
 
52
-	echo '</td>';
52
+    echo '</td>';
53 53
 
54 54
 endforeach;
Please login to merge, or discard this patch.
includes/class-getpaid-template.php 1 patch
Indentation   +90 added lines, -90 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if ( ! defined( 'ABSPATH' ) ) {
3
-	exit;
3
+    exit;
4 4
 }
5 5
 
6 6
 /**
@@ -20,23 +20,23 @@  discard block
 block discarded – undo
20 20
     public $templates_url;
21 21
 
22 22
     /**
23
-	 * Class constructor.
24
-	 *
25
-	 * @since 1.0.19
26
-	 */
27
-	public function __construct() {
23
+     * Class constructor.
24
+     *
25
+     * @since 1.0.19
26
+     */
27
+    public function __construct() {
28 28
 
29 29
         $this->templates_dir = apply_filters( 'getpaid_default_templates_dir', WPINV_PLUGIN_DIR . 'templates' );
30 30
         $this->templates_url = apply_filters( 'getpaid_default_templates_url', WPINV_PLUGIN_URL . 'templates' );
31 31
     }
32 32
 
33 33
     /**
34
-	 * Checks if this is a preview page
35
-	 *
36
-	 * @since 1.0.19
37
-	 * @return bool
38
-	 */
39
-	public function is_preview() {
34
+     * Checks if this is a preview page
35
+     *
36
+     * @since 1.0.19
37
+     * @return bool
38
+     */
39
+    public function is_preview() {
40 40
         return 
41 41
             $this->is_divi_preview() ||
42 42
             $this->is_elementor_preview() ||
@@ -48,73 +48,73 @@  discard block
 block discarded – undo
48 48
     }
49 49
 
50 50
     /**
51
-	 * Checks if this is an elementor preview page
52
-	 *
53
-	 * @since 1.0.19
54
-	 * @return bool
55
-	 */
56
-	public function is_elementor_preview() {
57
-		return isset( $_REQUEST['elementor-preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) || ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor_ajax' );
58
-	}
59
-
60
-	/**
61
-	 * Checks if this is a DIVI preview page
62
-	 *
63
-	 * @since 1.0.19
64
-	 * @return bool
65
-	 */
66
-	public function is_divi_preview() {
67
-		return isset( $_REQUEST['et_fb'] ) || isset( $_REQUEST['et_pb_preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'et_pb' );
68
-	}
69
-
70
-	/**
71
-	 * Checks if this is a beaver builder preview page
72
-	 *
73
-	 * @since 1.0.19
74
-	 * @return bool
75
-	 */
76
-	public function is_beaver_preview() {
77
-		return isset( $_REQUEST['fl_builder'] );
78
-	}
79
-
80
-	/**
81
-	 * Checks if this is a siteorigin builder preview page
82
-	 *
83
-	 * @since 1.0.19
84
-	 * @return bool
85
-	 */
86
-	public function is_siteorigin_preview() {
87
-		return ! empty( $_REQUEST['siteorigin_panels_live_editor'] );
88
-	}
89
-
90
-	/**
91
-	 * Checks if this is a cornerstone builder preview page
92
-	 *
93
-	 * @since 1.0.19
94
-	 * @return bool
95
-	 */
96
-	public function is_cornerstone_preview() {
97
-		return ! empty( $_REQUEST['cornerstone_preview'] ) || basename( $_SERVER['REQUEST_URI'] ) == 'cornerstone-endpoint';
98
-	}
99
-
100
-	/**
101
-	 * Checks if this is a fusion builder preview page
102
-	 *
103
-	 * @since 1.0.19
104
-	 * @return bool
105
-	 */
106
-	public function is_fusion_preview() {
107
-		return ! empty( $_REQUEST['fb-edit'] ) || ! empty( $_REQUEST['fusion_load_nonce'] );
108
-	}
109
-
110
-	/**
111
-	 * Checks if this is an oxygen builder preview page
112
-	 *
113
-	 * @since 1.0.19
114
-	 * @return bool
115
-	 */
116
-	public function is_oxygen_preview() {
117
-		return ! empty( $_REQUEST['ct_builder'] ) || ( ! empty( $_REQUEST['action'] ) && ( substr( $_REQUEST['action'], 0, 11 ) === "oxy_render_" || substr( $_REQUEST['action'], 0, 10 ) === "ct_render_" ) );
51
+     * Checks if this is an elementor preview page
52
+     *
53
+     * @since 1.0.19
54
+     * @return bool
55
+     */
56
+    public function is_elementor_preview() {
57
+        return isset( $_REQUEST['elementor-preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) || ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor_ajax' );
58
+    }
59
+
60
+    /**
61
+     * Checks if this is a DIVI preview page
62
+     *
63
+     * @since 1.0.19
64
+     * @return bool
65
+     */
66
+    public function is_divi_preview() {
67
+        return isset( $_REQUEST['et_fb'] ) || isset( $_REQUEST['et_pb_preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'et_pb' );
68
+    }
69
+
70
+    /**
71
+     * Checks if this is a beaver builder preview page
72
+     *
73
+     * @since 1.0.19
74
+     * @return bool
75
+     */
76
+    public function is_beaver_preview() {
77
+        return isset( $_REQUEST['fl_builder'] );
78
+    }
79
+
80
+    /**
81
+     * Checks if this is a siteorigin builder preview page
82
+     *
83
+     * @since 1.0.19
84
+     * @return bool
85
+     */
86
+    public function is_siteorigin_preview() {
87
+        return ! empty( $_REQUEST['siteorigin_panels_live_editor'] );
88
+    }
89
+
90
+    /**
91
+     * Checks if this is a cornerstone builder preview page
92
+     *
93
+     * @since 1.0.19
94
+     * @return bool
95
+     */
96
+    public function is_cornerstone_preview() {
97
+        return ! empty( $_REQUEST['cornerstone_preview'] ) || basename( $_SERVER['REQUEST_URI'] ) == 'cornerstone-endpoint';
98
+    }
99
+
100
+    /**
101
+     * Checks if this is a fusion builder preview page
102
+     *
103
+     * @since 1.0.19
104
+     * @return bool
105
+     */
106
+    public function is_fusion_preview() {
107
+        return ! empty( $_REQUEST['fb-edit'] ) || ! empty( $_REQUEST['fusion_load_nonce'] );
108
+    }
109
+
110
+    /**
111
+     * Checks if this is an oxygen builder preview page
112
+     *
113
+     * @since 1.0.19
114
+     * @return bool
115
+     */
116
+    public function is_oxygen_preview() {
117
+        return ! empty( $_REQUEST['ct_builder'] ) || ( ! empty( $_REQUEST['action'] ) && ( substr( $_REQUEST['action'], 0, 11 ) === "oxy_render_" || substr( $_REQUEST['action'], 0, 10 ) === "ct_render_" ) );
118 118
     }
119 119
 
120 120
     /**
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
      * @param string $template_path The template path relative to the theme's root dir. Defaults to 'invoicing'.
125 125
      * @param string $default_path The root path to the default template. Defaults to invoicing/templates
126 126
      */
127
-	public function locate_template( $template_name, $template_path = '', $default_path = '' ) {
127
+    public function locate_template( $template_name, $template_path = '', $default_path = '' ) {
128 128
 
129 129
         // Load the defaults for the template path and default path.
130 130
         $template_path = empty( $template_path ) ? 'invoicing' : $template_path;
@@ -145,22 +145,22 @@  discard block
 block discarded – undo
145 145
     }
146 146
     
147 147
     /**
148
-	 * Loads a template
149
-	 *
150
-	 * @since 1.0.19
151
-	 * @return bool
152
-	 */
153
-	protected function load_template( $template_name, $template_path, $args ) {
148
+     * Loads a template
149
+     *
150
+     * @since 1.0.19
151
+     * @return bool
152
+     */
153
+    protected function load_template( $template_name, $template_path, $args ) {
154 154
 
155 155
         if ( is_array( $args ) ){
156 156
             extract( $args );
157 157
         }
158 158
 
159 159
         // Fires before loading a template.
160
-	    do_action( 'wpinv_before_template_part', $template_name, $template_path, $args );
160
+        do_action( 'wpinv_before_template_part', $template_name, $template_path, $args );
161 161
 
162 162
         // Load the template.
163
-	    include( $template_path );
163
+        include( $template_path );
164 164
 
165 165
         // Fires after loading a template.
166 166
         do_action( 'wpinv_after_template_part', $template_name, $template_path, $args );
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
      * @param string $template_path The templates directory relative to the theme's root dir. Defaults to 'invoicing'.
178 178
      * @param string $default_path The root path to the default template. Defaults to invoicing/templates
179 179
      */
180
-	public function display_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
180
+    public function display_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
181 181
 
182 182
         // Locate the template.
183 183
         $located = $this->locate_template( $template_name, $template_path, $default_path );
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
      * @param string $template_path The templates directory relative to the theme's root dir. Defaults to 'invoicing'.
203 203
      * @param string $default_path The root path to the default template. Defaults to invoicing/templates
204 204
      */
205
-	public function get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
205
+    public function get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
206 206
         ob_start();
207 207
         $this->display_template( $template_name, $args, $template_path, $default_path );
208 208
         return ob_get_clean();
Please login to merge, or discard this patch.
templates/payment-forms/cart-totals.php 1 patch
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -11,26 +11,26 @@  discard block
 block discarded – undo
11 11
 
12 12
 // Totals rows.
13 13
 $totals = apply_filters(
14
-	'getpaid_payment_form_cart_table_totals',
15
-	array(
16
-		'subtotal' => __( 'Subtotal', 'invoicing' ),
17
-		'tax'      => __( 'Tax', 'invoicing' ),
18
-		'fees'     => __( 'Fee', 'invoicing' ),
19
-		'discount' => __( 'Discount', 'invoicing' ),
20
-		'total'    => __( 'Total', 'invoicing' ),
21
-	),
22
-	$form
14
+    'getpaid_payment_form_cart_table_totals',
15
+    array(
16
+        'subtotal' => __( 'Subtotal', 'invoicing' ),
17
+        'tax'      => __( 'Tax', 'invoicing' ),
18
+        'fees'     => __( 'Fee', 'invoicing' ),
19
+        'discount' => __( 'Discount', 'invoicing' ),
20
+        'total'    => __( 'Total', 'invoicing' ),
21
+    ),
22
+    $form
23 23
 );
24 24
 
25 25
 $currency = $form->get_currency();
26 26
 $country  = wpinv_get_default_country();
27 27
 
28 28
 if ( ! empty( $form->invoice ) ) {
29
-	$country  = $form->invoice->get_country();
29
+    $country  = $form->invoice->get_country();
30 30
 }
31 31
 
32 32
 if ( ! wpinv_use_taxes() && isset( $totals['tax'] ) ) {
33
-	unset( $totals['tax'] );
33
+    unset( $totals['tax'] );
34 34
 }
35 35
 
36 36
 do_action( 'getpaid_before_payment_form_cart_totals', $form, $totals );
@@ -61,13 +61,13 @@  discard block
 block discarded – undo
61 61
 
62 62
 							<?php
63 63
 
64
-								// Total tax.
65
-								if ( in_array( $key, array( 'tax', 'discount', 'subtotal', 'total', 'fees' ) ) ) {
66
-									echo wpinv_price( 0, $currency );
67
-								}
64
+                                // Total tax.
65
+                                if ( in_array( $key, array( 'tax', 'discount', 'subtotal', 'total', 'fees' ) ) ) {
66
+                                    echo wpinv_price( 0, $currency );
67
+                                }
68 68
 
69
-								do_action( "getpaid_payment_form_cart_totals_$key", $form );
70
-							?>
69
+                                do_action( "getpaid_payment_form_cart_totals_$key", $form );
70
+                            ?>
71 71
 
72 72
 						</div>
73 73
 
Please login to merge, or discard this patch.
includes/class-wpinv-privacy.php 1 patch
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -37,25 +37,25 @@
 block discarded – undo
37 37
     public function get_privacy_message() {
38 38
 
39 39
         $content = '<div class="wp-suggested-text">' .
40
-                   '<h2>' . __( 'Invoices and checkout', 'invoicing' ) . '</h2>' .
41
-                   '<p class="privacy-policy-tutorial">' . __( 'Example privacy texts.', 'invoicing' ) . '</p>' .
42
-                   '<p>' . __( 'We collect information about you during the checkout process on our site. This information may include, but is not limited to, your name, email address, phone number, address, IP and any other details that might be requested from you for the purpose of processing your payment and retaining your invoice details for legal reasons.', 'invoicing' ) . '</p>' .
43
-                   '<p>' . __( 'Handling this data also allows us to:', 'invoicing' ) . '</p>' .
44
-                   '<ul>' .
45
-                   '<li>' . __( '- Send you important account/invoice/service information.', 'invoicing' ) . '</li>' .
46
-                   '<li>' . __( '- Estimate taxes based on your location.', 'invoicing' ) . '</li>' .
47
-                   '<li>' . __( '- Respond to your queries or complaints.', 'invoicing' ) . '</li>' .
48
-                   '<li>' . __( '- Process payments and to prevent fraudulent transactions. We do this on the basis of our legitimate business interests.', 'invoicing' ) . '</li>' .
49
-                   '<li>' . __( '- Retain historical payment and invoice history. We do this on the basis of legal obligations.', 'invoicing' ) . '</li>' .
50
-                   '<li>' . __( '- Set up and administer your account, provide technical and/or customer support, and to verify your identity. We do this on the basis of our legitimate business interests.', 'invoicing' ) . '</li>' .
51
-                   '</ul>' .
52
-                   '<p>' . __( 'In addition to collecting information at checkout we may also use and store your contact details when manually creating invoices for require payments relating to prior contractual agreements or agreed terms.', 'invoicing' ) . '</p>' .
53
-                   '<h2>' . __( 'What we share with others', 'invoicing' ) . '</h2>' .
54
-                   '<p>' . __( 'We share information with third parties who help us provide our payment and invoicing services to you; for example --', 'invoicing' ) . '</p>' .
55
-                   '<p class="privacy-policy-tutorial">' . __( 'In this subsection you should list which third party payment processors you’re using to take payments since these may handle customer data. We’ve included PayPal as an example, but you should remove this if you’re not using PayPal.', 'invoicing' ) . '</p>' .
56
-                   '<p>' . __( 'We accept payments through PayPal. When processing payments, some of your data will be passed to PayPal, including information required to process or support the payment, such as the purchase total and billing information.', 'invoicing' ) . '</p>' .
57
-                   '<p>' . __( 'Please see the <a href="https://www.paypal.com/us/webapps/mpp/ua/privacy-full">PayPal Privacy Policy</a> for more details.', 'invoicing' ) . '</p>' .
58
-                   '</div>';
40
+                    '<h2>' . __( 'Invoices and checkout', 'invoicing' ) . '</h2>' .
41
+                    '<p class="privacy-policy-tutorial">' . __( 'Example privacy texts.', 'invoicing' ) . '</p>' .
42
+                    '<p>' . __( 'We collect information about you during the checkout process on our site. This information may include, but is not limited to, your name, email address, phone number, address, IP and any other details that might be requested from you for the purpose of processing your payment and retaining your invoice details for legal reasons.', 'invoicing' ) . '</p>' .
43
+                    '<p>' . __( 'Handling this data also allows us to:', 'invoicing' ) . '</p>' .
44
+                    '<ul>' .
45
+                    '<li>' . __( '- Send you important account/invoice/service information.', 'invoicing' ) . '</li>' .
46
+                    '<li>' . __( '- Estimate taxes based on your location.', 'invoicing' ) . '</li>' .
47
+                    '<li>' . __( '- Respond to your queries or complaints.', 'invoicing' ) . '</li>' .
48
+                    '<li>' . __( '- Process payments and to prevent fraudulent transactions. We do this on the basis of our legitimate business interests.', 'invoicing' ) . '</li>' .
49
+                    '<li>' . __( '- Retain historical payment and invoice history. We do this on the basis of legal obligations.', 'invoicing' ) . '</li>' .
50
+                    '<li>' . __( '- Set up and administer your account, provide technical and/or customer support, and to verify your identity. We do this on the basis of our legitimate business interests.', 'invoicing' ) . '</li>' .
51
+                    '</ul>' .
52
+                    '<p>' . __( 'In addition to collecting information at checkout we may also use and store your contact details when manually creating invoices for require payments relating to prior contractual agreements or agreed terms.', 'invoicing' ) . '</p>' .
53
+                    '<h2>' . __( 'What we share with others', 'invoicing' ) . '</h2>' .
54
+                    '<p>' . __( 'We share information with third parties who help us provide our payment and invoicing services to you; for example --', 'invoicing' ) . '</p>' .
55
+                    '<p class="privacy-policy-tutorial">' . __( 'In this subsection you should list which third party payment processors you’re using to take payments since these may handle customer data. We’ve included PayPal as an example, but you should remove this if you’re not using PayPal.', 'invoicing' ) . '</p>' .
56
+                    '<p>' . __( 'We accept payments through PayPal. When processing payments, some of your data will be passed to PayPal, including information required to process or support the payment, such as the purchase total and billing information.', 'invoicing' ) . '</p>' .
57
+                    '<p>' . __( 'Please see the <a href="https://www.paypal.com/us/webapps/mpp/ua/privacy-full">PayPal Privacy Policy</a> for more details.', 'invoicing' ) . '</p>' .
58
+                    '</div>';
59 59
 
60 60
         return apply_filters( 'wpinv_privacy_policy_content', $content );
61 61
     }
Please login to merge, or discard this patch.
includes/payments/class-getpaid-payment-form-submission-fees.php 1 patch
Indentation   +102 added lines, -102 removed lines patch added patch discarded remove patch
@@ -12,109 +12,109 @@
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Payment_Form_Submission_Fees {
14 14
 
15
-	/**
16
-	 * The fee validation error.
17
-	 * @var string
18
-	 */
19
-	public $fee_error;
20
-
21
-	/**
22
-	 * Submission fees.
23
-	 * @var array
24
-	 */
25
-	public $fees = array();
15
+    /**
16
+     * The fee validation error.
17
+     * @var string
18
+     */
19
+    public $fee_error;
20
+
21
+    /**
22
+     * Submission fees.
23
+     * @var array
24
+     */
25
+    public $fees = array();
26
+
27
+    /**
28
+     * Class constructor
29
+     *
30
+     * @param GetPaid_Payment_Form_Submission $submission
31
+     */
32
+    public function __construct( $submission ) {
33
+
34
+        // Process any existing invoice fees.
35
+        if ( $submission->has_invoice() ) {
36
+            $this->fees = $submission->get_invoice()->get_fees();
37
+        }
38
+
39
+        // Process price fields.
40
+        $data         = $submission->get_data();
41
+        $payment_form = $submission->get_payment_form();
42
+
43
+        foreach ( $payment_form->get_elements() as $element ) {
44
+
45
+            if ( 'price_input' == $element['type'] ) {
46
+                $this->process_price_input( $element, $data, $submission );
47
+            }
48
+
49
+            if ( 'price_select' == $element['type'] ) {
50
+                $this->process_price_select( $element, $data );
51
+            }
52
+
53
+        }
54
+
55
+    }
56
+
57
+    /**
58
+     * Process a price input field.
59
+     *
60
+     * @param array $element
61
+     * @param array $data
62
+     * @param GetPaid_Payment_Form_Submission $submission
63
+     */
64
+    public function process_price_input( $element, $data, $submission ) {
65
+
66
+        // Abort if not passed.
67
+        if ( empty( $data[ $element['id'] ] ) ) {
68
+            return;
69
+        }
70
+
71
+        $amount  = (float) wpinv_sanitize_amount( $data[ $element['id'] ] );
72
+        $minimum = empty( $element['minimum'] ) ? 0 : (float) wpinv_sanitize_amount( $element['minimum'] );
73
+
74
+        if ( $amount < $minimum ) {
75
+            throw new Exception( sprintf( __( 'The minimum allowed amount is %s', 'invoicing' ), wpinv_price( $minimum, $submission->get_currency() ) ) );
76
+        }
77
+
78
+        $this->fees[ $element['label'] ] = array(
79
+            'name'          => $element['label'],
80
+            'initial_fee'   => $amount,
81
+            'recurring_fee' => 0,
82
+        );
83
+
84
+    }
26 85
 
27 86
     /**
28
-	 * Class constructor
29
-	 *
30
-	 * @param GetPaid_Payment_Form_Submission $submission
31
-	 */
32
-	public function __construct( $submission ) {
33
-
34
-		// Process any existing invoice fees.
35
-		if ( $submission->has_invoice() ) {
36
-			$this->fees = $submission->get_invoice()->get_fees();
37
-		}
38
-
39
-		// Process price fields.
40
-		$data         = $submission->get_data();
41
-		$payment_form = $submission->get_payment_form();
42
-
43
-		foreach ( $payment_form->get_elements() as $element ) {
44
-
45
-			if ( 'price_input' == $element['type'] ) {
46
-				$this->process_price_input( $element, $data, $submission );
47
-			}
48
-
49
-			if ( 'price_select' == $element['type'] ) {
50
-				$this->process_price_select( $element, $data );
51
-			}
52
-
53
-		}
54
-
55
-	}
56
-
57
-	/**
58
-	 * Process a price input field.
59
-	 *
60
-	 * @param array $element
61
-	 * @param array $data
62
-	 * @param GetPaid_Payment_Form_Submission $submission
63
-	 */
64
-	public function process_price_input( $element, $data, $submission ) {
65
-
66
-		// Abort if not passed.
67
-		if ( empty( $data[ $element['id'] ] ) ) {
68
-			return;
69
-		}
70
-
71
-		$amount  = (float) wpinv_sanitize_amount( $data[ $element['id'] ] );
72
-		$minimum = empty( $element['minimum'] ) ? 0 : (float) wpinv_sanitize_amount( $element['minimum'] );
73
-
74
-		if ( $amount < $minimum ) {
75
-			throw new Exception( sprintf( __( 'The minimum allowed amount is %s', 'invoicing' ), wpinv_price( $minimum, $submission->get_currency() ) ) );
76
-		}
77
-
78
-		$this->fees[ $element['label'] ] = array(
79
-			'name'          => $element['label'],
80
-			'initial_fee'   => $amount,
81
-			'recurring_fee' => 0,
82
-		);
83
-
84
-	}
85
-
86
-	/**
87
-	 * Process a price select field.
88
-	 *
89
-	 * @param array $element
90
-	 * @param array $data
91
-	 */
92
-	public function process_price_select( $element, $data ) {
93
-
94
-		// Abort if not passed.
95
-		if ( empty( $data[ $element['id'] ] ) ) {
96
-			return;
97
-		}
98
-
99
-		$options  = getpaid_convert_price_string_to_options( $element['options'] );
100
-		$selected = wpinv_parse_list( $data[ $element['id'] ] );
101
-		$total    = 0;
102
-
103
-		foreach ( $selected as $price ) {
104
-
105
-			if ( ! isset( $options[ $price ] ) ) {
106
-				throw new Exception( __( 'You have selected an invalid amount', 'invoicing' ) );
107
-			}
108
-
109
-			$total += (float) wpinv_sanitize_amount( $price );
110
-		}
111
-
112
-		$this->fees[ $element['label'] ] = array(
113
-			'name'          => $element['label'],
114
-			'initial_fee'   => $total,
115
-			'recurring_fee' => 0,
116
-		);
117
-
118
-	}
87
+     * Process a price select field.
88
+     *
89
+     * @param array $element
90
+     * @param array $data
91
+     */
92
+    public function process_price_select( $element, $data ) {
93
+
94
+        // Abort if not passed.
95
+        if ( empty( $data[ $element['id'] ] ) ) {
96
+            return;
97
+        }
98
+
99
+        $options  = getpaid_convert_price_string_to_options( $element['options'] );
100
+        $selected = wpinv_parse_list( $data[ $element['id'] ] );
101
+        $total    = 0;
102
+
103
+        foreach ( $selected as $price ) {
104
+
105
+            if ( ! isset( $options[ $price ] ) ) {
106
+                throw new Exception( __( 'You have selected an invalid amount', 'invoicing' ) );
107
+            }
108
+
109
+            $total += (float) wpinv_sanitize_amount( $price );
110
+        }
111
+
112
+        $this->fees[ $element['label'] ] = array(
113
+            'name'          => $element['label'],
114
+            'initial_fee'   => $total,
115
+            'recurring_fee' => 0,
116
+        );
117
+
118
+    }
119 119
 
120 120
 }
Please login to merge, or discard this patch.
templates/invoice-history.php 1 patch
Indentation   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -42,86 +42,86 @@  discard block
 block discarded – undo
42 42
 					<tr class="wpinv-item wpinv-item-<?php echo $invoice_status = $invoice->get_status(); ?>">
43 43
 						<?php
44 44
 
45
-							foreach ( wpinv_get_user_invoices_columns( $post_type ) as $column_id => $column_name ) :
45
+                            foreach ( wpinv_get_user_invoices_columns( $post_type ) as $column_id => $column_name ) :
46 46
 
47
-								$column_id = sanitize_html_class( $column_id );
48
-								$class     = empty( $column_name['class'] ) ? '' : sanitize_html_class( $column_name['class'] );
47
+                                $column_id = sanitize_html_class( $column_id );
48
+                                $class     = empty( $column_name['class'] ) ? '' : sanitize_html_class( $column_name['class'] );
49 49
 
50
-								echo "<td class='$column_id $class'>";
51
-								switch ( $column_id ) {
50
+                                echo "<td class='$column_id $class'>";
51
+                                switch ( $column_id ) {
52 52
 
53
-									case 'invoice-number':
54
-										echo wpinv_invoice_link( $invoice );
55
-										break;
53
+                                    case 'invoice-number':
54
+                                        echo wpinv_invoice_link( $invoice );
55
+                                        break;
56 56
 
57
-									case 'created-date':
58
-										echo getpaid_format_date_value( $invoice->get_date_created() );
59
-										break;
57
+                                    case 'created-date':
58
+                                        echo getpaid_format_date_value( $invoice->get_date_created() );
59
+                                        break;
60 60
 
61
-									case 'payment-date':
61
+                                    case 'payment-date':
62 62
 
63
-										if ( $invoice->needs_payment() ) {
64
-											echo "&mdash;";
65
-										} else {
66
-											echo getpaid_format_date_value( $invoice->get_date_completed() );
67
-										}
63
+                                        if ( $invoice->needs_payment() ) {
64
+                                            echo "&mdash;";
65
+                                        } else {
66
+                                            echo getpaid_format_date_value( $invoice->get_date_completed() );
67
+                                        }
68 68
 
69
-										break;
69
+                                        break;
70 70
 
71
-									case 'invoice-status':
72
-										echo $invoice->get_status_label_html();
71
+                                    case 'invoice-status':
72
+                                        echo $invoice->get_status_label_html();
73 73
 
74
-										break;
74
+                                        break;
75 75
 
76
-									case 'invoice-total':
77
-										echo wpinv_price( $invoice->get_total(), $invoice->get_currency() );
76
+                                    case 'invoice-total':
77
+                                        echo wpinv_price( $invoice->get_total(), $invoice->get_currency() );
78 78
 
79
-										break;
79
+                                        break;
80 80
 
81
-									case 'invoice-actions':
81
+                                    case 'invoice-actions':
82 82
 
83
-										$actions = array(
83
+                                        $actions = array(
84 84
 
85
-											'pay'       => array(
86
-												'url'   => $invoice->get_checkout_payment_url(),
87
-												'name'  => __( 'Pay Now', 'invoicing' ),
88
-												'class' => 'btn-success'
89
-											),
85
+                                            'pay'       => array(
86
+                                                'url'   => $invoice->get_checkout_payment_url(),
87
+                                                'name'  => __( 'Pay Now', 'invoicing' ),
88
+                                                'class' => 'btn-success'
89
+                                            ),
90 90
 
91
-											'print'     => array(
92
-												'url'   => $invoice->get_view_url(),
93
-												'name'  => __( 'View', 'invoicing' ),
94
-												'class' => 'btn-secondary',
95
-												'attrs' => 'target="_blank"'
96
-											)
97
-										);
91
+                                            'print'     => array(
92
+                                                'url'   => $invoice->get_view_url(),
93
+                                                'name'  => __( 'View', 'invoicing' ),
94
+                                                'class' => 'btn-secondary',
95
+                                                'attrs' => 'target="_blank"'
96
+                                            )
97
+                                        );
98 98
 
99
-										if ( ! $invoice->needs_payment() ) {
100
-											unset( $actions['pay'] );
101
-										}
99
+                                        if ( ! $invoice->needs_payment() ) {
100
+                                            unset( $actions['pay'] );
101
+                                        }
102 102
 
103
-										$actions = apply_filters( 'wpinv_user_invoices_actions', $actions, $invoice, $post_type );
103
+                                        $actions = apply_filters( 'wpinv_user_invoices_actions', $actions, $invoice, $post_type );
104 104
 
105
-										foreach ( $actions as $key => $action ) {
106
-											$class = !empty($action['class']) ? sanitize_html_class($action['class']) : '';
107
-											echo '<a href="' . esc_url( $action['url'] ) . '" class="btn btn-sm btn-block ' . $class . ' ' . sanitize_html_class( $key ) . '" ' . ( !empty($action['attrs']) ? $action['attrs'] : '' ) . '>' . $action['name'] . '</a>';
108
-										}
105
+                                        foreach ( $actions as $key => $action ) {
106
+                                            $class = !empty($action['class']) ? sanitize_html_class($action['class']) : '';
107
+                                            echo '<a href="' . esc_url( $action['url'] ) . '" class="btn btn-sm btn-block ' . $class . ' ' . sanitize_html_class( $key ) . '" ' . ( !empty($action['attrs']) ? $action['attrs'] : '' ) . '>' . $action['name'] . '</a>';
108
+                                        }
109 109
 
110
-										break;
110
+                                        break;
111 111
 
112
-									default:
113
-										do_action( "wpinv_user_invoices_column_$column_id", $invoice );
114
-										break;
112
+                                    default:
113
+                                        do_action( "wpinv_user_invoices_column_$column_id", $invoice );
114
+                                        break;
115 115
 
116 116
 
117
-								}
117
+                                }
118 118
 
119
-								do_action( "wpinv_user_invoices_column_after_$column_id", $invoice );
119
+                                do_action( "wpinv_user_invoices_column_after_$column_id", $invoice );
120 120
 
121
-								echo '</td>';
121
+                                echo '</td>';
122 122
 
123
-							endforeach;
124
-						?>
123
+                            endforeach;
124
+                        ?>
125 125
 					</tr>
126 126
 
127 127
 				<?php endforeach; ?>
@@ -135,14 +135,14 @@  discard block
 block discarded – undo
135 135
 	<?php if ( 1 < $invoices->max_num_pages ) : ?>
136 136
 		<div class="invoicing-Pagination">
137 137
 			<?php
138
-			$big = 999999;
139
-
140
-			echo paginate_links( array(
141
-				'base'    => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
142
-				'format'  => '?paged=%#%',
143
-				'total'   => $invoices->max_num_pages,
144
-			) );
145
-			?>
138
+            $big = 999999;
139
+
140
+            echo paginate_links( array(
141
+                'base'    => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
142
+                'format'  => '?paged=%#%',
143
+                'total'   => $invoices->max_num_pages,
144
+            ) );
145
+            ?>
146 146
 		</div>
147 147
 	<?php endif; ?>
148 148
 
Please login to merge, or discard this patch.
includes/gateways/class-getpaid-paypal-gateway.php 1 patch
Indentation   +223 added lines, -223 removed lines patch added patch discarded remove patch
@@ -13,94 +13,94 @@  discard block
 block discarded – undo
13 13
 class GetPaid_Paypal_Gateway extends GetPaid_Payment_Gateway {
14 14
 
15 15
     /**
16
-	 * Payment method id.
17
-	 *
18
-	 * @var string
19
-	 */
16
+     * Payment method id.
17
+     *
18
+     * @var string
19
+     */
20 20
     public $id = 'paypal';
21 21
 
22 22
     /**
23
-	 * An array of features that this gateway supports.
24
-	 *
25
-	 * @var array
26
-	 */
23
+     * An array of features that this gateway supports.
24
+     *
25
+     * @var array
26
+     */
27 27
     protected $supports = array( 'subscription', 'sandbox' );
28 28
 
29 29
     /**
30
-	 * Payment method order.
31
-	 *
32
-	 * @var int
33
-	 */
30
+     * Payment method order.
31
+     *
32
+     * @var int
33
+     */
34 34
     public $order = 1;
35 35
 
36 36
     /**
37
-	 * Stores line items to send to PayPal.
38
-	 *
39
-	 * @var array
40
-	 */
37
+     * Stores line items to send to PayPal.
38
+     *
39
+     * @var array
40
+     */
41 41
     protected $line_items = array();
42 42
 
43 43
     /**
44
-	 * Endpoint for requests from PayPal.
45
-	 *
46
-	 * @var string
47
-	 */
48
-	protected $notify_url;
49
-
50
-	/**
51
-	 * Endpoint for requests to PayPal.
52
-	 *
53
-	 * @var string
54
-	 */
44
+     * Endpoint for requests from PayPal.
45
+     *
46
+     * @var string
47
+     */
48
+    protected $notify_url;
49
+
50
+    /**
51
+     * Endpoint for requests to PayPal.
52
+     *
53
+     * @var string
54
+     */
55 55
     protected $endpoint;
56 56
     
57 57
     /**
58
-	 * Currencies this gateway is allowed for.
59
-	 *
60
-	 * @var array
61
-	 */
62
-	public $currencies = array( 'AUD', 'BRL', 'CAD', 'MXN', 'NZD', 'HKD', 'SGD', 'USD', 'EUR', 'JPY', 'TRY', 'NOK', 'CZK', 'DKK', 'HUF', 'ILS', 'MYR', 'PHP', 'PLN', 'SEK', 'CHF', 'TWD', 'THB', 'GBP', 'RMB', 'RUB', 'INR' );
58
+     * Currencies this gateway is allowed for.
59
+     *
60
+     * @var array
61
+     */
62
+    public $currencies = array( 'AUD', 'BRL', 'CAD', 'MXN', 'NZD', 'HKD', 'SGD', 'USD', 'EUR', 'JPY', 'TRY', 'NOK', 'CZK', 'DKK', 'HUF', 'ILS', 'MYR', 'PHP', 'PLN', 'SEK', 'CHF', 'TWD', 'THB', 'GBP', 'RMB', 'RUB', 'INR' );
63 63
 
64 64
     /**
65
-	 * URL to view a transaction.
66
-	 *
67
-	 * @var string
68
-	 */
65
+     * URL to view a transaction.
66
+     *
67
+     * @var string
68
+     */
69 69
     public $view_transaction_url = 'https://www.{sandbox}paypal.com/activity/payment/%s';
70 70
 
71 71
     /**
72
-	 * URL to view a subscription.
73
-	 *
74
-	 * @var string
75
-	 */
76
-	public $view_subscription_url = 'https://www.{sandbox}paypal.com/cgi-bin/webscr?cmd=_profile-recurring-payments&encrypted_profile_id=%s';
72
+     * URL to view a subscription.
73
+     *
74
+     * @var string
75
+     */
76
+    public $view_subscription_url = 'https://www.{sandbox}paypal.com/cgi-bin/webscr?cmd=_profile-recurring-payments&encrypted_profile_id=%s';
77 77
 
78 78
     /**
79
-	 * Class constructor.
80
-	 */
81
-	public function __construct() {
79
+     * Class constructor.
80
+     */
81
+    public function __construct() {
82 82
 
83 83
         $this->title                = __( 'PayPal Standard', 'invoicing' );
84 84
         $this->method_title         = __( 'PayPal Standard', 'invoicing' );
85 85
         $this->checkout_button_text = __( 'Proceed to PayPal', 'invoicing' );
86 86
         $this->notify_url           = wpinv_get_ipn_url( $this->id );
87 87
 
88
-		add_filter( 'getpaid_paypal_args', array( $this, 'process_subscription' ), 10, 2 );
88
+        add_filter( 'getpaid_paypal_args', array( $this, 'process_subscription' ), 10, 2 );
89 89
         add_filter( 'getpaid_paypal_sandbox_notice', array( $this, 'sandbox_notice' ) );
90 90
 
91 91
         parent::__construct();
92 92
     }
93 93
 
94 94
     /**
95
-	 * Process Payment.
96
-	 *
97
-	 *
98
-	 * @param WPInv_Invoice $invoice Invoice.
99
-	 * @param array $submission_data Posted checkout fields.
100
-	 * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
101
-	 * @return array
102
-	 */
103
-	public function process_payment( $invoice, $submission_data, $submission ) {
95
+     * Process Payment.
96
+     *
97
+     *
98
+     * @param WPInv_Invoice $invoice Invoice.
99
+     * @param array $submission_data Posted checkout fields.
100
+     * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
101
+     * @return array
102
+     */
103
+    public function process_payment( $invoice, $submission_data, $submission ) {
104 104
 
105 105
         // Get redirect url.
106 106
         $paypal_redirect = $this->get_request_url( $invoice );
@@ -123,15 +123,15 @@  discard block
 block discarded – undo
123 123
     }
124 124
 
125 125
     /**
126
-	 * Get the PayPal request URL for an invoice.
127
-	 *
128
-	 * @param  WPInv_Invoice $invoice Invoice object.
129
-	 * @return string
130
-	 */
131
-	public function get_request_url( $invoice ) {
126
+     * Get the PayPal request URL for an invoice.
127
+     *
128
+     * @param  WPInv_Invoice $invoice Invoice object.
129
+     * @return string
130
+     */
131
+    public function get_request_url( $invoice ) {
132 132
 
133 133
         // Endpoint for this request
134
-		$this->endpoint    = $this->is_sandbox( $invoice ) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr?test_ipn=1&' : 'https://www.paypal.com/cgi-bin/webscr?';
134
+        $this->endpoint    = $this->is_sandbox( $invoice ) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr?test_ipn=1&' : 'https://www.paypal.com/cgi-bin/webscr?';
135 135
 
136 136
         // Retrieve paypal args.
137 137
         $paypal_args       = map_deep( $this->get_paypal_args( $invoice ), 'urlencode' );
@@ -144,44 +144,44 @@  discard block
 block discarded – undo
144 144
 
145 145
         return add_query_arg( $paypal_args, $this->endpoint );
146 146
 
147
-	}
147
+    }
148 148
 
149 149
     /**
150
-	 * Get PayPal Args for passing to PP.
151
-	 *
152
-	 * @param  WPInv_Invoice $invoice Invoice object.
153
-	 * @return array
154
-	 */
155
-	protected function get_paypal_args( $invoice ) {
150
+     * Get PayPal Args for passing to PP.
151
+     *
152
+     * @param  WPInv_Invoice $invoice Invoice object.
153
+     * @return array
154
+     */
155
+    protected function get_paypal_args( $invoice ) {
156 156
 
157 157
         // Whether or not to send the line items as one item.
158
-		$force_one_line_item = apply_filters( 'getpaid_paypal_force_one_line_item', false, $invoice );
159
-
160
-		if ( $invoice->is_recurring() || ( wpinv_use_taxes() && wpinv_prices_include_tax() ) ) {
161
-			$force_one_line_item = true;
162
-		}
163
-
164
-		$paypal_args = apply_filters(
165
-			'getpaid_paypal_args',
166
-			array_merge(
167
-				$this->get_transaction_args( $invoice ),
168
-				$this->get_line_item_args( $invoice, $force_one_line_item )
169
-			),
170
-			$invoice
171
-		);
172
-
173
-		return $this->fix_request_length( $invoice, $paypal_args );
158
+        $force_one_line_item = apply_filters( 'getpaid_paypal_force_one_line_item', false, $invoice );
159
+
160
+        if ( $invoice->is_recurring() || ( wpinv_use_taxes() && wpinv_prices_include_tax() ) ) {
161
+            $force_one_line_item = true;
162
+        }
163
+
164
+        $paypal_args = apply_filters(
165
+            'getpaid_paypal_args',
166
+            array_merge(
167
+                $this->get_transaction_args( $invoice ),
168
+                $this->get_line_item_args( $invoice, $force_one_line_item )
169
+            ),
170
+            $invoice
171
+        );
172
+
173
+        return $this->fix_request_length( $invoice, $paypal_args );
174 174
     }
175 175
 
176 176
     /**
177
-	 * Get transaction args for paypal request.
178
-	 *
179
-	 * @param WPInv_Invoice $invoice Invoice object.
180
-	 * @return array
181
-	 */
182
-	protected function get_transaction_args( $invoice ) {
183
-
184
-		return array(
177
+     * Get transaction args for paypal request.
178
+     *
179
+     * @param WPInv_Invoice $invoice Invoice object.
180
+     * @return array
181
+     */
182
+    protected function get_transaction_args( $invoice ) {
183
+
184
+        return array(
185 185
             'cmd'           => '_cart',
186 186
             'business'      => wpinv_get_option( 'paypal_email', false ),
187 187
             'no_shipping'   => '1',
@@ -206,16 +206,16 @@  discard block
 block discarded – undo
206 206
     }
207 207
 
208 208
     /**
209
-	 * Get line item args for paypal request.
210
-	 *
211
-	 * @param  WPInv_Invoice $invoice Invoice object.
212
-	 * @param  bool     $force_one_line_item Create only one item for this invoice.
213
-	 * @return array
214
-	 */
215
-	protected function get_line_item_args( $invoice, $force_one_line_item = false ) {
209
+     * Get line item args for paypal request.
210
+     *
211
+     * @param  WPInv_Invoice $invoice Invoice object.
212
+     * @param  bool     $force_one_line_item Create only one item for this invoice.
213
+     * @return array
214
+     */
215
+    protected function get_line_item_args( $invoice, $force_one_line_item = false ) {
216 216
 
217 217
         // Maybe send invoice as a single item.
218
-		if ( $force_one_line_item ) {
218
+        if ( $force_one_line_item ) {
219 219
             return $this->get_line_item_args_single_item( $invoice );
220 220
         }
221 221
 
@@ -235,129 +235,129 @@  discard block
 block discarded – undo
235 235
             $line_item_args['discount_amount_cart'] = wpinv_sanitize_amount( (float) $invoice->get_total_discount(), 2 );
236 236
         }
237 237
 
238
-		return array_merge( $line_item_args, $this->get_line_items() );
238
+        return array_merge( $line_item_args, $this->get_line_items() );
239 239
 
240 240
     }
241 241
 
242 242
     /**
243
-	 * Get line item args for paypal request as a single line item.
244
-	 *
245
-	 * @param  WPInv_Invoice $invoice Invoice object.
246
-	 * @return array
247
-	 */
248
-	protected function get_line_item_args_single_item( $invoice ) {
249
-		$this->delete_line_items();
243
+     * Get line item args for paypal request as a single line item.
244
+     *
245
+     * @param  WPInv_Invoice $invoice Invoice object.
246
+     * @return array
247
+     */
248
+    protected function get_line_item_args_single_item( $invoice ) {
249
+        $this->delete_line_items();
250 250
 
251 251
         $item_name = sprintf( __( 'Invoice #%s', 'invoicing' ), $invoice->get_number() );
252
-		$this->add_line_item( $item_name, 1, wpinv_sanitize_amount( (float) $invoice->get_total(), 2 ), $invoice->get_id() );
252
+        $this->add_line_item( $item_name, 1, wpinv_sanitize_amount( (float) $invoice->get_total(), 2 ), $invoice->get_id() );
253 253
 
254
-		return $this->get_line_items();
254
+        return $this->get_line_items();
255 255
     }
256 256
 
257 257
     /**
258
-	 * Return all line items.
259
-	 */
260
-	protected function get_line_items() {
261
-		return $this->line_items;
262
-	}
258
+     * Return all line items.
259
+     */
260
+    protected function get_line_items() {
261
+        return $this->line_items;
262
+    }
263 263
 
264 264
     /**
265
-	 * Remove all line items.
266
-	 */
267
-	protected function delete_line_items() {
268
-		$this->line_items = array();
265
+     * Remove all line items.
266
+     */
267
+    protected function delete_line_items() {
268
+        $this->line_items = array();
269 269
     }
270 270
 
271 271
     /**
272
-	 * Prepare line items to send to paypal.
273
-	 *
274
-	 * @param  WPInv_Invoice $invoice Invoice object.
275
-	 */
276
-	protected function prepare_line_items( $invoice ) {
277
-		$this->delete_line_items();
278
-
279
-		// Items.
280
-		foreach ( $invoice->get_items() as $item ) {
281
-			$amount   = $invoice->get_template() == 'amount' ? $item->get_price() : $item->get_sub_total();
282
-			$quantity = $invoice->get_template() == 'amount' ? 1 : $item->get_quantity();
283
-			$this->add_line_item( $item->get_raw_name(), $quantity, $amount, $item->get_id() );
272
+     * Prepare line items to send to paypal.
273
+     *
274
+     * @param  WPInv_Invoice $invoice Invoice object.
275
+     */
276
+    protected function prepare_line_items( $invoice ) {
277
+        $this->delete_line_items();
278
+
279
+        // Items.
280
+        foreach ( $invoice->get_items() as $item ) {
281
+            $amount   = $invoice->get_template() == 'amount' ? $item->get_price() : $item->get_sub_total();
282
+            $quantity = $invoice->get_template() == 'amount' ? 1 : $item->get_quantity();
283
+            $this->add_line_item( $item->get_raw_name(), $quantity, $amount, $item->get_id() );
284 284
         }
285 285
 
286 286
         // Fees.
287
-		foreach ( $invoice->get_fees() as $fee => $data ) {
287
+        foreach ( $invoice->get_fees() as $fee => $data ) {
288 288
             $this->add_line_item( $fee, 1, wpinv_sanitize_amount( $data['initial_fee'] ) );
289 289
         }
290 290
 
291 291
     }
292 292
 
293 293
     /**
294
-	 * Add PayPal Line Item.
295
-	 *
296
-	 * @param  string $item_name Item name.
297
-	 * @param  int    $quantity Item quantity.
298
-	 * @param  float  $amount Amount.
299
-	 * @param  string $item_number Item number.
300
-	 */
301
-	protected function add_line_item( $item_name, $quantity = 1, $amount = 0.0, $item_number = '' ) {
302
-		$index = ( count( $this->line_items ) / 4 ) + 1;
303
-
304
-		$item = apply_filters(
305
-			'getpaid_paypal_line_item',
306
-			array(
307
-				'item_name'   => html_entity_decode( getpaid_limit_length( $item_name ? wp_strip_all_tags( $item_name ) : __( 'Item', 'invoicing' ), 127 ), ENT_NOQUOTES, 'UTF-8' ),
308
-				'quantity'    => (float) $quantity,
309
-				'amount'      => wpinv_sanitize_amount( (float) $amount, 2 ),
310
-				'item_number' => $item_number,
311
-			),
312
-			$item_name,
313
-			$quantity,
314
-			$amount,
315
-			$item_number
316
-		);
317
-
318
-		$this->line_items[ 'item_name_' . $index ]   = getpaid_limit_length( $item['item_name'], 127 );
294
+     * Add PayPal Line Item.
295
+     *
296
+     * @param  string $item_name Item name.
297
+     * @param  int    $quantity Item quantity.
298
+     * @param  float  $amount Amount.
299
+     * @param  string $item_number Item number.
300
+     */
301
+    protected function add_line_item( $item_name, $quantity = 1, $amount = 0.0, $item_number = '' ) {
302
+        $index = ( count( $this->line_items ) / 4 ) + 1;
303
+
304
+        $item = apply_filters(
305
+            'getpaid_paypal_line_item',
306
+            array(
307
+                'item_name'   => html_entity_decode( getpaid_limit_length( $item_name ? wp_strip_all_tags( $item_name ) : __( 'Item', 'invoicing' ), 127 ), ENT_NOQUOTES, 'UTF-8' ),
308
+                'quantity'    => (float) $quantity,
309
+                'amount'      => wpinv_sanitize_amount( (float) $amount, 2 ),
310
+                'item_number' => $item_number,
311
+            ),
312
+            $item_name,
313
+            $quantity,
314
+            $amount,
315
+            $item_number
316
+        );
317
+
318
+        $this->line_items[ 'item_name_' . $index ]   = getpaid_limit_length( $item['item_name'], 127 );
319 319
         $this->line_items[ 'quantity_' . $index ]    = $item['quantity'];
320 320
         
321 321
         // The price or amount of the product, service, or contribution, not including shipping, handling, or tax.
322
-		$this->line_items[ 'amount_' . $index ]      = $item['amount'];
323
-		$this->line_items[ 'item_number_' . $index ] = getpaid_limit_length( $item['item_number'], 127 );
322
+        $this->line_items[ 'amount_' . $index ]      = $item['amount'];
323
+        $this->line_items[ 'item_number_' . $index ] = getpaid_limit_length( $item['item_number'], 127 );
324 324
     }
325 325
 
326 326
     /**
327
-	 * If the default request with line items is too long, generate a new one with only one line item.
328
-	 *
329
-	 * https://support.microsoft.com/en-us/help/208427/maximum-url-length-is-2-083-characters-in-internet-explorer.
330
-	 *
331
-	 * @param WPInv_Invoice $invoice Invoice to be sent to Paypal.
332
-	 * @param array    $paypal_args Arguments sent to Paypal in the request.
333
-	 * @return array
334
-	 */
335
-	protected function fix_request_length( $invoice, $paypal_args ) {
336
-		$max_paypal_length = 2083;
337
-		$query_candidate   = http_build_query( $paypal_args, '', '&' );
338
-
339
-		if ( strlen( $this->endpoint . $query_candidate ) <= $max_paypal_length ) {
340
-			return $paypal_args;
341
-		}
342
-
343
-		return apply_filters(
344
-			'getpaid_paypal_args',
345
-			array_merge(
346
-				$this->get_transaction_args( $invoice ),
347
-				$this->get_line_item_args( $invoice, true )
348
-			),
349
-			$invoice
350
-		);
327
+     * If the default request with line items is too long, generate a new one with only one line item.
328
+     *
329
+     * https://support.microsoft.com/en-us/help/208427/maximum-url-length-is-2-083-characters-in-internet-explorer.
330
+     *
331
+     * @param WPInv_Invoice $invoice Invoice to be sent to Paypal.
332
+     * @param array    $paypal_args Arguments sent to Paypal in the request.
333
+     * @return array
334
+     */
335
+    protected function fix_request_length( $invoice, $paypal_args ) {
336
+        $max_paypal_length = 2083;
337
+        $query_candidate   = http_build_query( $paypal_args, '', '&' );
338
+
339
+        if ( strlen( $this->endpoint . $query_candidate ) <= $max_paypal_length ) {
340
+            return $paypal_args;
341
+        }
342
+
343
+        return apply_filters(
344
+            'getpaid_paypal_args',
345
+            array_merge(
346
+                $this->get_transaction_args( $invoice ),
347
+                $this->get_line_item_args( $invoice, true )
348
+            ),
349
+            $invoice
350
+        );
351 351
 
352 352
     }
353 353
     
354 354
     /**
355
-	 * Processes recurring invoices.
356
-	 *
357
-	 * @param  array $paypal_args PayPal args.
358
-	 * @param  WPInv_Invoice    $invoice Invoice object.
359
-	 */
360
-	public function process_subscription( $paypal_args, $invoice ) {
355
+     * Processes recurring invoices.
356
+     *
357
+     * @param  array $paypal_args PayPal args.
358
+     * @param  WPInv_Invoice    $invoice Invoice object.
359
+     */
360
+    public function process_subscription( $paypal_args, $invoice ) {
361 361
 
362 362
         // Make sure this is a subscription.
363 363
         if ( ! $invoice->is_recurring() || ! $subscription = wpinv_get_subscription( $invoice ) ) {
@@ -382,11 +382,11 @@  discard block
 block discarded – undo
382 382
 
383 383
             $paypal_args['a1'] = 0 == $initial_amount ? 0 : $initial_amount;
384 384
 
385
-			// Trial period length.
386
-			$paypal_args['p1'] = $subscription_item->get_trial_interval();
385
+            // Trial period length.
386
+            $paypal_args['p1'] = $subscription_item->get_trial_interval();
387 387
 
388
-			// Trial period.
389
-			$paypal_args['t1'] = $subscription_item->get_trial_period();
388
+            // Trial period.
389
+            $paypal_args['t1'] = $subscription_item->get_trial_period();
390 390
 
391 391
         } else if ( $initial_amount != $recurring_amount ) {
392 392
 
@@ -409,40 +409,40 @@  discard block
 block discarded – undo
409 409
         }
410 410
 
411 411
         // We have a recurring payment
412
-		if ( ! isset( $param_number ) || 1 == $param_number ) {
412
+        if ( ! isset( $param_number ) || 1 == $param_number ) {
413 413
 
414
-			// Subscription price
415
-			$paypal_args['a3'] = $recurring_amount;
414
+            // Subscription price
415
+            $paypal_args['a3'] = $recurring_amount;
416 416
 
417
-			// Subscription duration
418
-			$paypal_args['p3'] = $interval;
417
+            // Subscription duration
418
+            $paypal_args['p3'] = $interval;
419 419
 
420
-			// Subscription period
421
-			$paypal_args['t3'] = $period;
420
+            // Subscription period
421
+            $paypal_args['t3'] = $period;
422 422
 
423 423
         }
424 424
         
425 425
         // Recurring payments
426
-		if ( 1 == $bill_times || ( $initial_amount != $recurring_amount && ! $subscription_item->has_free_trial() && 2 == $bill_times ) ) {
426
+        if ( 1 == $bill_times || ( $initial_amount != $recurring_amount && ! $subscription_item->has_free_trial() && 2 == $bill_times ) ) {
427 427
 
428
-			// Non-recurring payments
429
-			$paypal_args['src'] = 0;
428
+            // Non-recurring payments
429
+            $paypal_args['src'] = 0;
430 430
 
431
-		} else {
431
+        } else {
432 432
 
433
-			$paypal_args['src'] = 1;
433
+            $paypal_args['src'] = 1;
434 434
 
435
-			if ( $bill_times > 0 ) {
435
+            if ( $bill_times > 0 ) {
436 436
 
437
-				// An initial period is being used to charge a sign-up fee
438
-				if ( $initial_amount != $recurring_amount && ! $subscription_item->has_free_trial() ) {
439
-					$bill_times--;
440
-				}
437
+                // An initial period is being used to charge a sign-up fee
438
+                if ( $initial_amount != $recurring_amount && ! $subscription_item->has_free_trial() ) {
439
+                    $bill_times--;
440
+                }
441 441
 
442 442
                 // Make sure it's not over the max of 52
443 443
                 $paypal_args['srt'] = ( $bill_times <= 52 ? absint( $bill_times ) : 52 );
444 444
 
445
-			}
445
+            }
446 446
         }
447 447
         
448 448
         // Force return URL so that order description & instructions display
@@ -458,19 +458,19 @@  discard block
 block discarded – undo
458 458
         }
459 459
 
460 460
         return apply_filters(
461
-			'getpaid_paypal_subscription_args',
462
-			$paypal_args,
463
-			$invoice
461
+            'getpaid_paypal_subscription_args',
462
+            $paypal_args,
463
+            $invoice
464 464
         );
465 465
 
466 466
     }
467 467
 
468 468
     /**
469
-	 * Processes ipns and marks payments as complete.
470
-	 *
471
-	 * @return void
472
-	 */
473
-	public function verify_ipn() {
469
+     * Processes ipns and marks payments as complete.
470
+     *
471
+     * @return void
472
+     */
473
+    public function verify_ipn() {
474 474
         new GetPaid_Paypal_Gateway_IPN_Handler( $this );
475 475
     }
476 476
 
@@ -480,10 +480,10 @@  discard block
 block discarded – undo
480 480
     public function sandbox_notice() {
481 481
 
482 482
         return sprintf(
483
-			__( 'SANDBOX ENABLED. You can use sandbox testing accounts only. See the %sPayPal Sandbox Testing Guide%s for more details.', 'invoicing' ),
484
-			'<a href="https://developer.paypal.com/docs/classic/lifecycle/ug_sandbox/">',
485
-			'</a>'
486
-		);
483
+            __( 'SANDBOX ENABLED. You can use sandbox testing accounts only. See the %sPayPal Sandbox Testing Guide%s for more details.', 'invoicing' ),
484
+            '<a href="https://developer.paypal.com/docs/classic/lifecycle/ug_sandbox/">',
485
+            '</a>'
486
+        );
487 487
 
488 488
     }
489 489
 
Please login to merge, or discard this patch.