Completed
Branch models-cleanup/more-ee-base-cl... (91a157)
by
unknown
53:04 queued 43:29
created
core/db_classes/EE_Payment_Method.class.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -389,11 +389,11 @@  discard block
 block discarded – undo
389 389
      */
390 390
     public function type_obj()
391 391
     {
392
-        if (! $this->_type_obj) {
392
+        if ( ! $this->_type_obj) {
393 393
             EE_Registry::instance()->load_lib('Payment_Method_Manager');
394 394
             if (EE_Payment_Method_Manager::instance()->payment_method_type_exists($this->type())) {
395 395
                 $class_name = EE_Payment_Method_Manager::instance()->payment_method_class_from_type($this->type());
396
-                if (! class_exists($class_name)) {
396
+                if ( ! class_exists($class_name)) {
397 397
                     throw new EE_Error(
398 398
                         sprintf(
399 399
                             __(
@@ -402,7 +402,7 @@  discard block
 block discarded – undo
402 402
                             ),
403 403
                             $class_name,
404 404
                             '<br />',
405
-                            '<a href="' . admin_url('plugins.php') . '">',
405
+                            '<a href="'.admin_url('plugins.php').'">',
406 406
                             '</a>'
407 407
                         )
408 408
                     );
@@ -441,7 +441,7 @@  discard block
 block discarded – undo
441 441
         foreach ($fields as $key => $value) {
442 442
             if (strpos($key, 'PMD_') === 0) {
443 443
                 $key_sans_model_prefix = str_replace('PMD_', '', $key);
444
-                $combined_settings_array [ $key_sans_model_prefix ] = $value;
444
+                $combined_settings_array [$key_sans_model_prefix] = $value;
445 445
             }
446 446
         }
447 447
         $combined_settings_array = array_merge($extra_meta, $combined_settings_array);
@@ -464,14 +464,14 @@  discard block
 block discarded – undo
464 464
 		 <div id="'
465 465
                . $this->slug()
466 466
                . '-payment-option-dv" class="'
467
-               . $payment_occurs . '-payment-gateway reg-page-payment-option-dv' . $css_class . '">
467
+               . $payment_occurs.'-payment-gateway reg-page-payment-option-dv'.$css_class.'">
468 468
 			<a id="payment-gateway-button-' . $this->slug()
469 469
                . '" class="reg-page-payment-option-lnk" rel="'
470
-               . $this->slug() . '" href="' . $url . '" >
471
-				<img src="' . $this->button_url() . '" alt="' . sprintf(
470
+               . $this->slug().'" href="'.$url.'" >
471
+				<img src="' . $this->button_url().'" alt="'.sprintf(
472 472
                    esc_attr__('Pay using %s', 'event_espresso'),
473 473
                    $this->get_pretty('PMD_name', 'form_input')
474
-               ) . '" />
474
+               ).'" />
475 475
 			</a>
476 476
 		</div>
477 477
 ';
Please login to merge, or discard this patch.
Indentation   +570 added lines, -570 removed lines patch added patch discarded remove patch
@@ -11,580 +11,580 @@
 block discarded – undo
11 11
 class EE_Payment_Method extends EE_Base_Class
12 12
 {
13 13
 
14
-    /**
15
-     * Payment Method type object, which has all the info about this type of payment method,
16
-     * including functions for processing payments, to get settings forms, etc.
17
-     *
18
-     * @var EE_PMT_Base
19
-     */
20
-    protected $_type_obj;
21
-
22
-
23
-    /**
24
-     * @param array $props_n_values
25
-     * @return EE_Payment_Method
26
-     * @throws \EE_Error
27
-     */
28
-    public static function new_instance($props_n_values = array())
29
-    {
30
-        $has_object = parent::_check_for_object($props_n_values, __CLASS__);
31
-        return $has_object ? $has_object : new self($props_n_values, false);
32
-    }
33
-
34
-
35
-    /**
36
-     * @param array $props_n_values
37
-     * @return EE_Payment_Method
38
-     * @throws \EE_Error
39
-     */
40
-    public static function new_instance_from_db($props_n_values = array())
41
-    {
42
-        return new self($props_n_values, true);
43
-    }
44
-
45
-
46
-
47
-    /**
48
-     * Checks if there is a payment method class of the given 'PMD_type', and if so returns the classname.
49
-     * Otherwise returns a normal EE_Payment_Method
50
-     *
51
-     * @param array $props_n_values where 'PMD_type' is a gateway name like 'Paypal_Standard','Invoice',etc (basically
52
-     *                              the classname minus 'EEPM_')
53
-     * @return string
54
-     */
55
-    // private static function _payment_method_type($props_n_values)
56
-    // {
57
-    //     EE_Registry::instance()->load_lib('Payment_Method_Manager');
58
-    //     $type_string = isset($props_n_values['PMD_type']) ? $props_n_values['PMD_type'] : null;
59
-    //     if (EE_Payment_Method_Manager::instance()->payment_method_type_exists($type_string)) {
60
-    //         return 'EEPM_' . $type_string;
61
-    //     } else {
62
-    //         return __CLASS__;
63
-    //     }
64
-    // }
65
-
66
-
67
-    /**
68
-     * Gets whether this payment method can be used anywhere at all (ie frontend cart, admin, etc)
69
-     *
70
-     * @return boolean
71
-     */
72
-    public function active()
73
-    {
74
-        return array_intersect(array_keys(EEM_Payment_Method::instance()->scopes()), $this->scope());
75
-    }
76
-
77
-
78
-    /**
79
-     * Sets this PM as active by making it usable within the CART scope. Offline gateways
80
-     * are also usable from the admin-scope as well. DOES NOT SAVE it
81
-     *
82
-     * @throws \EE_Error
83
-     */
84
-    public function set_active()
85
-    {
86
-        $default_scopes = array(EEM_Payment_Method::scope_cart);
87
-        if (
88
-            $this->type_obj() &&
89
-            $this->type_obj()->payment_occurs() === EE_PMT_Base::offline
90
-        ) {
91
-            $default_scopes[] = EEM_Payment_Method::scope_admin;
92
-        }
93
-        $this->set_scope($default_scopes);
94
-    }
95
-
96
-
97
-    /**
98
-     * Makes this payment method apply to NO scopes at all. DOES NOT SAVE it.
99
-     */
100
-    public function deactivate()
101
-    {
102
-        $this->set_scope(array());
103
-    }
104
-
105
-
106
-    /**
107
-     * Gets button_url
108
-     *
109
-     * @return string
110
-     */
111
-    public function button_url()
112
-    {
113
-        return $this->get('PMD_button_url');
114
-    }
115
-
116
-
117
-    /**
118
-     * Sets button_url
119
-     *
120
-     * @param string $button_url
121
-     */
122
-    public function set_button_url($button_url)
123
-    {
124
-        $this->set('PMD_button_url', $button_url);
125
-    }
126
-
127
-
128
-    /**
129
-     * Gets debug_mode
130
-     *
131
-     * @return boolean
132
-     */
133
-    public function debug_mode()
134
-    {
135
-        return $this->get('PMD_debug_mode');
136
-    }
137
-
138
-
139
-    /**
140
-     * Sets debug_mode
141
-     *
142
-     * @param boolean $debug_mode
143
-     */
144
-    public function set_debug_mode($debug_mode)
145
-    {
146
-        $this->set('PMD_debug_mode', $debug_mode);
147
-    }
148
-
149
-
150
-    /**
151
-     * Gets description
152
-     *
153
-     * @return string
154
-     */
155
-    public function description()
156
-    {
157
-        return $this->get('PMD_desc');
158
-    }
159
-
160
-
161
-    /**
162
-     * Sets description
163
-     *
164
-     * @param string $description
165
-     */
166
-    public function set_description($description)
167
-    {
168
-        $this->set('PMD_desc', $description);
169
-    }
170
-
171
-
172
-    /**
173
-     * Gets name
174
-     *
175
-     * @return string
176
-     */
177
-    public function name()
178
-    {
179
-        return $this->get('PMD_name');
180
-    }
181
-
182
-
183
-    /**
184
-     * Sets name
185
-     *
186
-     * @param string $name
187
-     */
188
-    public function set_name($name)
189
-    {
190
-        $this->set('PMD_name', $name);
191
-    }
192
-
193
-
194
-    /**
195
-     * Gets open_by_default
196
-     *
197
-     * @return boolean
198
-     */
199
-    public function open_by_default()
200
-    {
201
-        return $this->get('PMD_open_by_default');
202
-    }
203
-
204
-
205
-    /**
206
-     * Sets open_by_default
207
-     *
208
-     * @param boolean $open_by_default
209
-     */
210
-    public function set_open_by_default($open_by_default)
211
-    {
212
-        $this->set('PMD_open_by_default', $open_by_default);
213
-    }
214
-
215
-
216
-    /**
217
-     * Gets order
218
-     *
219
-     * @return int
220
-     */
221
-    public function order()
222
-    {
223
-        return $this->get('PMD_order');
224
-    }
225
-
226
-
227
-    /**
228
-     * Sets order
229
-     *
230
-     * @param int $order
231
-     */
232
-    public function set_order($order)
233
-    {
234
-        $this->set('PMD_order', $order);
235
-    }
236
-
237
-
238
-    /**
239
-     * Gets slug
240
-     *
241
-     * @return string
242
-     */
243
-    public function slug()
244
-    {
245
-        return $this->get('PMD_slug');
246
-    }
247
-
248
-
249
-    /**
250
-     * Sets slug
251
-     *
252
-     * @param string $slug
253
-     */
254
-    public function set_slug($slug)
255
-    {
256
-        $this->set('PMD_slug', $slug);
257
-    }
258
-
259
-
260
-    /**
261
-     * Gets type
262
-     *
263
-     * @return string
264
-     */
265
-    public function type()
266
-    {
267
-        return $this->get('PMD_type');
268
-    }
269
-
270
-
271
-    /**
272
-     * Sets type
273
-     *
274
-     * @param string $type
275
-     */
276
-    public function set_type($type)
277
-    {
278
-        $this->set('PMD_type', $type);
279
-    }
280
-
281
-
282
-    /**
283
-     * Gets wp_user
284
-     *
285
-     * @return int
286
-     */
287
-    public function wp_user()
288
-    {
289
-        return $this->get('PMD_wp_user');
290
-    }
291
-
292
-
293
-    /**
294
-     * Sets wp_user
295
-     *
296
-     * @param int $wp_user_id
297
-     */
298
-    public function set_wp_user($wp_user_id)
299
-    {
300
-        $this->set('PMD_wp_user', $wp_user_id);
301
-    }
302
-
303
-    /**
304
-     * Overrides parent so when PMD_type is changed we refresh the _type_obj
305
-     *
306
-     * @param string $field_name
307
-     * @param mixed $field_value
308
-     * @param boolean $use_default
309
-     */
310
-    public function set($field_name, $field_value, $use_default = false)
311
-    {
312
-        if ($field_name === 'PMD_type') {
313
-            // the type has probably changed, so forget about its old type object
314
-            $this->_type_obj = null;
315
-        }
316
-        parent::set($field_name, $field_value, $use_default);
317
-    }
318
-
319
-
320
-    /**
321
-     * Gets admin_name
322
-     *
323
-     * @return string
324
-     */
325
-    public function admin_name()
326
-    {
327
-        return $this->get('PMD_admin_name');
328
-    }
329
-
330
-
331
-    /**
332
-     * Sets admin_name
333
-     *
334
-     * @param string $admin_name
335
-     */
336
-    public function set_admin_name($admin_name)
337
-    {
338
-        $this->set('PMD_admin_name', $admin_name);
339
-    }
340
-
341
-
342
-    /**
343
-     * Gets admin_desc
344
-     *
345
-     * @return string
346
-     */
347
-    public function admin_desc()
348
-    {
349
-        return $this->get('PMD_admin_desc');
350
-    }
351
-
352
-
353
-    /**
354
-     * Sets admin_desc
355
-     *
356
-     * @param string $admin_desc
357
-     */
358
-    public function set_admin_desc($admin_desc)
359
-    {
360
-        $this->set('PMD_admin_desc', $admin_desc);
361
-    }
362
-
363
-
364
-    /**
365
-     * Gets scope
366
-     *
367
-     * @return array
368
-     */
369
-    public function scope()
370
-    {
371
-        return $this->get('PMD_scope');
372
-    }
373
-
374
-
375
-    /**
376
-     * Sets scope
377
-     *
378
-     * @param array $scope
379
-     */
380
-    public function set_scope($scope)
381
-    {
382
-        $this->set('PMD_scope', $scope);
383
-    }
384
-
385
-
386
-    /**
387
-     * Gets the payment method type for this payment method instance
388
-     *
389
-     * @return EE_PMT_Base
390
-     * @throws EE_Error
391
-     */
392
-    public function type_obj()
393
-    {
394
-        if (! $this->_type_obj) {
395
-            EE_Registry::instance()->load_lib('Payment_Method_Manager');
396
-            if (EE_Payment_Method_Manager::instance()->payment_method_type_exists($this->type())) {
397
-                $class_name = EE_Payment_Method_Manager::instance()->payment_method_class_from_type($this->type());
398
-                if (! class_exists($class_name)) {
399
-                    throw new EE_Error(
400
-                        sprintf(
401
-                            __(
402
-                                'An attempt to use the "%1$s" payment method failed, so it was deactivated.%2$sWas the "%1$s" Plugin recently deactivated? It can be reactivated on the %3$sPlugins Admin Page%4$s',
403
-                                'event_espresso'
404
-                            ),
405
-                            $class_name,
406
-                            '<br />',
407
-                            '<a href="' . admin_url('plugins.php') . '">',
408
-                            '</a>'
409
-                        )
410
-                    );
411
-                }
412
-                $r = new ReflectionClass($class_name);
413
-                $this->_type_obj = $r->newInstanceArgs(array($this));
414
-            } else {
415
-                throw new EE_Error(
416
-                    sprintf(
417
-                        __(
418
-                            'A payment method of type "%1$s" does not exist. Only ones existing are: %2$s',
419
-                            'event_espresso'
420
-                        ),
421
-                        $this->type(),
422
-                        implode(',', EE_Payment_Method_Manager::instance()->payment_method_type_names())
423
-                    )
424
-                );
425
-            }
426
-        }
427
-        return $this->_type_obj;
428
-    }
429
-
430
-
431
-    /**
432
-     * Returns a simple array of key-value pairs combining the payment method's fields (without the 'PMD_' prefix)
433
-     * and the extra meta. Mostly used for passing off ot gateways.     *
434
-     *
435
-     * @return array
436
-     */
437
-    public function settings_array()
438
-    {
439
-        $fields = $this->model_field_array();
440
-        $extra_meta = $this->all_extra_meta_array();
441
-        // remove the model's prefix from the fields
442
-        $combined_settings_array = array();
443
-        foreach ($fields as $key => $value) {
444
-            if (strpos($key, 'PMD_') === 0) {
445
-                $key_sans_model_prefix = str_replace('PMD_', '', $key);
446
-                $combined_settings_array [ $key_sans_model_prefix ] = $value;
447
-            }
448
-        }
449
-        $combined_settings_array = array_merge($extra_meta, $combined_settings_array);
450
-        return $combined_settings_array;
451
-    }
452
-
453
-
454
-    /**
455
-     * Gets the HTML for displaying the payment method on a page.
456
-     *
457
-     * @param string $url
458
-     * @param string $css_class
459
-     * @return string of HTML for displaying the button
460
-     * @throws \EE_Error
461
-     */
462
-    public function button_html($url = '', $css_class = '')
463
-    {
464
-        $payment_occurs = $this->type_obj()->payment_occurs();
465
-        return '
14
+	/**
15
+	 * Payment Method type object, which has all the info about this type of payment method,
16
+	 * including functions for processing payments, to get settings forms, etc.
17
+	 *
18
+	 * @var EE_PMT_Base
19
+	 */
20
+	protected $_type_obj;
21
+
22
+
23
+	/**
24
+	 * @param array $props_n_values
25
+	 * @return EE_Payment_Method
26
+	 * @throws \EE_Error
27
+	 */
28
+	public static function new_instance($props_n_values = array())
29
+	{
30
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__);
31
+		return $has_object ? $has_object : new self($props_n_values, false);
32
+	}
33
+
34
+
35
+	/**
36
+	 * @param array $props_n_values
37
+	 * @return EE_Payment_Method
38
+	 * @throws \EE_Error
39
+	 */
40
+	public static function new_instance_from_db($props_n_values = array())
41
+	{
42
+		return new self($props_n_values, true);
43
+	}
44
+
45
+
46
+
47
+	/**
48
+	 * Checks if there is a payment method class of the given 'PMD_type', and if so returns the classname.
49
+	 * Otherwise returns a normal EE_Payment_Method
50
+	 *
51
+	 * @param array $props_n_values where 'PMD_type' is a gateway name like 'Paypal_Standard','Invoice',etc (basically
52
+	 *                              the classname minus 'EEPM_')
53
+	 * @return string
54
+	 */
55
+	// private static function _payment_method_type($props_n_values)
56
+	// {
57
+	//     EE_Registry::instance()->load_lib('Payment_Method_Manager');
58
+	//     $type_string = isset($props_n_values['PMD_type']) ? $props_n_values['PMD_type'] : null;
59
+	//     if (EE_Payment_Method_Manager::instance()->payment_method_type_exists($type_string)) {
60
+	//         return 'EEPM_' . $type_string;
61
+	//     } else {
62
+	//         return __CLASS__;
63
+	//     }
64
+	// }
65
+
66
+
67
+	/**
68
+	 * Gets whether this payment method can be used anywhere at all (ie frontend cart, admin, etc)
69
+	 *
70
+	 * @return boolean
71
+	 */
72
+	public function active()
73
+	{
74
+		return array_intersect(array_keys(EEM_Payment_Method::instance()->scopes()), $this->scope());
75
+	}
76
+
77
+
78
+	/**
79
+	 * Sets this PM as active by making it usable within the CART scope. Offline gateways
80
+	 * are also usable from the admin-scope as well. DOES NOT SAVE it
81
+	 *
82
+	 * @throws \EE_Error
83
+	 */
84
+	public function set_active()
85
+	{
86
+		$default_scopes = array(EEM_Payment_Method::scope_cart);
87
+		if (
88
+			$this->type_obj() &&
89
+			$this->type_obj()->payment_occurs() === EE_PMT_Base::offline
90
+		) {
91
+			$default_scopes[] = EEM_Payment_Method::scope_admin;
92
+		}
93
+		$this->set_scope($default_scopes);
94
+	}
95
+
96
+
97
+	/**
98
+	 * Makes this payment method apply to NO scopes at all. DOES NOT SAVE it.
99
+	 */
100
+	public function deactivate()
101
+	{
102
+		$this->set_scope(array());
103
+	}
104
+
105
+
106
+	/**
107
+	 * Gets button_url
108
+	 *
109
+	 * @return string
110
+	 */
111
+	public function button_url()
112
+	{
113
+		return $this->get('PMD_button_url');
114
+	}
115
+
116
+
117
+	/**
118
+	 * Sets button_url
119
+	 *
120
+	 * @param string $button_url
121
+	 */
122
+	public function set_button_url($button_url)
123
+	{
124
+		$this->set('PMD_button_url', $button_url);
125
+	}
126
+
127
+
128
+	/**
129
+	 * Gets debug_mode
130
+	 *
131
+	 * @return boolean
132
+	 */
133
+	public function debug_mode()
134
+	{
135
+		return $this->get('PMD_debug_mode');
136
+	}
137
+
138
+
139
+	/**
140
+	 * Sets debug_mode
141
+	 *
142
+	 * @param boolean $debug_mode
143
+	 */
144
+	public function set_debug_mode($debug_mode)
145
+	{
146
+		$this->set('PMD_debug_mode', $debug_mode);
147
+	}
148
+
149
+
150
+	/**
151
+	 * Gets description
152
+	 *
153
+	 * @return string
154
+	 */
155
+	public function description()
156
+	{
157
+		return $this->get('PMD_desc');
158
+	}
159
+
160
+
161
+	/**
162
+	 * Sets description
163
+	 *
164
+	 * @param string $description
165
+	 */
166
+	public function set_description($description)
167
+	{
168
+		$this->set('PMD_desc', $description);
169
+	}
170
+
171
+
172
+	/**
173
+	 * Gets name
174
+	 *
175
+	 * @return string
176
+	 */
177
+	public function name()
178
+	{
179
+		return $this->get('PMD_name');
180
+	}
181
+
182
+
183
+	/**
184
+	 * Sets name
185
+	 *
186
+	 * @param string $name
187
+	 */
188
+	public function set_name($name)
189
+	{
190
+		$this->set('PMD_name', $name);
191
+	}
192
+
193
+
194
+	/**
195
+	 * Gets open_by_default
196
+	 *
197
+	 * @return boolean
198
+	 */
199
+	public function open_by_default()
200
+	{
201
+		return $this->get('PMD_open_by_default');
202
+	}
203
+
204
+
205
+	/**
206
+	 * Sets open_by_default
207
+	 *
208
+	 * @param boolean $open_by_default
209
+	 */
210
+	public function set_open_by_default($open_by_default)
211
+	{
212
+		$this->set('PMD_open_by_default', $open_by_default);
213
+	}
214
+
215
+
216
+	/**
217
+	 * Gets order
218
+	 *
219
+	 * @return int
220
+	 */
221
+	public function order()
222
+	{
223
+		return $this->get('PMD_order');
224
+	}
225
+
226
+
227
+	/**
228
+	 * Sets order
229
+	 *
230
+	 * @param int $order
231
+	 */
232
+	public function set_order($order)
233
+	{
234
+		$this->set('PMD_order', $order);
235
+	}
236
+
237
+
238
+	/**
239
+	 * Gets slug
240
+	 *
241
+	 * @return string
242
+	 */
243
+	public function slug()
244
+	{
245
+		return $this->get('PMD_slug');
246
+	}
247
+
248
+
249
+	/**
250
+	 * Sets slug
251
+	 *
252
+	 * @param string $slug
253
+	 */
254
+	public function set_slug($slug)
255
+	{
256
+		$this->set('PMD_slug', $slug);
257
+	}
258
+
259
+
260
+	/**
261
+	 * Gets type
262
+	 *
263
+	 * @return string
264
+	 */
265
+	public function type()
266
+	{
267
+		return $this->get('PMD_type');
268
+	}
269
+
270
+
271
+	/**
272
+	 * Sets type
273
+	 *
274
+	 * @param string $type
275
+	 */
276
+	public function set_type($type)
277
+	{
278
+		$this->set('PMD_type', $type);
279
+	}
280
+
281
+
282
+	/**
283
+	 * Gets wp_user
284
+	 *
285
+	 * @return int
286
+	 */
287
+	public function wp_user()
288
+	{
289
+		return $this->get('PMD_wp_user');
290
+	}
291
+
292
+
293
+	/**
294
+	 * Sets wp_user
295
+	 *
296
+	 * @param int $wp_user_id
297
+	 */
298
+	public function set_wp_user($wp_user_id)
299
+	{
300
+		$this->set('PMD_wp_user', $wp_user_id);
301
+	}
302
+
303
+	/**
304
+	 * Overrides parent so when PMD_type is changed we refresh the _type_obj
305
+	 *
306
+	 * @param string $field_name
307
+	 * @param mixed $field_value
308
+	 * @param boolean $use_default
309
+	 */
310
+	public function set($field_name, $field_value, $use_default = false)
311
+	{
312
+		if ($field_name === 'PMD_type') {
313
+			// the type has probably changed, so forget about its old type object
314
+			$this->_type_obj = null;
315
+		}
316
+		parent::set($field_name, $field_value, $use_default);
317
+	}
318
+
319
+
320
+	/**
321
+	 * Gets admin_name
322
+	 *
323
+	 * @return string
324
+	 */
325
+	public function admin_name()
326
+	{
327
+		return $this->get('PMD_admin_name');
328
+	}
329
+
330
+
331
+	/**
332
+	 * Sets admin_name
333
+	 *
334
+	 * @param string $admin_name
335
+	 */
336
+	public function set_admin_name($admin_name)
337
+	{
338
+		$this->set('PMD_admin_name', $admin_name);
339
+	}
340
+
341
+
342
+	/**
343
+	 * Gets admin_desc
344
+	 *
345
+	 * @return string
346
+	 */
347
+	public function admin_desc()
348
+	{
349
+		return $this->get('PMD_admin_desc');
350
+	}
351
+
352
+
353
+	/**
354
+	 * Sets admin_desc
355
+	 *
356
+	 * @param string $admin_desc
357
+	 */
358
+	public function set_admin_desc($admin_desc)
359
+	{
360
+		$this->set('PMD_admin_desc', $admin_desc);
361
+	}
362
+
363
+
364
+	/**
365
+	 * Gets scope
366
+	 *
367
+	 * @return array
368
+	 */
369
+	public function scope()
370
+	{
371
+		return $this->get('PMD_scope');
372
+	}
373
+
374
+
375
+	/**
376
+	 * Sets scope
377
+	 *
378
+	 * @param array $scope
379
+	 */
380
+	public function set_scope($scope)
381
+	{
382
+		$this->set('PMD_scope', $scope);
383
+	}
384
+
385
+
386
+	/**
387
+	 * Gets the payment method type for this payment method instance
388
+	 *
389
+	 * @return EE_PMT_Base
390
+	 * @throws EE_Error
391
+	 */
392
+	public function type_obj()
393
+	{
394
+		if (! $this->_type_obj) {
395
+			EE_Registry::instance()->load_lib('Payment_Method_Manager');
396
+			if (EE_Payment_Method_Manager::instance()->payment_method_type_exists($this->type())) {
397
+				$class_name = EE_Payment_Method_Manager::instance()->payment_method_class_from_type($this->type());
398
+				if (! class_exists($class_name)) {
399
+					throw new EE_Error(
400
+						sprintf(
401
+							__(
402
+								'An attempt to use the "%1$s" payment method failed, so it was deactivated.%2$sWas the "%1$s" Plugin recently deactivated? It can be reactivated on the %3$sPlugins Admin Page%4$s',
403
+								'event_espresso'
404
+							),
405
+							$class_name,
406
+							'<br />',
407
+							'<a href="' . admin_url('plugins.php') . '">',
408
+							'</a>'
409
+						)
410
+					);
411
+				}
412
+				$r = new ReflectionClass($class_name);
413
+				$this->_type_obj = $r->newInstanceArgs(array($this));
414
+			} else {
415
+				throw new EE_Error(
416
+					sprintf(
417
+						__(
418
+							'A payment method of type "%1$s" does not exist. Only ones existing are: %2$s',
419
+							'event_espresso'
420
+						),
421
+						$this->type(),
422
+						implode(',', EE_Payment_Method_Manager::instance()->payment_method_type_names())
423
+					)
424
+				);
425
+			}
426
+		}
427
+		return $this->_type_obj;
428
+	}
429
+
430
+
431
+	/**
432
+	 * Returns a simple array of key-value pairs combining the payment method's fields (without the 'PMD_' prefix)
433
+	 * and the extra meta. Mostly used for passing off ot gateways.     *
434
+	 *
435
+	 * @return array
436
+	 */
437
+	public function settings_array()
438
+	{
439
+		$fields = $this->model_field_array();
440
+		$extra_meta = $this->all_extra_meta_array();
441
+		// remove the model's prefix from the fields
442
+		$combined_settings_array = array();
443
+		foreach ($fields as $key => $value) {
444
+			if (strpos($key, 'PMD_') === 0) {
445
+				$key_sans_model_prefix = str_replace('PMD_', '', $key);
446
+				$combined_settings_array [ $key_sans_model_prefix ] = $value;
447
+			}
448
+		}
449
+		$combined_settings_array = array_merge($extra_meta, $combined_settings_array);
450
+		return $combined_settings_array;
451
+	}
452
+
453
+
454
+	/**
455
+	 * Gets the HTML for displaying the payment method on a page.
456
+	 *
457
+	 * @param string $url
458
+	 * @param string $css_class
459
+	 * @return string of HTML for displaying the button
460
+	 * @throws \EE_Error
461
+	 */
462
+	public function button_html($url = '', $css_class = '')
463
+	{
464
+		$payment_occurs = $this->type_obj()->payment_occurs();
465
+		return '
466 466
 		 <div id="'
467
-               . $this->slug()
468
-               . '-payment-option-dv" class="'
469
-               . $payment_occurs . '-payment-gateway reg-page-payment-option-dv' . $css_class . '">
467
+			   . $this->slug()
468
+			   . '-payment-option-dv" class="'
469
+			   . $payment_occurs . '-payment-gateway reg-page-payment-option-dv' . $css_class . '">
470 470
 			<a id="payment-gateway-button-' . $this->slug()
471
-               . '" class="reg-page-payment-option-lnk" rel="'
472
-               . $this->slug() . '" href="' . $url . '" >
471
+			   . '" class="reg-page-payment-option-lnk" rel="'
472
+			   . $this->slug() . '" href="' . $url . '" >
473 473
 				<img src="' . $this->button_url() . '" alt="' . sprintf(
474
-                   esc_attr__('Pay using %s', 'event_espresso'),
475
-                   $this->get_pretty('PMD_name', 'form_input')
476
-               ) . '" />
474
+				   esc_attr__('Pay using %s', 'event_espresso'),
475
+				   $this->get_pretty('PMD_name', 'form_input')
476
+			   ) . '" />
477 477
 			</a>
478 478
 		</div>
479 479
 ';
480
-    }
481
-
482
-
483
-    /**
484
-     * Gets all the currencies which are an option for this payment method
485
-     * (as defined by the gateway and the currently active currencies)
486
-     *
487
-     * @return EE_Currency[]
488
-     * @throws \EE_Error
489
-     */
490
-    public function get_all_usable_currencies()
491
-    {
492
-        return EEM_Currency::instance()->get_all_currencies_usable_by($this->type_obj());
493
-    }
494
-
495
-
496
-    /**
497
-     * Reports whether or not this payment method can be used for this payment method
498
-     *
499
-     * @param string $currency_code currency ID (code)
500
-     * @return boolean
501
-     * @throws \EE_Error
502
-     */
503
-    public function usable_for_currency($currency_code)
504
-    {
505
-        foreach ($this->get_all_usable_currencies() as $currency_obj) {
506
-            if ($currency_obj->ID() === $currency_code) {
507
-                return true;
508
-            }
509
-        }
510
-        return false;
511
-    }
512
-
513
-
514
-    /**
515
-     * Returns TRUE if this payment method's gateway is an instance of EE_Onsite_Gateway
516
-     *
517
-     * @return bool
518
-     * @throws \EE_Error
519
-     */
520
-    public function is_on_site()
521
-    {
522
-        return $this->type_obj()->payment_occurs() === EE_PMT_Base::onsite;
523
-    }
524
-
525
-
526
-    /**
527
-     * Returns TRUE if this payment method's gateway is an instance of EE_Offsite_Gateway
528
-     *
529
-     * @return bool
530
-     * @throws \EE_Error
531
-     */
532
-    public function is_off_site()
533
-    {
534
-        return $this->type_obj()->payment_occurs() === EE_PMT_Base::offsite;
535
-    }
536
-
537
-
538
-    /**
539
-     * Returns TRUE if this payment method does not utilize a gateway
540
-     *
541
-     * @return bool
542
-     * @throws \EE_Error
543
-     */
544
-    public function is_off_line()
545
-    {
546
-        return $this->type_obj()->payment_occurs() === EE_PMT_Base::offline;
547
-    }
548
-
549
-    /**
550
-     * Overrides default __sleep so the object type is NOT cached.
551
-     * This way we can rely on the normal EE_Payment_Method::type_obj() logic
552
-     * to load the required classes, and don't need them at the time of unserialization
553
-     *
554
-     * @return array
555
-     */
556
-    public function __sleep()
557
-    {
558
-        $properties = get_object_vars($this);
559
-        unset($properties['_type_obj']);
560
-        return array_keys($properties);
561
-    }
562
-
563
-
564
-    /**
565
-     * Overrides parent to add some logging for when payment methods get deactivated
566
-     *
567
-     * @param array $set_cols_n_values
568
-     * @return int @see EE_Base_Class::save()
569
-     * @throws \EE_Error
570
-     */
571
-    public function save($set_cols_n_values = array())
572
-    {
573
-        $results = parent::save($set_cols_n_values);
574
-        if ($this->get_original('PMD_scope') !== $this->get('PMD_scope')) {
575
-            EE_Log::instance()->log(
576
-                __FILE__,
577
-                __FUNCTION__,
578
-                sprintf(
579
-                    __('Set new scope on payment method %1$s to %2$s from %3$s on URL %4$s', 'event_espresso'),
580
-                    $this->name(),
581
-                    serialize($this->get_original('PMD_scope')),
582
-                    serialize($this->get('PMD_scope')),
583
-                    EE_Registry::instance()->REQ->get_current_page_permalink()
584
-                ),
585
-                'payment_method_change'
586
-            );
587
-        }
588
-        return $results;
589
-    }
480
+	}
481
+
482
+
483
+	/**
484
+	 * Gets all the currencies which are an option for this payment method
485
+	 * (as defined by the gateway and the currently active currencies)
486
+	 *
487
+	 * @return EE_Currency[]
488
+	 * @throws \EE_Error
489
+	 */
490
+	public function get_all_usable_currencies()
491
+	{
492
+		return EEM_Currency::instance()->get_all_currencies_usable_by($this->type_obj());
493
+	}
494
+
495
+
496
+	/**
497
+	 * Reports whether or not this payment method can be used for this payment method
498
+	 *
499
+	 * @param string $currency_code currency ID (code)
500
+	 * @return boolean
501
+	 * @throws \EE_Error
502
+	 */
503
+	public function usable_for_currency($currency_code)
504
+	{
505
+		foreach ($this->get_all_usable_currencies() as $currency_obj) {
506
+			if ($currency_obj->ID() === $currency_code) {
507
+				return true;
508
+			}
509
+		}
510
+		return false;
511
+	}
512
+
513
+
514
+	/**
515
+	 * Returns TRUE if this payment method's gateway is an instance of EE_Onsite_Gateway
516
+	 *
517
+	 * @return bool
518
+	 * @throws \EE_Error
519
+	 */
520
+	public function is_on_site()
521
+	{
522
+		return $this->type_obj()->payment_occurs() === EE_PMT_Base::onsite;
523
+	}
524
+
525
+
526
+	/**
527
+	 * Returns TRUE if this payment method's gateway is an instance of EE_Offsite_Gateway
528
+	 *
529
+	 * @return bool
530
+	 * @throws \EE_Error
531
+	 */
532
+	public function is_off_site()
533
+	{
534
+		return $this->type_obj()->payment_occurs() === EE_PMT_Base::offsite;
535
+	}
536
+
537
+
538
+	/**
539
+	 * Returns TRUE if this payment method does not utilize a gateway
540
+	 *
541
+	 * @return bool
542
+	 * @throws \EE_Error
543
+	 */
544
+	public function is_off_line()
545
+	{
546
+		return $this->type_obj()->payment_occurs() === EE_PMT_Base::offline;
547
+	}
548
+
549
+	/**
550
+	 * Overrides default __sleep so the object type is NOT cached.
551
+	 * This way we can rely on the normal EE_Payment_Method::type_obj() logic
552
+	 * to load the required classes, and don't need them at the time of unserialization
553
+	 *
554
+	 * @return array
555
+	 */
556
+	public function __sleep()
557
+	{
558
+		$properties = get_object_vars($this);
559
+		unset($properties['_type_obj']);
560
+		return array_keys($properties);
561
+	}
562
+
563
+
564
+	/**
565
+	 * Overrides parent to add some logging for when payment methods get deactivated
566
+	 *
567
+	 * @param array $set_cols_n_values
568
+	 * @return int @see EE_Base_Class::save()
569
+	 * @throws \EE_Error
570
+	 */
571
+	public function save($set_cols_n_values = array())
572
+	{
573
+		$results = parent::save($set_cols_n_values);
574
+		if ($this->get_original('PMD_scope') !== $this->get('PMD_scope')) {
575
+			EE_Log::instance()->log(
576
+				__FILE__,
577
+				__FUNCTION__,
578
+				sprintf(
579
+					__('Set new scope on payment method %1$s to %2$s from %3$s on URL %4$s', 'event_espresso'),
580
+					$this->name(),
581
+					serialize($this->get_original('PMD_scope')),
582
+					serialize($this->get('PMD_scope')),
583
+					EE_Registry::instance()->REQ->get_current_page_permalink()
584
+				),
585
+				'payment_method_change'
586
+			);
587
+		}
588
+		return $results;
589
+	}
590 590
 }
Please login to merge, or discard this patch.
core/db_classes/EE_Event_Venue.class.php 1 patch
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -6,23 +6,23 @@
 block discarded – undo
6 6
 class EE_Event_Venue extends EE_Base_Class
7 7
 {
8 8
 
9
-    /**
10
-     * @param array $props_n_values
11
-     * @return EE_Event_Venue|mixed
12
-     */
13
-    public static function new_instance($props_n_values = array())
14
-    {
15
-        $has_object = parent::_check_for_object($props_n_values, __CLASS__);
16
-        return $has_object ? $has_object : new self($props_n_values);
17
-    }
9
+	/**
10
+	 * @param array $props_n_values
11
+	 * @return EE_Event_Venue|mixed
12
+	 */
13
+	public static function new_instance($props_n_values = array())
14
+	{
15
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__);
16
+		return $has_object ? $has_object : new self($props_n_values);
17
+	}
18 18
 
19 19
 
20
-    /**
21
-     * @param array $props_n_values
22
-     * @return EE_Event_Venue
23
-     */
24
-    public static function new_instance_from_db($props_n_values = array())
25
-    {
26
-        return new self($props_n_values, true);
27
-    }
20
+	/**
21
+	 * @param array $props_n_values
22
+	 * @return EE_Event_Venue
23
+	 */
24
+	public static function new_instance_from_db($props_n_values = array())
25
+	{
26
+		return new self($props_n_values, true);
27
+	}
28 28
 }
Please login to merge, or discard this patch.
core/db_classes/EE_Soft_Delete_Base_Class.class.php 1 patch
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -12,53 +12,53 @@
 block discarded – undo
12 12
 {
13 13
 
14 14
 
15
-    /**
16
-     * Overrides parent _delete() so that we do soft deletes.
17
-     *
18
-     * @return bool|int
19
-     */
20
-    protected function _delete()
21
-    {
22
-        return $this->delete_or_restore();
23
-    }
15
+	/**
16
+	 * Overrides parent _delete() so that we do soft deletes.
17
+	 *
18
+	 * @return bool|int
19
+	 */
20
+	protected function _delete()
21
+	{
22
+		return $this->delete_or_restore();
23
+	}
24 24
 
25 25
 
26
-    /**
27
-     * Deletes or restores this object.
28
-     *
29
-     * @param bool $delete true=>delete, false=>restore
30
-     * @return bool|int
31
-     */
32
-    public function delete_or_restore($delete = true)
33
-    {
34
-        /**
35
-         * Called just before trashing (soft delete) or restoring a trashed item.
36
-         *
37
-         * @param EE_Base_Class $model_object about to be trashed or restored
38
-         * @param bool          $delete       true the item is being trashed, false the item is being restored.
39
-         */
40
-        do_action('AHEE__EE_Soft_Delete_Base_Class__delete_or_restore__before', $this, $delete);
41
-        $model = $this->get_model();
42
-        $result = $model->delete_or_restore_by_ID($delete, $this->ID());
43
-        /**
44
-         * Called just after trashing (soft delete) or restoring a trashed item.
45
-         *
46
-         * @param EE_Base_Class $model_object that was just trashed or restored.
47
-         * @param bool          $delete       true the item is being trashed, false the item is being restored.
48
-         * @param bool|int      $result
49
-         */
50
-        do_action('AHEE__EE_Soft_Delete_Base_Class__delete_or_restore__after', $this, $delete, $result);
51
-        return $result;
52
-    }
26
+	/**
27
+	 * Deletes or restores this object.
28
+	 *
29
+	 * @param bool $delete true=>delete, false=>restore
30
+	 * @return bool|int
31
+	 */
32
+	public function delete_or_restore($delete = true)
33
+	{
34
+		/**
35
+		 * Called just before trashing (soft delete) or restoring a trashed item.
36
+		 *
37
+		 * @param EE_Base_Class $model_object about to be trashed or restored
38
+		 * @param bool          $delete       true the item is being trashed, false the item is being restored.
39
+		 */
40
+		do_action('AHEE__EE_Soft_Delete_Base_Class__delete_or_restore__before', $this, $delete);
41
+		$model = $this->get_model();
42
+		$result = $model->delete_or_restore_by_ID($delete, $this->ID());
43
+		/**
44
+		 * Called just after trashing (soft delete) or restoring a trashed item.
45
+		 *
46
+		 * @param EE_Base_Class $model_object that was just trashed or restored.
47
+		 * @param bool          $delete       true the item is being trashed, false the item is being restored.
48
+		 * @param bool|int      $result
49
+		 */
50
+		do_action('AHEE__EE_Soft_Delete_Base_Class__delete_or_restore__after', $this, $delete, $result);
51
+		return $result;
52
+	}
53 53
 
54 54
 
55
-    /**
56
-     * Performs a restoration (un-deletes) this object
57
-     *
58
-     * @return bool|int
59
-     */
60
-    public function restore()
61
-    {
62
-        return $this->delete_or_restore(false);
63
-    }
55
+	/**
56
+	 * Performs a restoration (un-deletes) this object
57
+	 *
58
+	 * @return bool|int
59
+	 */
60
+	public function restore()
61
+	{
62
+		return $this->delete_or_restore(false);
63
+	}
64 64
 }
Please login to merge, or discard this patch.
core/db_classes/EE_Event_Question_Group.class.php 1 patch
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -6,23 +6,23 @@
 block discarded – undo
6 6
 class EE_Event_Question_Group extends EE_Base_Class
7 7
 {
8 8
 
9
-    /**
10
-     * @param array $props_n_values
11
-     * @return EE_Event_Question_Group|mixed
12
-     */
13
-    public static function new_instance($props_n_values = array())
14
-    {
15
-        $has_object = parent::_check_for_object($props_n_values, __CLASS__);
16
-        return $has_object ? $has_object : new self($props_n_values);
17
-    }
9
+	/**
10
+	 * @param array $props_n_values
11
+	 * @return EE_Event_Question_Group|mixed
12
+	 */
13
+	public static function new_instance($props_n_values = array())
14
+	{
15
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__);
16
+		return $has_object ? $has_object : new self($props_n_values);
17
+	}
18 18
 
19 19
 
20
-    /**
21
-     * @param array $props_n_values
22
-     * @return EE_Event_Question_Group
23
-     */
24
-    public static function new_instance_from_db($props_n_values = array())
25
-    {
26
-        return new self($props_n_values, true);
27
-    }
20
+	/**
21
+	 * @param array $props_n_values
22
+	 * @return EE_Event_Question_Group
23
+	 */
24
+	public static function new_instance_from_db($props_n_values = array())
25
+	{
26
+		return new self($props_n_values, true);
27
+	}
28 28
 }
Please login to merge, or discard this patch.
core/db_classes/EE_Payment.class.php 3 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
      */
297 297
     public function timestamp($dt_frmt = '', $tm_frmt = '')
298 298
     {
299
-        return $this->get_i18n_datetime('PAY_timestamp', trim($dt_frmt . ' ' . $tm_frmt));
299
+        return $this->get_i18n_datetime('PAY_timestamp', trim($dt_frmt.' '.$tm_frmt));
300 300
     }
301 301
 
302 302
 
@@ -481,7 +481,7 @@  discard block
 block discarded – undo
481 481
                     : '';
482 482
                 break;
483 483
         }
484
-        return $icon . $status[ $this->STS_ID() ];
484
+        return $icon.$status[$this->STS_ID()];
485 485
     }
486 486
 
487 487
 
@@ -627,7 +627,7 @@  discard block
 block discarded – undo
627 627
     public function redirect_form($inside_form_html = null)
628 628
     {
629 629
         $redirect_url = $this->redirect_url();
630
-        if (! empty($redirect_url)) {
630
+        if ( ! empty($redirect_url)) {
631 631
             // what ? no inner form content?
632 632
             if ($inside_form_html === null) {
633 633
                 $inside_form_html = EEH_HTML::p(
@@ -657,7 +657,7 @@  discard block
 block discarded – undo
657 657
                 $get_params = null;
658 658
                 parse_str($querystring, $get_params);
659 659
                 $inside_form_html .= $this->_args_as_inputs($get_params);
660
-                $redirect_url = str_replace('?' . $querystring, '', $redirect_url);
660
+                $redirect_url = str_replace('?'.$querystring, '', $redirect_url);
661 661
             }
662 662
             $form = EEH_HTML::nl(1)
663 663
                     . '<form method="'
@@ -665,9 +665,9 @@  discard block
 block discarded – undo
665 665
                     . '" name="gateway_form" action="'
666 666
                     . $redirect_url
667 667
                     . '">';
668
-            $form .= EEH_HTML::nl(1) . $this->redirect_args_as_inputs();
668
+            $form .= EEH_HTML::nl(1).$this->redirect_args_as_inputs();
669 669
             $form .= $inside_form_html;
670
-            $form .= EEH_HTML::nl(-1) . '</form>' . EEH_HTML::nl(-1);
670
+            $form .= EEH_HTML::nl(-1).'</form>'.EEH_HTML::nl(-1);
671 671
             return $form;
672 672
         } else {
673 673
             return null;
Please login to merge, or discard this patch.
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
      * @param array  $props_n_values          incoming values
14 14
      * @param string $timezone                incoming timezone (if not set the timezone set for the website will be
15 15
      *                                        used.)
16
-     * @param array  $date_formats            incoming date_formats in an array where the first value is the
16
+     * @param string[]  $date_formats            incoming date_formats in an array where the first value is the
17 17
      *                                        date_format and the second value is the time format
18 18
      * @return EE_Payment
19 19
      * @throws \EE_Error
@@ -588,7 +588,7 @@  discard block
 block discarded – undo
588 588
      * Gets all the extra meta info on this payment
589 589
      *
590 590
      * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
591
-     * @return EE_Extra_Meta
591
+     * @return EE_Base_Class[]
592 592
      * @throws \EE_Error
593 593
      */
594 594
     public function extra_meta($query_params = array())
@@ -836,7 +836,7 @@  discard block
 block discarded – undo
836 836
     /**
837 837
      * Returns the payment's transaction's primary registration
838 838
      *
839
-     * @return EE_Registration|null
839
+     * @return EE_Base_Class|null
840 840
      */
841 841
     public function get_primary_registration()
842 842
     {
Please login to merge, or discard this patch.
Indentation   +852 added lines, -852 removed lines patch added patch discarded remove patch
@@ -10,856 +10,856 @@
 block discarded – undo
10 10
 class EE_Payment extends EE_Base_Class implements EEI_Payment
11 11
 {
12 12
 
13
-    /**
14
-     * @param array  $props_n_values          incoming values
15
-     * @param string $timezone                incoming timezone (if not set the timezone set for the website will be
16
-     *                                        used.)
17
-     * @param array  $date_formats            incoming date_formats in an array where the first value is the
18
-     *                                        date_format and the second value is the time format
19
-     * @return EE_Payment
20
-     * @throws \EE_Error
21
-     */
22
-    public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array())
23
-    {
24
-        $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
25
-        return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
26
-    }
27
-
28
-
29
-    /**
30
-     * @param array  $props_n_values  incoming values from the database
31
-     * @param string $timezone        incoming timezone as set by the model.  If not set the timezone for
32
-     *                                the website will be used.
33
-     * @return EE_Payment
34
-     * @throws \EE_Error
35
-     */
36
-    public static function new_instance_from_db($props_n_values = array(), $timezone = null)
37
-    {
38
-        return new self($props_n_values, true, $timezone);
39
-    }
40
-
41
-
42
-    /**
43
-     * Set Transaction ID
44
-     *
45
-     * @access public
46
-     * @param int $TXN_ID
47
-     * @throws \EE_Error
48
-     */
49
-    public function set_transaction_id($TXN_ID = 0)
50
-    {
51
-        $this->set('TXN_ID', $TXN_ID);
52
-    }
53
-
54
-
55
-    /**
56
-     * Gets the transaction related to this payment
57
-     *
58
-     * @return EE_Transaction
59
-     * @throws \EE_Error
60
-     */
61
-    public function transaction()
62
-    {
63
-        return $this->get_first_related('Transaction');
64
-    }
65
-
66
-
67
-    /**
68
-     * Set Status
69
-     *
70
-     * @access public
71
-     * @param string $STS_ID
72
-     * @throws \EE_Error
73
-     */
74
-    public function set_status($STS_ID = '')
75
-    {
76
-        $this->set('STS_ID', $STS_ID);
77
-    }
78
-
79
-
80
-    /**
81
-     * Set Payment Timestamp
82
-     *
83
-     * @access public
84
-     * @param int $timestamp
85
-     * @throws \EE_Error
86
-     */
87
-    public function set_timestamp($timestamp = 0)
88
-    {
89
-        $this->set('PAY_timestamp', $timestamp);
90
-    }
91
-
92
-
93
-    /**
94
-     * Set Payment Method
95
-     *
96
-     * @access public
97
-     * @param string $PAY_source
98
-     * @throws \EE_Error
99
-     */
100
-    public function set_source($PAY_source = '')
101
-    {
102
-        $this->set('PAY_source', $PAY_source);
103
-    }
104
-
105
-
106
-    /**
107
-     * Set Payment Amount
108
-     *
109
-     * @access public
110
-     * @param float $amount
111
-     * @throws \EE_Error
112
-     */
113
-    public function set_amount($amount = 0.00)
114
-    {
115
-        $this->set('PAY_amount', (float) $amount);
116
-    }
117
-
118
-
119
-    /**
120
-     * Set Payment Gateway Response
121
-     *
122
-     * @access public
123
-     * @param string $gateway_response
124
-     * @throws \EE_Error
125
-     */
126
-    public function set_gateway_response($gateway_response = '')
127
-    {
128
-        $this->set('PAY_gateway_response', $gateway_response);
129
-    }
130
-
131
-
132
-    /**
133
-     * Returns the name of the payment method used on this payment (previously known merely as 'gateway')
134
-     * but since 4.6.0, payment methods are models and the payment keeps a foreign key to the payment method
135
-     * used on it
136
-     *
137
-     * @deprecated
138
-     * @return string
139
-     * @throws \EE_Error
140
-     */
141
-    public function gateway()
142
-    {
143
-        EE_Error::doing_it_wrong(
144
-            'EE_Payment::gateway',
145
-            __(
146
-                'The method EE_Payment::gateway() has been deprecated. Consider instead using EE_Payment::payment_method()->name()',
147
-                'event_espresso'
148
-            ),
149
-            '4.6.0'
150
-        );
151
-        return $this->payment_method() ? $this->payment_method()->name() : __('Unknown', 'event_espresso');
152
-    }
153
-
154
-
155
-    /**
156
-     * Set Gateway Transaction ID
157
-     *
158
-     * @access public
159
-     * @param string $txn_id_chq_nmbr
160
-     * @throws \EE_Error
161
-     */
162
-    public function set_txn_id_chq_nmbr($txn_id_chq_nmbr = '')
163
-    {
164
-        $this->set('PAY_txn_id_chq_nmbr', $txn_id_chq_nmbr);
165
-    }
166
-
167
-
168
-    /**
169
-     * Set Purchase Order Number
170
-     *
171
-     * @access public
172
-     * @param string $po_number
173
-     * @throws \EE_Error
174
-     */
175
-    public function set_po_number($po_number = '')
176
-    {
177
-        $this->set('PAY_po_number', $po_number);
178
-    }
179
-
180
-
181
-    /**
182
-     * Set Extra Accounting Field
183
-     *
184
-     * @access public
185
-     * @param string $extra_accntng
186
-     * @throws \EE_Error
187
-     */
188
-    public function set_extra_accntng($extra_accntng = '')
189
-    {
190
-        $this->set('PAY_extra_accntng', $extra_accntng);
191
-    }
192
-
193
-
194
-    /**
195
-     * Set Payment made via admin flag
196
-     *
197
-     * @access public
198
-     * @param bool $via_admin
199
-     * @throws \EE_Error
200
-     */
201
-    public function set_payment_made_via_admin($via_admin = false)
202
-    {
203
-        if ($via_admin) {
204
-            $this->set('PAY_source', EEM_Payment_Method::scope_admin);
205
-        } else {
206
-            $this->set('PAY_source', EEM_Payment_Method::scope_cart);
207
-        }
208
-    }
209
-
210
-
211
-    /**
212
-     * Set Payment Details
213
-     *
214
-     * @access public
215
-     * @param string|array $details
216
-     * @throws \EE_Error
217
-     */
218
-    public function set_details($details = '')
219
-    {
220
-        if (is_array($details)) {
221
-            array_walk_recursive($details, array($this, '_strip_all_tags_within_array'));
222
-        } else {
223
-            $details = wp_strip_all_tags($details);
224
-        }
225
-        $this->set('PAY_details', $details);
226
-    }
227
-
228
-
229
-    /**
230
-     * Sets redirect_url
231
-     *
232
-     * @param string $redirect_url
233
-     * @throws \EE_Error
234
-     */
235
-    public function set_redirect_url($redirect_url)
236
-    {
237
-        $this->set('PAY_redirect_url', $redirect_url);
238
-    }
239
-
240
-
241
-    /**
242
-     * Sets redirect_args
243
-     *
244
-     * @param array $redirect_args
245
-     * @throws \EE_Error
246
-     */
247
-    public function set_redirect_args($redirect_args)
248
-    {
249
-        $this->set('PAY_redirect_args', $redirect_args);
250
-    }
251
-
252
-
253
-    /**
254
-     * get Payment Transaction ID
255
-     *
256
-     * @access public
257
-     * @throws \EE_Error
258
-     */
259
-    public function TXN_ID()
260
-    {
261
-        return $this->get('TXN_ID');
262
-    }
263
-
264
-
265
-    /**
266
-     * get Payment Status
267
-     *
268
-     * @access public
269
-     * @throws \EE_Error
270
-     */
271
-    public function status()
272
-    {
273
-        return $this->get('STS_ID');
274
-    }
275
-
276
-
277
-    /**
278
-     * get Payment Status
279
-     *
280
-     * @access public
281
-     * @throws \EE_Error
282
-     */
283
-    public function STS_ID()
284
-    {
285
-        return $this->get('STS_ID');
286
-    }
287
-
288
-
289
-    /**
290
-     * get Payment Timestamp
291
-     *
292
-     * @access public
293
-     * @param string $dt_frmt
294
-     * @param string $tm_frmt
295
-     * @return string
296
-     * @throws \EE_Error
297
-     */
298
-    public function timestamp($dt_frmt = '', $tm_frmt = '')
299
-    {
300
-        return $this->get_i18n_datetime('PAY_timestamp', trim($dt_frmt . ' ' . $tm_frmt));
301
-    }
302
-
303
-
304
-    /**
305
-     * get Payment Source
306
-     *
307
-     * @access public
308
-     * @throws \EE_Error
309
-     */
310
-    public function source()
311
-    {
312
-        return $this->get('PAY_source');
313
-    }
314
-
315
-
316
-    /**
317
-     * get Payment Amount
318
-     *
319
-     * @access public
320
-     * @return float
321
-     * @throws \EE_Error
322
-     */
323
-    public function amount()
324
-    {
325
-        return (float) $this->get('PAY_amount');
326
-    }
327
-
328
-
329
-    /**
330
-     * @return mixed
331
-     * @throws \EE_Error
332
-     */
333
-    public function amount_no_code()
334
-    {
335
-        return $this->get_pretty('PAY_amount', 'no_currency_code');
336
-    }
337
-
338
-
339
-    /**
340
-     * get Payment Gateway Response
341
-     *
342
-     * @access public
343
-     * @throws \EE_Error
344
-     */
345
-    public function gateway_response()
346
-    {
347
-        return $this->get('PAY_gateway_response');
348
-    }
349
-
350
-
351
-    /**
352
-     * get Payment Gateway Transaction ID
353
-     *
354
-     * @access public
355
-     * @throws \EE_Error
356
-     */
357
-    public function txn_id_chq_nmbr()
358
-    {
359
-        return $this->get('PAY_txn_id_chq_nmbr');
360
-    }
361
-
362
-
363
-    /**
364
-     * get Purchase Order Number
365
-     *
366
-     * @access public
367
-     * @throws \EE_Error
368
-     */
369
-    public function po_number()
370
-    {
371
-        return $this->get('PAY_po_number');
372
-    }
373
-
374
-
375
-    /**
376
-     * get Extra Accounting Field
377
-     *
378
-     * @access public
379
-     * @throws \EE_Error
380
-     */
381
-    public function extra_accntng()
382
-    {
383
-        return $this->get('PAY_extra_accntng');
384
-    }
385
-
386
-
387
-    /**
388
-     * get Payment made via admin source
389
-     *
390
-     * @access public
391
-     * @throws \EE_Error
392
-     */
393
-    public function payment_made_via_admin()
394
-    {
395
-        return ($this->get('PAY_source') === EEM_Payment_Method::scope_admin);
396
-    }
397
-
398
-
399
-    /**
400
-     * get Payment Details
401
-     *
402
-     * @access public
403
-     * @throws \EE_Error
404
-     */
405
-    public function details()
406
-    {
407
-        return $this->get('PAY_details');
408
-    }
409
-
410
-
411
-    /**
412
-     * Gets redirect_url
413
-     *
414
-     * @return string
415
-     * @throws \EE_Error
416
-     */
417
-    public function redirect_url()
418
-    {
419
-        return $this->get('PAY_redirect_url');
420
-    }
421
-
422
-
423
-    /**
424
-     * Gets redirect_args
425
-     *
426
-     * @return array
427
-     * @throws \EE_Error
428
-     */
429
-    public function redirect_args()
430
-    {
431
-        return $this->get('PAY_redirect_args');
432
-    }
433
-
434
-
435
-    /**
436
-     * echoes $this->pretty_status()
437
-     *
438
-     * @param bool $show_icons
439
-     * @return void
440
-     * @throws \EE_Error
441
-     */
442
-    public function e_pretty_status($show_icons = false)
443
-    {
444
-        echo $this->pretty_status($show_icons);
445
-    }
446
-
447
-
448
-    /**
449
-     * returns a pretty version of the status, good for displaying to users
450
-     *
451
-     * @param bool $show_icons
452
-     * @return string
453
-     * @throws \EE_Error
454
-     */
455
-    public function pretty_status($show_icons = false)
456
-    {
457
-        $status = EEM_Status::instance()->localized_status(
458
-            array($this->STS_ID() => __('unknown', 'event_espresso')),
459
-            false,
460
-            'sentence'
461
-        );
462
-        $icon = '';
463
-        switch ($this->STS_ID()) {
464
-            case EEM_Payment::status_id_approved:
465
-                $icon = $show_icons
466
-                    ? '<span class="dashicons dashicons-yes ee-icon-size-24 green-text"></span>'
467
-                    : '';
468
-                break;
469
-            case EEM_Payment::status_id_pending:
470
-                $icon = $show_icons
471
-                    ? '<span class="dashicons dashicons-clock ee-icon-size-16 orange-text"></span>'
472
-                    : '';
473
-                break;
474
-            case EEM_Payment::status_id_cancelled:
475
-                $icon = $show_icons
476
-                    ? '<span class="dashicons dashicons-no ee-icon-size-16 lt-grey-text"></span>'
477
-                    : '';
478
-                break;
479
-            case EEM_Payment::status_id_declined:
480
-                $icon = $show_icons
481
-                    ? '<span class="dashicons dashicons-no ee-icon-size-16 red-text"></span>'
482
-                    : '';
483
-                break;
484
-        }
485
-        return $icon . $status[ $this->STS_ID() ];
486
-    }
487
-
488
-
489
-    /**
490
-     * For determining the status of the payment
491
-     *
492
-     * @return boolean whether the payment is approved or not
493
-     * @throws \EE_Error
494
-     */
495
-    public function is_approved()
496
-    {
497
-        return $this->status_is(EEM_Payment::status_id_approved);
498
-    }
499
-
500
-
501
-    /**
502
-     * Generally determines if the status of this payment equals
503
-     * the $STS_ID string
504
-     *
505
-     * @param string $STS_ID an ID from the esp_status table/
506
-     *                       one of the status_id_* on the EEM_Payment model
507
-     * @return boolean whether the status of this payment equals the status id
508
-     * @throws \EE_Error
509
-     */
510
-    protected function status_is($STS_ID)
511
-    {
512
-        return $STS_ID === $this->STS_ID() ? true : false;
513
-    }
514
-
515
-
516
-    /**
517
-     * For determining the status of the payment
518
-     *
519
-     * @return boolean whether the payment is pending or not
520
-     * @throws \EE_Error
521
-     */
522
-    public function is_pending()
523
-    {
524
-        return $this->status_is(EEM_Payment::status_id_pending);
525
-    }
526
-
527
-
528
-    /**
529
-     * For determining the status of the payment
530
-     *
531
-     * @return boolean
532
-     * @throws \EE_Error
533
-     */
534
-    public function is_cancelled()
535
-    {
536
-        return $this->status_is(EEM_Payment::status_id_cancelled);
537
-    }
538
-
539
-
540
-    /**
541
-     * For determining the status of the payment
542
-     *
543
-     * @return boolean
544
-     * @throws \EE_Error
545
-     */
546
-    public function is_declined()
547
-    {
548
-        return $this->status_is(EEM_Payment::status_id_declined);
549
-    }
550
-
551
-
552
-    /**
553
-     * For determining the status of the payment
554
-     *
555
-     * @return boolean
556
-     * @throws \EE_Error
557
-     */
558
-    public function is_failed()
559
-    {
560
-        return $this->status_is(EEM_Payment::status_id_failed);
561
-    }
562
-
563
-
564
-    /**
565
-     * For determining if the payment is actually a refund ( ie: has a negative value )
566
-     *
567
-     * @return boolean
568
-     * @throws \EE_Error
569
-     */
570
-    public function is_a_refund()
571
-    {
572
-        return $this->amount() < 0 ? true : false;
573
-    }
574
-
575
-
576
-    /**
577
-     * Get the status object of this object
578
-     *
579
-     * @return EE_Status
580
-     * @throws \EE_Error
581
-     */
582
-    public function status_obj()
583
-    {
584
-        return $this->get_first_related('Status');
585
-    }
586
-
587
-
588
-    /**
589
-     * Gets all the extra meta info on this payment
590
-     *
591
-     * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
592
-     * @return EE_Extra_Meta
593
-     * @throws \EE_Error
594
-     */
595
-    public function extra_meta($query_params = array())
596
-    {
597
-        return $this->get_many_related('Extra_Meta', $query_params);
598
-    }
599
-
600
-
601
-    /**
602
-     * Gets the last-used payment method on this transaction
603
-     * (we COULD just use the last-made payment, but some payment methods, namely
604
-     * offline ones, dont' create payments)
605
-     *
606
-     * @return EE_Payment_Method
607
-     * @throws \EE_Error
608
-     */
609
-    public function payment_method()
610
-    {
611
-        return $this->get_first_related('Payment_Method');
612
-    }
613
-
614
-
615
-    /**
616
-     * Gets the HTML for redirecting the user to an offsite gateway
617
-     * You can pass it special content to put inside the form, or use
618
-     * the default inner content (or possibly generate this all yourself using
619
-     * redirect_url() and redirect_args() or redirect_args_as_inputs()).
620
-     * Creates a POST request by default, but if no redirect args are specified, creates a GET request instead
621
-     * (and any querystring variables in the redirect_url are converted into html inputs
622
-     * so browsers submit them properly)
623
-     *
624
-     * @param string $inside_form_html
625
-     * @return string html
626
-     * @throws \EE_Error
627
-     */
628
-    public function redirect_form($inside_form_html = null)
629
-    {
630
-        $redirect_url = $this->redirect_url();
631
-        if (! empty($redirect_url)) {
632
-            // what ? no inner form content?
633
-            if ($inside_form_html === null) {
634
-                $inside_form_html = EEH_HTML::p(
635
-                    sprintf(
636
-                        __(
637
-                            'If you are not automatically redirected to the payment website within 10 seconds... %1$s %2$s Click Here %3$s',
638
-                            'event_espresso'
639
-                        ),
640
-                        EEH_HTML::br(2),
641
-                        '<input type="submit" value="',
642
-                        '">'
643
-                    ),
644
-                    '',
645
-                    '',
646
-                    'text-align:center;'
647
-                );
648
-            }
649
-            $method = apply_filters(
650
-                'FHEE__EE_Payment__redirect_form__method',
651
-                $this->redirect_args() ? 'POST' : 'GET',
652
-                $this
653
-            );
654
-            // if it's a GET request, we need to remove all the GET params in the querystring
655
-            // and put them into the form instead
656
-            if ($method === 'GET') {
657
-                $querystring = parse_url($redirect_url, PHP_URL_QUERY);
658
-                $get_params = null;
659
-                parse_str($querystring, $get_params);
660
-                $inside_form_html .= $this->_args_as_inputs($get_params);
661
-                $redirect_url = str_replace('?' . $querystring, '', $redirect_url);
662
-            }
663
-            $form = EEH_HTML::nl(1)
664
-                    . '<form method="'
665
-                    . $method
666
-                    . '" name="gateway_form" action="'
667
-                    . $redirect_url
668
-                    . '">';
669
-            $form .= EEH_HTML::nl(1) . $this->redirect_args_as_inputs();
670
-            $form .= $inside_form_html;
671
-            $form .= EEH_HTML::nl(-1) . '</form>' . EEH_HTML::nl(-1);
672
-            return $form;
673
-        } else {
674
-            return null;
675
-        }
676
-    }
677
-
678
-
679
-    /**
680
-     * Changes all the name-value pairs of the redirect args into html inputs
681
-     * and returns the html as a string
682
-     *
683
-     * @return string
684
-     * @throws \EE_Error
685
-     */
686
-    public function redirect_args_as_inputs()
687
-    {
688
-        return $this->_args_as_inputs($this->redirect_args());
689
-    }
690
-
691
-
692
-    /**
693
-     * Converts a 1d array of key-value pairs into html hidden inputs
694
-     * and returns the string of html
695
-     *
696
-     * @param array $args key-value pairs
697
-     * @return string
698
-     */
699
-    protected function _args_as_inputs($args)
700
-    {
701
-        $html = '';
702
-        if ($args !== null && is_array($args)) {
703
-            foreach ($args as $name => $value) {
704
-                $html .= EEH_HTML::nl(0)
705
-                         . '<input type="hidden" name="'
706
-                         . $name
707
-                         . '" value="'
708
-                         . esc_attr($value)
709
-                         . '"/>';
710
-            }
711
-        }
712
-        return $html;
713
-    }
714
-
715
-
716
-    /**
717
-     * Returns the currency of the payment.
718
-     * (At the time of writing, this will always be the currency in the configuration;
719
-     * however in the future it is anticipated that this will be stored on the payment
720
-     * object itself)
721
-     *
722
-     * @return string for the currency code
723
-     */
724
-    public function currency_code()
725
-    {
726
-        return EE_Config::instance()->currency->code;
727
-    }
728
-
729
-
730
-    /**
731
-     * apply wp_strip_all_tags to all elements within an array
732
-     *
733
-     * @access private
734
-     * @param mixed $item
735
-     */
736
-    private function _strip_all_tags_within_array(&$item)
737
-    {
738
-        if (is_object($item)) {
739
-            $item = (array) $item;
740
-        }
741
-        if (is_array($item)) {
742
-            array_walk_recursive($item, array($this, '_strip_all_tags_within_array'));
743
-        } else {
744
-            $item = wp_strip_all_tags($item);
745
-        }
746
-    }
747
-
748
-
749
-    /**
750
-     * Returns TRUE is this payment was set to approved during this request (or
751
-     * is approved and was created during this request). False otherwise.
752
-     *
753
-     * @return boolean
754
-     * @throws \EE_Error
755
-     */
756
-    public function just_approved()
757
-    {
758
-        $original_status = EEH_Array::is_set(
759
-            $this->_props_n_values_provided_in_constructor,
760
-            'STS_ID',
761
-            $this->get_model()->field_settings_for('STS_ID')->get_default_value()
762
-        );
763
-        $current_status = $this->status();
764
-        if (
765
-            $original_status !== EEM_Payment::status_id_approved
766
-            && $current_status === EEM_Payment::status_id_approved
767
-        ) {
768
-            return true;
769
-        } else {
770
-            return false;
771
-        }
772
-    }
773
-
774
-
775
-    /**
776
-     * Overrides parents' get_pretty() function just for legacy reasons
777
-     * (to allow ticket https://events.codebasehq.com/projects/event-espresso/tickets/7420)
778
-     *
779
-     * @param string $field_name
780
-     * @param string $extra_cache_ref This allows the user to specify an extra cache ref for the given property
781
-     *                                (in cases where the same property may be used for different outputs
782
-     *                                - i.e. datetime, money etc.)
783
-     * @return mixed
784
-     * @throws \EE_Error
785
-     */
786
-    public function get_pretty($field_name, $extra_cache_ref = null)
787
-    {
788
-        if ($field_name === 'PAY_gateway') {
789
-            return $this->payment_method() ? $this->payment_method()->name() : __('Unknown', 'event_espresso');
790
-        }
791
-        return $this->_get_cached_property($field_name, true, $extra_cache_ref);
792
-    }
793
-
794
-
795
-    /**
796
-     * Gets details regarding which registrations this payment was applied to
797
-     *
798
-     * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
799
-     * @return EE_Registration_Payment[]
800
-     * @throws \EE_Error
801
-     */
802
-    public function registration_payments($query_params = array())
803
-    {
804
-        return $this->get_many_related('Registration_Payment', $query_params);
805
-    }
806
-
807
-
808
-    /**
809
-     * Gets the first event for this payment (it's possible that it could be for multiple)
810
-     *
811
-     * @return EE_Event|null
812
-     */
813
-    public function get_first_event()
814
-    {
815
-        $transaction = $this->transaction();
816
-        if ($transaction instanceof EE_Transaction) {
817
-            $primary_registrant = $transaction->primary_registration();
818
-            if ($primary_registrant instanceof EE_Registration) {
819
-                return $primary_registrant->event_obj();
820
-            }
821
-        }
822
-        return null;
823
-    }
824
-
825
-
826
-    /**
827
-     * Gets the name of the first event for which is being paid
828
-     *
829
-     * @return string
830
-     */
831
-    public function get_first_event_name()
832
-    {
833
-        $event = $this->get_first_event();
834
-        return $event instanceof EE_Event ? $event->name() : __('Event', 'event_espresso');
835
-    }
836
-
837
-
838
-    /**
839
-     * Returns the payment's transaction's primary registration
840
-     *
841
-     * @return EE_Registration|null
842
-     */
843
-    public function get_primary_registration()
844
-    {
845
-        if ($this->transaction() instanceof EE_Transaction) {
846
-            return $this->transaction()->primary_registration();
847
-        }
848
-        return null;
849
-    }
850
-
851
-
852
-    /**
853
-     * Gets the payment's transaction's primary registration's attendee, or null
854
-     *
855
-     * @return EE_Attendee|null
856
-     */
857
-    public function get_primary_attendee()
858
-    {
859
-        $primary_reg = $this->get_primary_registration();
860
-        if ($primary_reg instanceof EE_Registration) {
861
-            return $primary_reg->attendee();
862
-        }
863
-        return null;
864
-    }
13
+	/**
14
+	 * @param array  $props_n_values          incoming values
15
+	 * @param string $timezone                incoming timezone (if not set the timezone set for the website will be
16
+	 *                                        used.)
17
+	 * @param array  $date_formats            incoming date_formats in an array where the first value is the
18
+	 *                                        date_format and the second value is the time format
19
+	 * @return EE_Payment
20
+	 * @throws \EE_Error
21
+	 */
22
+	public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array())
23
+	{
24
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
25
+		return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
26
+	}
27
+
28
+
29
+	/**
30
+	 * @param array  $props_n_values  incoming values from the database
31
+	 * @param string $timezone        incoming timezone as set by the model.  If not set the timezone for
32
+	 *                                the website will be used.
33
+	 * @return EE_Payment
34
+	 * @throws \EE_Error
35
+	 */
36
+	public static function new_instance_from_db($props_n_values = array(), $timezone = null)
37
+	{
38
+		return new self($props_n_values, true, $timezone);
39
+	}
40
+
41
+
42
+	/**
43
+	 * Set Transaction ID
44
+	 *
45
+	 * @access public
46
+	 * @param int $TXN_ID
47
+	 * @throws \EE_Error
48
+	 */
49
+	public function set_transaction_id($TXN_ID = 0)
50
+	{
51
+		$this->set('TXN_ID', $TXN_ID);
52
+	}
53
+
54
+
55
+	/**
56
+	 * Gets the transaction related to this payment
57
+	 *
58
+	 * @return EE_Transaction
59
+	 * @throws \EE_Error
60
+	 */
61
+	public function transaction()
62
+	{
63
+		return $this->get_first_related('Transaction');
64
+	}
65
+
66
+
67
+	/**
68
+	 * Set Status
69
+	 *
70
+	 * @access public
71
+	 * @param string $STS_ID
72
+	 * @throws \EE_Error
73
+	 */
74
+	public function set_status($STS_ID = '')
75
+	{
76
+		$this->set('STS_ID', $STS_ID);
77
+	}
78
+
79
+
80
+	/**
81
+	 * Set Payment Timestamp
82
+	 *
83
+	 * @access public
84
+	 * @param int $timestamp
85
+	 * @throws \EE_Error
86
+	 */
87
+	public function set_timestamp($timestamp = 0)
88
+	{
89
+		$this->set('PAY_timestamp', $timestamp);
90
+	}
91
+
92
+
93
+	/**
94
+	 * Set Payment Method
95
+	 *
96
+	 * @access public
97
+	 * @param string $PAY_source
98
+	 * @throws \EE_Error
99
+	 */
100
+	public function set_source($PAY_source = '')
101
+	{
102
+		$this->set('PAY_source', $PAY_source);
103
+	}
104
+
105
+
106
+	/**
107
+	 * Set Payment Amount
108
+	 *
109
+	 * @access public
110
+	 * @param float $amount
111
+	 * @throws \EE_Error
112
+	 */
113
+	public function set_amount($amount = 0.00)
114
+	{
115
+		$this->set('PAY_amount', (float) $amount);
116
+	}
117
+
118
+
119
+	/**
120
+	 * Set Payment Gateway Response
121
+	 *
122
+	 * @access public
123
+	 * @param string $gateway_response
124
+	 * @throws \EE_Error
125
+	 */
126
+	public function set_gateway_response($gateway_response = '')
127
+	{
128
+		$this->set('PAY_gateway_response', $gateway_response);
129
+	}
130
+
131
+
132
+	/**
133
+	 * Returns the name of the payment method used on this payment (previously known merely as 'gateway')
134
+	 * but since 4.6.0, payment methods are models and the payment keeps a foreign key to the payment method
135
+	 * used on it
136
+	 *
137
+	 * @deprecated
138
+	 * @return string
139
+	 * @throws \EE_Error
140
+	 */
141
+	public function gateway()
142
+	{
143
+		EE_Error::doing_it_wrong(
144
+			'EE_Payment::gateway',
145
+			__(
146
+				'The method EE_Payment::gateway() has been deprecated. Consider instead using EE_Payment::payment_method()->name()',
147
+				'event_espresso'
148
+			),
149
+			'4.6.0'
150
+		);
151
+		return $this->payment_method() ? $this->payment_method()->name() : __('Unknown', 'event_espresso');
152
+	}
153
+
154
+
155
+	/**
156
+	 * Set Gateway Transaction ID
157
+	 *
158
+	 * @access public
159
+	 * @param string $txn_id_chq_nmbr
160
+	 * @throws \EE_Error
161
+	 */
162
+	public function set_txn_id_chq_nmbr($txn_id_chq_nmbr = '')
163
+	{
164
+		$this->set('PAY_txn_id_chq_nmbr', $txn_id_chq_nmbr);
165
+	}
166
+
167
+
168
+	/**
169
+	 * Set Purchase Order Number
170
+	 *
171
+	 * @access public
172
+	 * @param string $po_number
173
+	 * @throws \EE_Error
174
+	 */
175
+	public function set_po_number($po_number = '')
176
+	{
177
+		$this->set('PAY_po_number', $po_number);
178
+	}
179
+
180
+
181
+	/**
182
+	 * Set Extra Accounting Field
183
+	 *
184
+	 * @access public
185
+	 * @param string $extra_accntng
186
+	 * @throws \EE_Error
187
+	 */
188
+	public function set_extra_accntng($extra_accntng = '')
189
+	{
190
+		$this->set('PAY_extra_accntng', $extra_accntng);
191
+	}
192
+
193
+
194
+	/**
195
+	 * Set Payment made via admin flag
196
+	 *
197
+	 * @access public
198
+	 * @param bool $via_admin
199
+	 * @throws \EE_Error
200
+	 */
201
+	public function set_payment_made_via_admin($via_admin = false)
202
+	{
203
+		if ($via_admin) {
204
+			$this->set('PAY_source', EEM_Payment_Method::scope_admin);
205
+		} else {
206
+			$this->set('PAY_source', EEM_Payment_Method::scope_cart);
207
+		}
208
+	}
209
+
210
+
211
+	/**
212
+	 * Set Payment Details
213
+	 *
214
+	 * @access public
215
+	 * @param string|array $details
216
+	 * @throws \EE_Error
217
+	 */
218
+	public function set_details($details = '')
219
+	{
220
+		if (is_array($details)) {
221
+			array_walk_recursive($details, array($this, '_strip_all_tags_within_array'));
222
+		} else {
223
+			$details = wp_strip_all_tags($details);
224
+		}
225
+		$this->set('PAY_details', $details);
226
+	}
227
+
228
+
229
+	/**
230
+	 * Sets redirect_url
231
+	 *
232
+	 * @param string $redirect_url
233
+	 * @throws \EE_Error
234
+	 */
235
+	public function set_redirect_url($redirect_url)
236
+	{
237
+		$this->set('PAY_redirect_url', $redirect_url);
238
+	}
239
+
240
+
241
+	/**
242
+	 * Sets redirect_args
243
+	 *
244
+	 * @param array $redirect_args
245
+	 * @throws \EE_Error
246
+	 */
247
+	public function set_redirect_args($redirect_args)
248
+	{
249
+		$this->set('PAY_redirect_args', $redirect_args);
250
+	}
251
+
252
+
253
+	/**
254
+	 * get Payment Transaction ID
255
+	 *
256
+	 * @access public
257
+	 * @throws \EE_Error
258
+	 */
259
+	public function TXN_ID()
260
+	{
261
+		return $this->get('TXN_ID');
262
+	}
263
+
264
+
265
+	/**
266
+	 * get Payment Status
267
+	 *
268
+	 * @access public
269
+	 * @throws \EE_Error
270
+	 */
271
+	public function status()
272
+	{
273
+		return $this->get('STS_ID');
274
+	}
275
+
276
+
277
+	/**
278
+	 * get Payment Status
279
+	 *
280
+	 * @access public
281
+	 * @throws \EE_Error
282
+	 */
283
+	public function STS_ID()
284
+	{
285
+		return $this->get('STS_ID');
286
+	}
287
+
288
+
289
+	/**
290
+	 * get Payment Timestamp
291
+	 *
292
+	 * @access public
293
+	 * @param string $dt_frmt
294
+	 * @param string $tm_frmt
295
+	 * @return string
296
+	 * @throws \EE_Error
297
+	 */
298
+	public function timestamp($dt_frmt = '', $tm_frmt = '')
299
+	{
300
+		return $this->get_i18n_datetime('PAY_timestamp', trim($dt_frmt . ' ' . $tm_frmt));
301
+	}
302
+
303
+
304
+	/**
305
+	 * get Payment Source
306
+	 *
307
+	 * @access public
308
+	 * @throws \EE_Error
309
+	 */
310
+	public function source()
311
+	{
312
+		return $this->get('PAY_source');
313
+	}
314
+
315
+
316
+	/**
317
+	 * get Payment Amount
318
+	 *
319
+	 * @access public
320
+	 * @return float
321
+	 * @throws \EE_Error
322
+	 */
323
+	public function amount()
324
+	{
325
+		return (float) $this->get('PAY_amount');
326
+	}
327
+
328
+
329
+	/**
330
+	 * @return mixed
331
+	 * @throws \EE_Error
332
+	 */
333
+	public function amount_no_code()
334
+	{
335
+		return $this->get_pretty('PAY_amount', 'no_currency_code');
336
+	}
337
+
338
+
339
+	/**
340
+	 * get Payment Gateway Response
341
+	 *
342
+	 * @access public
343
+	 * @throws \EE_Error
344
+	 */
345
+	public function gateway_response()
346
+	{
347
+		return $this->get('PAY_gateway_response');
348
+	}
349
+
350
+
351
+	/**
352
+	 * get Payment Gateway Transaction ID
353
+	 *
354
+	 * @access public
355
+	 * @throws \EE_Error
356
+	 */
357
+	public function txn_id_chq_nmbr()
358
+	{
359
+		return $this->get('PAY_txn_id_chq_nmbr');
360
+	}
361
+
362
+
363
+	/**
364
+	 * get Purchase Order Number
365
+	 *
366
+	 * @access public
367
+	 * @throws \EE_Error
368
+	 */
369
+	public function po_number()
370
+	{
371
+		return $this->get('PAY_po_number');
372
+	}
373
+
374
+
375
+	/**
376
+	 * get Extra Accounting Field
377
+	 *
378
+	 * @access public
379
+	 * @throws \EE_Error
380
+	 */
381
+	public function extra_accntng()
382
+	{
383
+		return $this->get('PAY_extra_accntng');
384
+	}
385
+
386
+
387
+	/**
388
+	 * get Payment made via admin source
389
+	 *
390
+	 * @access public
391
+	 * @throws \EE_Error
392
+	 */
393
+	public function payment_made_via_admin()
394
+	{
395
+		return ($this->get('PAY_source') === EEM_Payment_Method::scope_admin);
396
+	}
397
+
398
+
399
+	/**
400
+	 * get Payment Details
401
+	 *
402
+	 * @access public
403
+	 * @throws \EE_Error
404
+	 */
405
+	public function details()
406
+	{
407
+		return $this->get('PAY_details');
408
+	}
409
+
410
+
411
+	/**
412
+	 * Gets redirect_url
413
+	 *
414
+	 * @return string
415
+	 * @throws \EE_Error
416
+	 */
417
+	public function redirect_url()
418
+	{
419
+		return $this->get('PAY_redirect_url');
420
+	}
421
+
422
+
423
+	/**
424
+	 * Gets redirect_args
425
+	 *
426
+	 * @return array
427
+	 * @throws \EE_Error
428
+	 */
429
+	public function redirect_args()
430
+	{
431
+		return $this->get('PAY_redirect_args');
432
+	}
433
+
434
+
435
+	/**
436
+	 * echoes $this->pretty_status()
437
+	 *
438
+	 * @param bool $show_icons
439
+	 * @return void
440
+	 * @throws \EE_Error
441
+	 */
442
+	public function e_pretty_status($show_icons = false)
443
+	{
444
+		echo $this->pretty_status($show_icons);
445
+	}
446
+
447
+
448
+	/**
449
+	 * returns a pretty version of the status, good for displaying to users
450
+	 *
451
+	 * @param bool $show_icons
452
+	 * @return string
453
+	 * @throws \EE_Error
454
+	 */
455
+	public function pretty_status($show_icons = false)
456
+	{
457
+		$status = EEM_Status::instance()->localized_status(
458
+			array($this->STS_ID() => __('unknown', 'event_espresso')),
459
+			false,
460
+			'sentence'
461
+		);
462
+		$icon = '';
463
+		switch ($this->STS_ID()) {
464
+			case EEM_Payment::status_id_approved:
465
+				$icon = $show_icons
466
+					? '<span class="dashicons dashicons-yes ee-icon-size-24 green-text"></span>'
467
+					: '';
468
+				break;
469
+			case EEM_Payment::status_id_pending:
470
+				$icon = $show_icons
471
+					? '<span class="dashicons dashicons-clock ee-icon-size-16 orange-text"></span>'
472
+					: '';
473
+				break;
474
+			case EEM_Payment::status_id_cancelled:
475
+				$icon = $show_icons
476
+					? '<span class="dashicons dashicons-no ee-icon-size-16 lt-grey-text"></span>'
477
+					: '';
478
+				break;
479
+			case EEM_Payment::status_id_declined:
480
+				$icon = $show_icons
481
+					? '<span class="dashicons dashicons-no ee-icon-size-16 red-text"></span>'
482
+					: '';
483
+				break;
484
+		}
485
+		return $icon . $status[ $this->STS_ID() ];
486
+	}
487
+
488
+
489
+	/**
490
+	 * For determining the status of the payment
491
+	 *
492
+	 * @return boolean whether the payment is approved or not
493
+	 * @throws \EE_Error
494
+	 */
495
+	public function is_approved()
496
+	{
497
+		return $this->status_is(EEM_Payment::status_id_approved);
498
+	}
499
+
500
+
501
+	/**
502
+	 * Generally determines if the status of this payment equals
503
+	 * the $STS_ID string
504
+	 *
505
+	 * @param string $STS_ID an ID from the esp_status table/
506
+	 *                       one of the status_id_* on the EEM_Payment model
507
+	 * @return boolean whether the status of this payment equals the status id
508
+	 * @throws \EE_Error
509
+	 */
510
+	protected function status_is($STS_ID)
511
+	{
512
+		return $STS_ID === $this->STS_ID() ? true : false;
513
+	}
514
+
515
+
516
+	/**
517
+	 * For determining the status of the payment
518
+	 *
519
+	 * @return boolean whether the payment is pending or not
520
+	 * @throws \EE_Error
521
+	 */
522
+	public function is_pending()
523
+	{
524
+		return $this->status_is(EEM_Payment::status_id_pending);
525
+	}
526
+
527
+
528
+	/**
529
+	 * For determining the status of the payment
530
+	 *
531
+	 * @return boolean
532
+	 * @throws \EE_Error
533
+	 */
534
+	public function is_cancelled()
535
+	{
536
+		return $this->status_is(EEM_Payment::status_id_cancelled);
537
+	}
538
+
539
+
540
+	/**
541
+	 * For determining the status of the payment
542
+	 *
543
+	 * @return boolean
544
+	 * @throws \EE_Error
545
+	 */
546
+	public function is_declined()
547
+	{
548
+		return $this->status_is(EEM_Payment::status_id_declined);
549
+	}
550
+
551
+
552
+	/**
553
+	 * For determining the status of the payment
554
+	 *
555
+	 * @return boolean
556
+	 * @throws \EE_Error
557
+	 */
558
+	public function is_failed()
559
+	{
560
+		return $this->status_is(EEM_Payment::status_id_failed);
561
+	}
562
+
563
+
564
+	/**
565
+	 * For determining if the payment is actually a refund ( ie: has a negative value )
566
+	 *
567
+	 * @return boolean
568
+	 * @throws \EE_Error
569
+	 */
570
+	public function is_a_refund()
571
+	{
572
+		return $this->amount() < 0 ? true : false;
573
+	}
574
+
575
+
576
+	/**
577
+	 * Get the status object of this object
578
+	 *
579
+	 * @return EE_Status
580
+	 * @throws \EE_Error
581
+	 */
582
+	public function status_obj()
583
+	{
584
+		return $this->get_first_related('Status');
585
+	}
586
+
587
+
588
+	/**
589
+	 * Gets all the extra meta info on this payment
590
+	 *
591
+	 * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
592
+	 * @return EE_Extra_Meta
593
+	 * @throws \EE_Error
594
+	 */
595
+	public function extra_meta($query_params = array())
596
+	{
597
+		return $this->get_many_related('Extra_Meta', $query_params);
598
+	}
599
+
600
+
601
+	/**
602
+	 * Gets the last-used payment method on this transaction
603
+	 * (we COULD just use the last-made payment, but some payment methods, namely
604
+	 * offline ones, dont' create payments)
605
+	 *
606
+	 * @return EE_Payment_Method
607
+	 * @throws \EE_Error
608
+	 */
609
+	public function payment_method()
610
+	{
611
+		return $this->get_first_related('Payment_Method');
612
+	}
613
+
614
+
615
+	/**
616
+	 * Gets the HTML for redirecting the user to an offsite gateway
617
+	 * You can pass it special content to put inside the form, or use
618
+	 * the default inner content (or possibly generate this all yourself using
619
+	 * redirect_url() and redirect_args() or redirect_args_as_inputs()).
620
+	 * Creates a POST request by default, but if no redirect args are specified, creates a GET request instead
621
+	 * (and any querystring variables in the redirect_url are converted into html inputs
622
+	 * so browsers submit them properly)
623
+	 *
624
+	 * @param string $inside_form_html
625
+	 * @return string html
626
+	 * @throws \EE_Error
627
+	 */
628
+	public function redirect_form($inside_form_html = null)
629
+	{
630
+		$redirect_url = $this->redirect_url();
631
+		if (! empty($redirect_url)) {
632
+			// what ? no inner form content?
633
+			if ($inside_form_html === null) {
634
+				$inside_form_html = EEH_HTML::p(
635
+					sprintf(
636
+						__(
637
+							'If you are not automatically redirected to the payment website within 10 seconds... %1$s %2$s Click Here %3$s',
638
+							'event_espresso'
639
+						),
640
+						EEH_HTML::br(2),
641
+						'<input type="submit" value="',
642
+						'">'
643
+					),
644
+					'',
645
+					'',
646
+					'text-align:center;'
647
+				);
648
+			}
649
+			$method = apply_filters(
650
+				'FHEE__EE_Payment__redirect_form__method',
651
+				$this->redirect_args() ? 'POST' : 'GET',
652
+				$this
653
+			);
654
+			// if it's a GET request, we need to remove all the GET params in the querystring
655
+			// and put them into the form instead
656
+			if ($method === 'GET') {
657
+				$querystring = parse_url($redirect_url, PHP_URL_QUERY);
658
+				$get_params = null;
659
+				parse_str($querystring, $get_params);
660
+				$inside_form_html .= $this->_args_as_inputs($get_params);
661
+				$redirect_url = str_replace('?' . $querystring, '', $redirect_url);
662
+			}
663
+			$form = EEH_HTML::nl(1)
664
+					. '<form method="'
665
+					. $method
666
+					. '" name="gateway_form" action="'
667
+					. $redirect_url
668
+					. '">';
669
+			$form .= EEH_HTML::nl(1) . $this->redirect_args_as_inputs();
670
+			$form .= $inside_form_html;
671
+			$form .= EEH_HTML::nl(-1) . '</form>' . EEH_HTML::nl(-1);
672
+			return $form;
673
+		} else {
674
+			return null;
675
+		}
676
+	}
677
+
678
+
679
+	/**
680
+	 * Changes all the name-value pairs of the redirect args into html inputs
681
+	 * and returns the html as a string
682
+	 *
683
+	 * @return string
684
+	 * @throws \EE_Error
685
+	 */
686
+	public function redirect_args_as_inputs()
687
+	{
688
+		return $this->_args_as_inputs($this->redirect_args());
689
+	}
690
+
691
+
692
+	/**
693
+	 * Converts a 1d array of key-value pairs into html hidden inputs
694
+	 * and returns the string of html
695
+	 *
696
+	 * @param array $args key-value pairs
697
+	 * @return string
698
+	 */
699
+	protected function _args_as_inputs($args)
700
+	{
701
+		$html = '';
702
+		if ($args !== null && is_array($args)) {
703
+			foreach ($args as $name => $value) {
704
+				$html .= EEH_HTML::nl(0)
705
+						 . '<input type="hidden" name="'
706
+						 . $name
707
+						 . '" value="'
708
+						 . esc_attr($value)
709
+						 . '"/>';
710
+			}
711
+		}
712
+		return $html;
713
+	}
714
+
715
+
716
+	/**
717
+	 * Returns the currency of the payment.
718
+	 * (At the time of writing, this will always be the currency in the configuration;
719
+	 * however in the future it is anticipated that this will be stored on the payment
720
+	 * object itself)
721
+	 *
722
+	 * @return string for the currency code
723
+	 */
724
+	public function currency_code()
725
+	{
726
+		return EE_Config::instance()->currency->code;
727
+	}
728
+
729
+
730
+	/**
731
+	 * apply wp_strip_all_tags to all elements within an array
732
+	 *
733
+	 * @access private
734
+	 * @param mixed $item
735
+	 */
736
+	private function _strip_all_tags_within_array(&$item)
737
+	{
738
+		if (is_object($item)) {
739
+			$item = (array) $item;
740
+		}
741
+		if (is_array($item)) {
742
+			array_walk_recursive($item, array($this, '_strip_all_tags_within_array'));
743
+		} else {
744
+			$item = wp_strip_all_tags($item);
745
+		}
746
+	}
747
+
748
+
749
+	/**
750
+	 * Returns TRUE is this payment was set to approved during this request (or
751
+	 * is approved and was created during this request). False otherwise.
752
+	 *
753
+	 * @return boolean
754
+	 * @throws \EE_Error
755
+	 */
756
+	public function just_approved()
757
+	{
758
+		$original_status = EEH_Array::is_set(
759
+			$this->_props_n_values_provided_in_constructor,
760
+			'STS_ID',
761
+			$this->get_model()->field_settings_for('STS_ID')->get_default_value()
762
+		);
763
+		$current_status = $this->status();
764
+		if (
765
+			$original_status !== EEM_Payment::status_id_approved
766
+			&& $current_status === EEM_Payment::status_id_approved
767
+		) {
768
+			return true;
769
+		} else {
770
+			return false;
771
+		}
772
+	}
773
+
774
+
775
+	/**
776
+	 * Overrides parents' get_pretty() function just for legacy reasons
777
+	 * (to allow ticket https://events.codebasehq.com/projects/event-espresso/tickets/7420)
778
+	 *
779
+	 * @param string $field_name
780
+	 * @param string $extra_cache_ref This allows the user to specify an extra cache ref for the given property
781
+	 *                                (in cases where the same property may be used for different outputs
782
+	 *                                - i.e. datetime, money etc.)
783
+	 * @return mixed
784
+	 * @throws \EE_Error
785
+	 */
786
+	public function get_pretty($field_name, $extra_cache_ref = null)
787
+	{
788
+		if ($field_name === 'PAY_gateway') {
789
+			return $this->payment_method() ? $this->payment_method()->name() : __('Unknown', 'event_espresso');
790
+		}
791
+		return $this->_get_cached_property($field_name, true, $extra_cache_ref);
792
+	}
793
+
794
+
795
+	/**
796
+	 * Gets details regarding which registrations this payment was applied to
797
+	 *
798
+	 * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
799
+	 * @return EE_Registration_Payment[]
800
+	 * @throws \EE_Error
801
+	 */
802
+	public function registration_payments($query_params = array())
803
+	{
804
+		return $this->get_many_related('Registration_Payment', $query_params);
805
+	}
806
+
807
+
808
+	/**
809
+	 * Gets the first event for this payment (it's possible that it could be for multiple)
810
+	 *
811
+	 * @return EE_Event|null
812
+	 */
813
+	public function get_first_event()
814
+	{
815
+		$transaction = $this->transaction();
816
+		if ($transaction instanceof EE_Transaction) {
817
+			$primary_registrant = $transaction->primary_registration();
818
+			if ($primary_registrant instanceof EE_Registration) {
819
+				return $primary_registrant->event_obj();
820
+			}
821
+		}
822
+		return null;
823
+	}
824
+
825
+
826
+	/**
827
+	 * Gets the name of the first event for which is being paid
828
+	 *
829
+	 * @return string
830
+	 */
831
+	public function get_first_event_name()
832
+	{
833
+		$event = $this->get_first_event();
834
+		return $event instanceof EE_Event ? $event->name() : __('Event', 'event_espresso');
835
+	}
836
+
837
+
838
+	/**
839
+	 * Returns the payment's transaction's primary registration
840
+	 *
841
+	 * @return EE_Registration|null
842
+	 */
843
+	public function get_primary_registration()
844
+	{
845
+		if ($this->transaction() instanceof EE_Transaction) {
846
+			return $this->transaction()->primary_registration();
847
+		}
848
+		return null;
849
+	}
850
+
851
+
852
+	/**
853
+	 * Gets the payment's transaction's primary registration's attendee, or null
854
+	 *
855
+	 * @return EE_Attendee|null
856
+	 */
857
+	public function get_primary_attendee()
858
+	{
859
+		$primary_reg = $this->get_primary_registration();
860
+		if ($primary_reg instanceof EE_Registration) {
861
+			return $primary_reg->attendee();
862
+		}
863
+		return null;
864
+	}
865 865
 }
Please login to merge, or discard this patch.
core/db_classes/EE_Registration_Payment.class.php 1 patch
Indentation   +94 added lines, -94 removed lines patch added patch discarded remove patch
@@ -14,98 +14,98 @@
 block discarded – undo
14 14
 class EE_Registration_Payment extends EE_Base_Class
15 15
 {
16 16
 
17
-    /**
18
-     *
19
-     * @param array  $props_n_values
20
-     * @param string $timezone
21
-     * @return EE_Registration_Payment
22
-     */
23
-    public static function new_instance($props_n_values = array(), $timezone = '', $date_formats = array())
24
-    {
25
-        $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
26
-        return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
27
-    }
28
-
29
-
30
-    /**
31
-     * @param array  $props_n_values
32
-     * @param string $timezone
33
-     * @return EE_Registration_Payment
34
-     */
35
-    public static function new_instance_from_db($props_n_values = array(), $timezone = '')
36
-    {
37
-        return new self($props_n_values, true, $timezone);
38
-    }
39
-
40
-
41
-    /**
42
-     * registration_ID
43
-     *
44
-     * @access    public
45
-     * @return    int
46
-     */
47
-    public function registration_ID()
48
-    {
49
-        return $this->get('REG_ID');
50
-    }
51
-
52
-
53
-    /**
54
-     * payment_ID
55
-     *
56
-     * @access    public
57
-     * @return    int
58
-     */
59
-    public function payment_ID()
60
-    {
61
-        return $this->get('PAY_ID');
62
-    }
63
-
64
-
65
-    /**
66
-     * amount
67
-     *
68
-     * @access    public
69
-     * @return    float
70
-     */
71
-    public function amount()
72
-    {
73
-        return $this->get('RPY_amount');
74
-    }
75
-
76
-
77
-    /**
78
-     * amount
79
-     *
80
-     * @access    public
81
-     * @param float $amount
82
-     */
83
-    public function set_amount($amount = 0.000)
84
-    {
85
-        $this->set('RPY_amount', $amount);
86
-    }
87
-
88
-
89
-    /**
90
-     * registration
91
-     *
92
-     * @access    public
93
-     * @return \EE_Registration
94
-     */
95
-    public function registration()
96
-    {
97
-        return $this->get_first_related('Registration');
98
-    }
99
-
100
-
101
-    /**
102
-     * payment
103
-     *
104
-     * @access    public
105
-     * @return \EE_Payment
106
-     */
107
-    public function payment()
108
-    {
109
-        return $this->get_first_related('Payment');
110
-    }
17
+	/**
18
+	 *
19
+	 * @param array  $props_n_values
20
+	 * @param string $timezone
21
+	 * @return EE_Registration_Payment
22
+	 */
23
+	public static function new_instance($props_n_values = array(), $timezone = '', $date_formats = array())
24
+	{
25
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
26
+		return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
27
+	}
28
+
29
+
30
+	/**
31
+	 * @param array  $props_n_values
32
+	 * @param string $timezone
33
+	 * @return EE_Registration_Payment
34
+	 */
35
+	public static function new_instance_from_db($props_n_values = array(), $timezone = '')
36
+	{
37
+		return new self($props_n_values, true, $timezone);
38
+	}
39
+
40
+
41
+	/**
42
+	 * registration_ID
43
+	 *
44
+	 * @access    public
45
+	 * @return    int
46
+	 */
47
+	public function registration_ID()
48
+	{
49
+		return $this->get('REG_ID');
50
+	}
51
+
52
+
53
+	/**
54
+	 * payment_ID
55
+	 *
56
+	 * @access    public
57
+	 * @return    int
58
+	 */
59
+	public function payment_ID()
60
+	{
61
+		return $this->get('PAY_ID');
62
+	}
63
+
64
+
65
+	/**
66
+	 * amount
67
+	 *
68
+	 * @access    public
69
+	 * @return    float
70
+	 */
71
+	public function amount()
72
+	{
73
+		return $this->get('RPY_amount');
74
+	}
75
+
76
+
77
+	/**
78
+	 * amount
79
+	 *
80
+	 * @access    public
81
+	 * @param float $amount
82
+	 */
83
+	public function set_amount($amount = 0.000)
84
+	{
85
+		$this->set('RPY_amount', $amount);
86
+	}
87
+
88
+
89
+	/**
90
+	 * registration
91
+	 *
92
+	 * @access    public
93
+	 * @return \EE_Registration
94
+	 */
95
+	public function registration()
96
+	{
97
+		return $this->get_first_related('Registration');
98
+	}
99
+
100
+
101
+	/**
102
+	 * payment
103
+	 *
104
+	 * @access    public
105
+	 * @return \EE_Payment
106
+	 */
107
+	public function payment()
108
+	{
109
+		return $this->get_first_related('Payment');
110
+	}
111 111
 }
Please login to merge, or discard this patch.
core/db_classes/EE_Question_Group_Question.class.php 1 patch
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -6,23 +6,23 @@
 block discarded – undo
6 6
 class EE_Question_Group_Question extends EE_Base_Class
7 7
 {
8 8
 
9
-    /**
10
-     * @param array $props_n_values
11
-     * @return EE_Question_Group_Question|mixed
12
-     */
13
-    public static function new_instance($props_n_values = array())
14
-    {
15
-        $has_object = parent::_check_for_object($props_n_values, __CLASS__);
16
-        return $has_object ? $has_object : new self($props_n_values);
17
-    }
9
+	/**
10
+	 * @param array $props_n_values
11
+	 * @return EE_Question_Group_Question|mixed
12
+	 */
13
+	public static function new_instance($props_n_values = array())
14
+	{
15
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__);
16
+		return $has_object ? $has_object : new self($props_n_values);
17
+	}
18 18
 
19 19
 
20
-    /**
21
-     * @param array $props_n_values
22
-     * @return EE_Question_Group_Question
23
-     */
24
-    public static function new_instance_from_db($props_n_values = array())
25
-    {
26
-        return new self($props_n_values, true);
27
-    }
20
+	/**
21
+	 * @param array $props_n_values
22
+	 * @return EE_Question_Group_Question
23
+	 */
24
+	public static function new_instance_from_db($props_n_values = array())
25
+	{
26
+		return new self($props_n_values, true);
27
+	}
28 28
 }
Please login to merge, or discard this patch.
core/db_classes/EE_State.class.php 1 patch
Indentation   +100 added lines, -100 removed lines patch added patch discarded remove patch
@@ -11,104 +11,104 @@
 block discarded – undo
11 11
 class EE_State extends EE_Base_Class
12 12
 {
13 13
 
14
-    /**
15
-     * @param array $props_n_values
16
-     * @return EE_State|mixed
17
-     */
18
-    public static function new_instance($props_n_values = array())
19
-    {
20
-        $has_object = parent::_check_for_object($props_n_values, __CLASS__);
21
-        return $has_object ? $has_object : new self($props_n_values);
22
-    }
23
-
24
-
25
-    /**
26
-     * @param array $props_n_values
27
-     * @return EE_State
28
-     */
29
-    public static function new_instance_from_db($props_n_values = array())
30
-    {
31
-        return new self($props_n_values, true);
32
-    }
33
-
34
-
35
-    /**
36
-     * @return string
37
-     */
38
-    public function country_iso()
39
-    {
40
-        return $this->get('CNT_ISO');
41
-    }
42
-
43
-
44
-    /**
45
-     * @return string
46
-     */
47
-    public function abbrev()
48
-    {
49
-        return $this->get('STA_abbrev');
50
-    }
51
-
52
-
53
-    /**
54
-     * @return bool
55
-     */
56
-    public function active()
57
-    {
58
-        return $this->get('STA_active');
59
-    }
60
-
61
-
62
-    /**
63
-     * @return string
64
-     */
65
-    public function name()
66
-    {
67
-        return $this->get('STA_name');
68
-    }
69
-
70
-
71
-    /**
72
-     * @return EE_Country
73
-     */
74
-    public function country()
75
-    {
76
-        return $this->get_first_related('Country');
77
-    }
78
-
79
-
80
-    /**
81
-     * @param $iso
82
-     */
83
-    public function set_country_iso($iso)
84
-    {
85
-        $this->set('CNT_ISO', $iso);
86
-    }
87
-
88
-
89
-    /**
90
-     * @param $abbrev
91
-     */
92
-    public function set_abbrev($abbrev)
93
-    {
94
-        $this->set('STA_abbrev', $abbrev);
95
-    }
96
-
97
-
98
-    /**
99
-     * @param $active
100
-     */
101
-    public function set_active($active)
102
-    {
103
-        $this->set('STA_active', $active);
104
-    }
105
-
106
-
107
-    /**
108
-     * @param $name
109
-     */
110
-    public function set_name($name)
111
-    {
112
-        $this->set('STA_name', $name);
113
-    }
14
+	/**
15
+	 * @param array $props_n_values
16
+	 * @return EE_State|mixed
17
+	 */
18
+	public static function new_instance($props_n_values = array())
19
+	{
20
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__);
21
+		return $has_object ? $has_object : new self($props_n_values);
22
+	}
23
+
24
+
25
+	/**
26
+	 * @param array $props_n_values
27
+	 * @return EE_State
28
+	 */
29
+	public static function new_instance_from_db($props_n_values = array())
30
+	{
31
+		return new self($props_n_values, true);
32
+	}
33
+
34
+
35
+	/**
36
+	 * @return string
37
+	 */
38
+	public function country_iso()
39
+	{
40
+		return $this->get('CNT_ISO');
41
+	}
42
+
43
+
44
+	/**
45
+	 * @return string
46
+	 */
47
+	public function abbrev()
48
+	{
49
+		return $this->get('STA_abbrev');
50
+	}
51
+
52
+
53
+	/**
54
+	 * @return bool
55
+	 */
56
+	public function active()
57
+	{
58
+		return $this->get('STA_active');
59
+	}
60
+
61
+
62
+	/**
63
+	 * @return string
64
+	 */
65
+	public function name()
66
+	{
67
+		return $this->get('STA_name');
68
+	}
69
+
70
+
71
+	/**
72
+	 * @return EE_Country
73
+	 */
74
+	public function country()
75
+	{
76
+		return $this->get_first_related('Country');
77
+	}
78
+
79
+
80
+	/**
81
+	 * @param $iso
82
+	 */
83
+	public function set_country_iso($iso)
84
+	{
85
+		$this->set('CNT_ISO', $iso);
86
+	}
87
+
88
+
89
+	/**
90
+	 * @param $abbrev
91
+	 */
92
+	public function set_abbrev($abbrev)
93
+	{
94
+		$this->set('STA_abbrev', $abbrev);
95
+	}
96
+
97
+
98
+	/**
99
+	 * @param $active
100
+	 */
101
+	public function set_active($active)
102
+	{
103
+		$this->set('STA_active', $active);
104
+	}
105
+
106
+
107
+	/**
108
+	 * @param $name
109
+	 */
110
+	public function set_name($name)
111
+	{
112
+		$this->set('STA_name', $name);
113
+	}
114 114
 }
Please login to merge, or discard this patch.
core/db_classes/EE_Event_Message_Template.class.php 1 patch
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -12,25 +12,25 @@
 block discarded – undo
12 12
 class EE_Event_Message_Template extends EE_Base_Class
13 13
 {
14 14
 
15
-    /**
16
-     * @param array $props_n_values
17
-     * @param null  $timezone
18
-     * @return EE_Event_Message_Template|mixed
19
-     */
20
-    public static function new_instance($props_n_values = array(), $timezone = null)
21
-    {
22
-        $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone);
23
-        return $has_object ? $has_object : new self($props_n_values, false, $timezone);
24
-    }
15
+	/**
16
+	 * @param array $props_n_values
17
+	 * @param null  $timezone
18
+	 * @return EE_Event_Message_Template|mixed
19
+	 */
20
+	public static function new_instance($props_n_values = array(), $timezone = null)
21
+	{
22
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone);
23
+		return $has_object ? $has_object : new self($props_n_values, false, $timezone);
24
+	}
25 25
 
26 26
 
27
-    /**
28
-     * @param array $props_n_values
29
-     * @param null  $timezone
30
-     * @return EE_Event_Message_Template
31
-     */
32
-    public static function new_instance_from_db($props_n_values = array(), $timezone = null)
33
-    {
34
-        return new self($props_n_values, true, $timezone);
35
-    }
27
+	/**
28
+	 * @param array $props_n_values
29
+	 * @param null  $timezone
30
+	 * @return EE_Event_Message_Template
31
+	 */
32
+	public static function new_instance_from_db($props_n_values = array(), $timezone = null)
33
+	{
34
+		return new self($props_n_values, true, $timezone);
35
+	}
36 36
 }
Please login to merge, or discard this patch.