Completed
Branch Gutenberg/use-new-wordpress-pa... (9fa7a4)
by
unknown
63:25 queued 48:18
created
core/libraries/payment_methods/EE_Offsite_Gateway.lib.php 1 patch
Indentation   +102 added lines, -102 removed lines patch added patch discarded remove patch
@@ -15,117 +15,117 @@
 block discarded – undo
15 15
 abstract class EE_Offsite_Gateway extends EE_Gateway
16 16
 {
17 17
 
18
-    /**
19
-     * whether or not the gateway uses an IPN
20
-     * that is sent in a separate request than the returning registrant.
21
-     * if false, then we need to process the payment results manually
22
-     * as soon as the registrant returns from the off-site gateway
23
-     *
24
-     * @type bool
25
-     */
26
-    protected $_uses_separate_IPN_request = false;
18
+	/**
19
+	 * whether or not the gateway uses an IPN
20
+	 * that is sent in a separate request than the returning registrant.
21
+	 * if false, then we need to process the payment results manually
22
+	 * as soon as the registrant returns from the off-site gateway
23
+	 *
24
+	 * @type bool
25
+	 */
26
+	protected $_uses_separate_IPN_request = false;
27 27
 
28 28
 
29
-    /**
30
-     * @return EE_Offsite_Gateway
31
-     */
32
-    public function __construct()
33
-    {
34
-        $this->_supports_receiving_refunds = true;
35
-        parent::__construct();
36
-    }
29
+	/**
30
+	 * @return EE_Offsite_Gateway
31
+	 */
32
+	public function __construct()
33
+	{
34
+		$this->_supports_receiving_refunds = true;
35
+		parent::__construct();
36
+	}
37 37
 
38 38
 
39
-    /**
40
-     * Adds information into the payment object's redirect_url and redirect_args so
41
-     * client code can use that payment to know where (and with what information)
42
-     * to redirect the user to in order to make the payment on the offsite gateway's website.
43
-     * Saving the payment from within this method is unnecessary,
44
-     * as it is the responsibility of client code to save it.
45
-     *
46
-     * @param EE_Payment $payment    to process
47
-     * @param array      $billing_info
48
-     * @param string     $return_url URL to send the user to after a successful payment on the payment provider's
49
-     *                               website
50
-     * @param string     $notify_url URL to send the instant payment notification
51
-     * @param string     $cancel_url URL to send the user to after a cancelled payment attempt on teh payment
52
-     *                               provider's website
53
-     * @return EE_Payment
54
-     */
55
-    abstract public function set_redirection_info(
56
-        $payment,
57
-        $billing_info = array(),
58
-        $return_url = null,
59
-        $notify_url = null,
60
-        $cancel_url = null
61
-    );
39
+	/**
40
+	 * Adds information into the payment object's redirect_url and redirect_args so
41
+	 * client code can use that payment to know where (and with what information)
42
+	 * to redirect the user to in order to make the payment on the offsite gateway's website.
43
+	 * Saving the payment from within this method is unnecessary,
44
+	 * as it is the responsibility of client code to save it.
45
+	 *
46
+	 * @param EE_Payment $payment    to process
47
+	 * @param array      $billing_info
48
+	 * @param string     $return_url URL to send the user to after a successful payment on the payment provider's
49
+	 *                               website
50
+	 * @param string     $notify_url URL to send the instant payment notification
51
+	 * @param string     $cancel_url URL to send the user to after a cancelled payment attempt on teh payment
52
+	 *                               provider's website
53
+	 * @return EE_Payment
54
+	 */
55
+	abstract public function set_redirection_info(
56
+		$payment,
57
+		$billing_info = array(),
58
+		$return_url = null,
59
+		$notify_url = null,
60
+		$cancel_url = null
61
+	);
62 62
 
63 63
 
64
-    /**
65
-     * Often used for IPNs. But applies the info in $update_info to the payment.
66
-     * What is $update_info? Often the contents of $_REQUEST, but not necessarily. Whatever
67
-     * the payment method passes in. Saving the payment from within this method is unnecessary,
68
-     * as it is the responsibility of client code to save it.
69
-     *
70
-     * @param array           $update_info of whatever
71
-     * @param EEI_Transaction $transaction
72
-     * @return EEI_Payment updated
73
-     */
74
-    abstract public function handle_payment_update($update_info, $transaction);
64
+	/**
65
+	 * Often used for IPNs. But applies the info in $update_info to the payment.
66
+	 * What is $update_info? Often the contents of $_REQUEST, but not necessarily. Whatever
67
+	 * the payment method passes in. Saving the payment from within this method is unnecessary,
68
+	 * as it is the responsibility of client code to save it.
69
+	 *
70
+	 * @param array           $update_info of whatever
71
+	 * @param EEI_Transaction $transaction
72
+	 * @return EEI_Payment updated
73
+	 */
74
+	abstract public function handle_payment_update($update_info, $transaction);
75 75
 
76 76
 
77
-    /**
78
-     * uses_separate_IPN_request
79
-     *
80
-     * return true or false for whether or not the gateway uses an IPN
81
-     * that is sent in a separate request than the returning registrant.
82
-     * if false, then we need to process the payment results manually
83
-     * as soon as the registrant returns from the off-site gateway
84
-     *
85
-     * @deprecated since version 4.8.39.rc.001 please use handle_IPN_in_this_request() instead
86
-     *
87
-     * @return bool
88
-     */
89
-    public function uses_separate_IPN_request()
90
-    {
91
-        return $this->_uses_separate_IPN_request;
92
-    }
77
+	/**
78
+	 * uses_separate_IPN_request
79
+	 *
80
+	 * return true or false for whether or not the gateway uses an IPN
81
+	 * that is sent in a separate request than the returning registrant.
82
+	 * if false, then we need to process the payment results manually
83
+	 * as soon as the registrant returns from the off-site gateway
84
+	 *
85
+	 * @deprecated since version 4.8.39.rc.001 please use handle_IPN_in_this_request() instead
86
+	 *
87
+	 * @return bool
88
+	 */
89
+	public function uses_separate_IPN_request()
90
+	{
91
+		return $this->_uses_separate_IPN_request;
92
+	}
93 93
 
94 94
 
95
-    /**
96
-     * set_uses_separate_IPN_request
97
-     *
98
-     * @access protected
99
-     * @param boolean $uses_separate_IPN_request
100
-     */
101
-    protected function set_uses_separate_IPN_request($uses_separate_IPN_request)
102
-    {
103
-        $this->_uses_separate_IPN_request = filter_var($uses_separate_IPN_request, FILTER_VALIDATE_BOOLEAN);
104
-    }
95
+	/**
96
+	 * set_uses_separate_IPN_request
97
+	 *
98
+	 * @access protected
99
+	 * @param boolean $uses_separate_IPN_request
100
+	 */
101
+	protected function set_uses_separate_IPN_request($uses_separate_IPN_request)
102
+	{
103
+		$this->_uses_separate_IPN_request = filter_var($uses_separate_IPN_request, FILTER_VALIDATE_BOOLEAN);
104
+	}
105 105
 
106
-    /**
107
-     * Allows gateway to dynamically decide whether or not to handle a payment update
108
-     * by overriding this method. By default, if this is a "true" IPN (meaning
109
-     * it's a separate request from when the user returns from the offsite gateway)
110
-     * and this gateway class is setup to handle IPNs in separate "true" IPNs, then
111
-     * this will return true, otherwise it will return false.
112
-     * If however, this is a request when the user is returning
113
-     * from an offsite gateway, and this gateway class is setup to process the payment
114
-     * data when the user returns, then this will return true.
115
-     *
116
-     * @param array   $request_data
117
-     * @param boolean $separate_IPN_request
118
-     * @return boolean
119
-     */
120
-    public function handle_IPN_in_this_request($request_data, $separate_IPN_request)
121
-    {
122
-        if ($separate_IPN_request) {
123
-            // payment data being sent in a request separate from the user
124
-            // it is this other request that will update the TXN and payment info
125
-            return $this->_uses_separate_IPN_request;
126
-        } else {
127
-            // it's a request where the user returned from an offsite gateway WITH the payment data
128
-            return ! $this->_uses_separate_IPN_request;
129
-        }
130
-    }
106
+	/**
107
+	 * Allows gateway to dynamically decide whether or not to handle a payment update
108
+	 * by overriding this method. By default, if this is a "true" IPN (meaning
109
+	 * it's a separate request from when the user returns from the offsite gateway)
110
+	 * and this gateway class is setup to handle IPNs in separate "true" IPNs, then
111
+	 * this will return true, otherwise it will return false.
112
+	 * If however, this is a request when the user is returning
113
+	 * from an offsite gateway, and this gateway class is setup to process the payment
114
+	 * data when the user returns, then this will return true.
115
+	 *
116
+	 * @param array   $request_data
117
+	 * @param boolean $separate_IPN_request
118
+	 * @return boolean
119
+	 */
120
+	public function handle_IPN_in_this_request($request_data, $separate_IPN_request)
121
+	{
122
+		if ($separate_IPN_request) {
123
+			// payment data being sent in a request separate from the user
124
+			// it is this other request that will update the TXN and payment info
125
+			return $this->_uses_separate_IPN_request;
126
+		} else {
127
+			// it's a request where the user returned from an offsite gateway WITH the payment data
128
+			return ! $this->_uses_separate_IPN_request;
129
+		}
130
+	}
131 131
 }
Please login to merge, or discard this patch.
core/libraries/payment_methods/EE_PMT_Base.lib.php 2 patches
Indentation   +797 added lines, -797 removed lines patch added patch discarded remove patch
@@ -21,801 +21,801 @@
 block discarded – undo
21 21
 abstract class EE_PMT_Base
22 22
 {
23 23
 
24
-    const onsite = 'on-site';
25
-    const offsite = 'off-site';
26
-    const offline = 'off-line';
27
-
28
-    /**
29
-     * @var EE_Payment_Method
30
-     */
31
-    protected $_pm_instance = null;
32
-
33
-    /**
34
-     * @var boolean
35
-     */
36
-    protected $_requires_https = false;
37
-
38
-    /**
39
-     * @var boolean
40
-     */
41
-    protected $_has_billing_form;
42
-
43
-    /**
44
-     * @var EE_Gateway
45
-     */
46
-    protected $_gateway = null;
47
-
48
-    /**
49
-     * @var EE_Payment_Method_Form
50
-     */
51
-    protected $_settings_form = null;
52
-
53
-    /**
54
-     * @var EE_Form_Section_Proper
55
-     */
56
-    protected $_billing_form = null;
57
-
58
-    /**
59
-     * @var boolean
60
-     */
61
-    protected $_cache_billing_form = true;
62
-
63
-    /**
64
-     * String of the absolute path to the folder containing this file, with a trailing slash.
65
-     * eg '/public_html/wp-site/wp-content/plugins/event-espresso/payment_methods/Invoice/'
66
-     *
67
-     * @var string
68
-     */
69
-    protected $_file_folder = null;
70
-
71
-    /**
72
-     * String to the absolute URL to this file (useful for getting its web-accessible resources
73
-     * like images, js, or css)
74
-     *
75
-     * @var string
76
-     */
77
-    protected $_file_url = null;
78
-
79
-    /**
80
-     * Pretty name for the payment method
81
-     *
82
-     * @var string
83
-     */
84
-    protected $_pretty_name = null;
85
-
86
-    /**
87
-     *
88
-     * @var string
89
-     */
90
-    protected $_default_button_url = null;
91
-
92
-    /**
93
-     *
94
-     * @var string
95
-     */
96
-    protected $_default_description = null;
97
-
98
-
99
-    /**
100
-     *
101
-     * @param EE_Payment_Method $pm_instance
102
-     * @throws EE_Error
103
-     * @return EE_PMT_Base
104
-     */
105
-    public function __construct($pm_instance = null)
106
-    {
107
-        if ($pm_instance instanceof EE_Payment_Method) {
108
-            $this->set_instance($pm_instance);
109
-        }
110
-        if ($this->_gateway) {
111
-            $this->_gateway->set_payment_model(EEM_Payment::instance());
112
-            $this->_gateway->set_payment_log(EEM_Change_Log::instance());
113
-            $this->_gateway->set_template_helper(new EEH_Template());
114
-            $this->_gateway->set_line_item_helper(new EEH_Line_Item());
115
-            $this->_gateway->set_money_helper(new EEH_Money());
116
-            $this->_gateway->set_gateway_data_formatter(new GatewayDataFormatter());
117
-            $this->_gateway->set_unsupported_character_remover(new AsciiOnly());
118
-            do_action('AHEE__EE_PMT_Base___construct__done_initializing_gateway_class', $this, $this->_gateway);
119
-        }
120
-        if (! isset($this->_has_billing_form)) {
121
-            // by default, On Site gateways have a billing form
122
-            if ($this->payment_occurs() == EE_PMT_Base::onsite) {
123
-                $this->set_has_billing_form(true);
124
-            } else {
125
-                $this->set_has_billing_form(false);
126
-            }
127
-        }
128
-
129
-        if (! $this->_pretty_name) {
130
-            throw new EE_Error(
131
-                sprintf(
132
-                    __(
133
-                        "You must set the pretty name for the Payment Method Type in the constructor (_pretty_name), and please make it internationalized",
134
-                        "event_espresso"
135
-                    )
136
-                )
137
-            );
138
-        }
139
-        // if the child didn't specify a default button, use the credit card one
140
-        if ($this->_default_button_url === null) {
141
-            $this->_default_button_url = EE_PLUGIN_DIR_URL . 'payment_methods' . DS . 'pay-by-credit-card.png';
142
-        }
143
-    }
144
-
145
-
146
-    /**
147
-     * @param boolean $has_billing_form
148
-     */
149
-    public function set_has_billing_form($has_billing_form)
150
-    {
151
-        $this->_has_billing_form = filter_var($has_billing_form, FILTER_VALIDATE_BOOLEAN);
152
-    }
153
-
154
-
155
-    /**
156
-     * sets the file_folder property
157
-     */
158
-    protected function _set_file_folder()
159
-    {
160
-        $reflector = new ReflectionClass(get_class($this));
161
-        $fn = $reflector->getFileName();
162
-        $this->_file_folder = dirname($fn) . DS;
163
-    }
164
-
165
-
166
-    /**
167
-     * sets the file URL with a trailing slash for this PMT
168
-     */
169
-    protected function _set_file_url()
170
-    {
171
-        $plugins_dir_fixed = str_replace('\\', DS, WP_PLUGIN_DIR);
172
-        $file_folder_fixed = str_replace('\\', DS, $this->file_folder());
173
-        $file_path = str_replace($plugins_dir_fixed, WP_PLUGIN_URL, $file_folder_fixed);
174
-        $this->_file_url = $file_path;
175
-    }
176
-
177
-    /**
178
-     * Gets the default description on all payment methods of this type
179
-     *
180
-     * @return string
181
-     */
182
-    public function default_description()
183
-    {
184
-        return $this->_default_description;
185
-    }
186
-
187
-
188
-    /**
189
-     * Returns the folder containing the PMT child class, with a trailing slash
190
-     *
191
-     * @return string
192
-     */
193
-    public function file_folder()
194
-    {
195
-        if (! $this->_file_folder) {
196
-            $this->_set_file_folder();
197
-        }
198
-        return $this->_file_folder;
199
-    }
200
-
201
-
202
-    /**
203
-     * @return string
204
-     */
205
-    public function file_url()
206
-    {
207
-        if (! $this->_file_url) {
208
-            $this->_set_file_url();
209
-        }
210
-        return $this->_file_url;
211
-    }
212
-
213
-
214
-    /**
215
-     * Sets the payment method instance this payment method type is for.
216
-     * Its important teh payment method instance is set before
217
-     *
218
-     * @param EE_Payment_Method $payment_method_instance
219
-     */
220
-    public function set_instance($payment_method_instance)
221
-    {
222
-        $this->_pm_instance = $payment_method_instance;
223
-        // if they have already requested the settings form, make sure its
224
-        // data matches this model object
225
-        if ($this->_settings_form) {
226
-            $this->settings_form()->populate_model_obj($payment_method_instance);
227
-        }
228
-        if ($this->_gateway && $this->_gateway instanceof EE_Gateway) {
229
-            $this->_gateway->set_settings($payment_method_instance->settings_array());
230
-        }
231
-    }
232
-
233
-
234
-    /**
235
-     * Gets teh form for displaying to admins where they setup the payment method
236
-     *
237
-     * @return EE_Payment_Method_Form
238
-     */
239
-    public function settings_form()
240
-    {
241
-        if (! $this->_settings_form) {
242
-            $this->_settings_form = $this->generate_new_settings_form();
243
-            $this->_settings_form->set_payment_method_type($this);
244
-            // if we have already assigned a model object to this pmt, make
245
-            // sure its reflected in teh form we just generated
246
-            if ($this->_pm_instance) {
247
-                $this->_settings_form->populate_model_obj($this->_pm_instance);
248
-            }
249
-        }
250
-        return $this->_settings_form;
251
-    }
252
-
253
-
254
-    /**
255
-     * Gets the form for all the settings related to this payment method type
256
-     *
257
-     * @return EE_Payment_Method_Form
258
-     */
259
-    abstract public function generate_new_settings_form();
260
-
261
-
262
-    /**
263
-     * Sets the form for settings. This may be useful if we have already received
264
-     * a form submission and have form data it in, and want to use it anytime we're showing
265
-     * this payment method type's settings form later in the request
266
-     *
267
-     * @param EE_Payment_Method_Form $form
268
-     */
269
-    public function set_settings_form($form)
270
-    {
271
-        $this->_settings_form = $form;
272
-    }
273
-
274
-
275
-    /**
276
-     * @return boolean
277
-     */
278
-    public function has_billing_form()
279
-    {
280
-        return $this->_has_billing_form;
281
-    }
282
-
283
-
284
-    /**
285
-     * Gets the form for displaying to attendees where they can enter their billing info
286
-     * which will be sent to teh gateway (can be null)
287
-     *
288
-     * @param \EE_Transaction $transaction
289
-     * @param array           $extra_args
290
-     * @return \EE_Billing_Attendee_Info_Form|\EE_Billing_Info_Form|null
291
-     */
292
-    public function billing_form(EE_Transaction $transaction = null, $extra_args = array())
293
-    {
294
-        // has billing form already been regenerated ? or overwrite cache?
295
-        if (! $this->_billing_form instanceof EE_Billing_Info_Form || ! $this->_cache_billing_form) {
296
-            $this->_billing_form = $this->generate_new_billing_form($transaction, $extra_args);
297
-        }
298
-        // if we know who the attendee is, and this is a billing form
299
-        // that uses attendee info, populate it
300
-        if (apply_filters(
301
-            'FHEE__populate_billing_form_fields_from_attendee',
302
-            ($this->_billing_form instanceof EE_Billing_Attendee_Info_Form
303
-                && $transaction instanceof EE_Transaction
304
-                && $transaction->primary_registration() instanceof EE_Registration
305
-                && $transaction->primary_registration()->attendee() instanceof EE_Attendee
306
-            ),
307
-            $this->_billing_form,
308
-            $transaction
309
-        )) {
310
-            $this->_billing_form->populate_from_attendee($transaction->primary_registration()->attendee());
311
-        }
312
-        return $this->_billing_form;
313
-    }
314
-
315
-
316
-    /**
317
-     * Creates the billing form for this payment method type
318
-     *
319
-     * @param \EE_Transaction $transaction
320
-     * @return \EE_Billing_Info_Form
321
-     */
322
-    abstract public function generate_new_billing_form(EE_Transaction $transaction = null);
323
-
324
-
325
-    /**
326
-     * apply_billing_form_debug_settings
327
-     * applies debug data to the form
328
-     *
329
-     * @param \EE_Billing_Info_Form $billing_form
330
-     * @return \EE_Billing_Info_Form
331
-     */
332
-    public function apply_billing_form_debug_settings(EE_Billing_Info_Form $billing_form)
333
-    {
334
-        return $billing_form;
335
-    }
336
-
337
-
338
-    /**
339
-     * Sets the billing form for this payment method type. You may want to use this
340
-     * if you have form
341
-     *
342
-     * @param EE_Payment_Method $form
343
-     */
344
-    public function set_billing_form($form)
345
-    {
346
-        $this->_billing_form = $form;
347
-    }
348
-
349
-
350
-    /**
351
-     * Returns whether or not this payment method requires HTTPS to be used
352
-     *
353
-     * @return boolean
354
-     */
355
-    public function requires_https()
356
-    {
357
-        return $this->_requires_https;
358
-    }
359
-
360
-
361
-    /**
362
-     *
363
-     * @param EE_Transaction       $transaction
364
-     * @param float                $amount
365
-     * @param EE_Billing_Info_Form $billing_info
366
-     * @param string               $return_url
367
-     * @param string               $fail_url
368
-     * @param string               $method
369
-     * @param bool                 $by_admin
370
-     * @return EE_Payment
371
-     * @throws EE_Error
372
-     */
373
-    public function process_payment(
374
-        EE_Transaction $transaction,
375
-        $amount = null,
376
-        $billing_info = null,
377
-        $return_url = null,
378
-        $fail_url = '',
379
-        $method = 'CART',
380
-        $by_admin = false
381
-    ) {
382
-        // @todo: add surcharge for the payment method, if any
383
-        if ($this->_gateway) {
384
-            // there is a gateway, so we're going to make a payment object
385
-            // but wait! do they already have a payment in progress that we thought was failed?
386
-            $duplicate_properties = array(
387
-                'STS_ID'               => EEM_Payment::status_id_failed,
388
-                'TXN_ID'               => $transaction->ID(),
389
-                'PMD_ID'               => $this->_pm_instance->ID(),
390
-                'PAY_source'           => $method,
391
-                'PAY_amount'           => $amount !== null ? $amount : $transaction->remaining(),
392
-                'PAY_gateway_response' => null,
393
-            );
394
-            $payment = EEM_Payment::instance()->get_one(array($duplicate_properties));
395
-            // if we didn't already have a payment in progress for the same thing,
396
-            // then we actually want to make a new payment
397
-            if (! $payment instanceof EE_Payment) {
398
-                $payment = EE_Payment::new_instance(
399
-                    array_merge(
400
-                        $duplicate_properties,
401
-                        array(
402
-                            'PAY_timestamp'       => time(),
403
-                            'PAY_txn_id_chq_nmbr' => null,
404
-                            'PAY_po_number'       => null,
405
-                            'PAY_extra_accntng'   => null,
406
-                            'PAY_details'         => null,
407
-                        )
408
-                    )
409
-                );
410
-            }
411
-            // make sure the payment has been saved to show we started it, and so it has an ID should the gateway try to log it
412
-            $payment->save();
413
-            $billing_values = $this->_get_billing_values_from_form($billing_info);
414
-
415
-            //  Offsite Gateway
416
-            if ($this->_gateway instanceof EE_Offsite_Gateway) {
417
-                $payment = $this->_gateway->set_redirection_info(
418
-                    $payment,
419
-                    $billing_values,
420
-                    $return_url,
421
-                    EE_Config::instance()->core->txn_page_url(
422
-                        array(
423
-                            'e_reg_url_link'    => $transaction->primary_registration()->reg_url_link(),
424
-                            'ee_payment_method' => $this->_pm_instance->slug(),
425
-                        )
426
-                    ),
427
-                    $fail_url
428
-                );
429
-                $payment->save();
430
-                //  Onsite Gateway
431
-            } elseif ($this->_gateway instanceof EE_Onsite_Gateway) {
432
-                $payment = $this->_gateway->do_direct_payment($payment, $billing_values);
433
-                $payment->save();
434
-            } else {
435
-                throw new EE_Error(
436
-                    sprintf(
437
-                        __(
438
-                            'Gateway for payment method type "%s" is "%s", not a subclass of either EE_Offsite_Gateway or EE_Onsite_Gateway, or null (to indicate NO gateway)',
439
-                            'event_espresso'
440
-                        ),
441
-                        get_class($this),
442
-                        gettype($this->_gateway)
443
-                    )
444
-                );
445
-            }
446
-        } else {
447
-            // no gateway provided
448
-            // there is no payment. Must be an offline gateway
449
-            // create a payment object anyways, but dont save it
450
-            $payment = EE_Payment::new_instance(
451
-                array(
452
-                    'STS_ID'        => EEM_Payment::status_id_pending,
453
-                    'TXN_ID'        => $transaction->ID(),
454
-                    'PMD_ID'        => $transaction->payment_method_ID(),
455
-                    'PAY_amount'    => 0.00,
456
-                    'PAY_timestamp' => time(),
457
-                )
458
-            );
459
-        }
460
-
461
-        // if there is billing info, clean it and save it now
462
-        if ($billing_info instanceof EE_Billing_Attendee_Info_Form) {
463
-            $this->_save_billing_info_to_attendee($billing_info, $transaction);
464
-        }
465
-
466
-        return $payment;
467
-    }
468
-
469
-    /**
470
-     * Gets the values we want to pass onto the gateway. Normally these
471
-     * are just the 'pretty' values, but there may be times the data may need
472
-     * a  little massaging. Proper subsections will become arrays of inputs
473
-     *
474
-     * @param EE_Billing_Info_Form $billing_form
475
-     * @return array
476
-     */
477
-    protected function _get_billing_values_from_form($billing_form)
478
-    {
479
-        if ($billing_form instanceof EE_Form_Section_Proper) {
480
-            return $billing_form->input_pretty_values(true);
481
-        } else {
482
-            return null;
483
-        }
484
-    }
485
-
486
-
487
-    /**
488
-     * Handles an instant payment notification when the transaction is known (by default).
489
-     *
490
-     * @param array          $req_data
491
-     * @param EE_Transaction $transaction
492
-     * @return EE_Payment
493
-     * @throws EE_Error
494
-     */
495
-    public function handle_ipn($req_data, $transaction)
496
-    {
497
-        $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction);
498
-        if (! $this->_gateway instanceof EE_Offsite_Gateway) {
499
-            throw new EE_Error(
500
-                sprintf(
501
-                    __("Could not handle IPN because '%s' is not an offsite gateway", "event_espresso"),
502
-                    print_r($this->_gateway, true)
503
-                )
504
-            );
505
-        }
506
-        $payment = $this->_gateway->handle_payment_update($req_data, $transaction);
507
-        return $payment;
508
-    }
509
-
510
-
511
-    /**
512
-     * Saves the billing info onto the attendee of the primary registrant on this transaction, and
513
-     * cleans it first.
514
-     *
515
-     * @param EE_Billing_Attendee_Info_Form $billing_form
516
-     * @param EE_Transaction                $transaction
517
-     * @return boolean success
518
-     */
519
-    protected function _save_billing_info_to_attendee($billing_form, $transaction)
520
-    {
521
-        if (! $transaction || ! $transaction instanceof EE_Transaction) {
522
-            EE_Error::add_error(
523
-                __("Cannot save billing info because no transaction was specified", "event_espresso"),
524
-                __FILE__,
525
-                __FUNCTION__,
526
-                __LINE__
527
-            );
528
-            return false;
529
-        }
530
-        $primary_reg = $transaction->primary_registration();
531
-        if (! $primary_reg) {
532
-            EE_Error::add_error(
533
-                __("Cannot save billing info because the transaction has no primary registration", "event_espresso"),
534
-                __FILE__,
535
-                __FUNCTION__,
536
-                __LINE__
537
-            );
538
-            return false;
539
-        }
540
-        $attendee = $primary_reg->attendee();
541
-        if (! $attendee) {
542
-            EE_Error::add_error(
543
-                __(
544
-                    "Cannot save billing info because the transaction's primary registration has no attendee!",
545
-                    "event_espresso"
546
-                ),
547
-                __FILE__,
548
-                __FUNCTION__,
549
-                __LINE__
550
-            );
551
-            return false;
552
-        }
553
-        return $attendee->save_and_clean_billing_info_for_payment_method($billing_form, $transaction->payment_method());
554
-    }
555
-
556
-
557
-    /**
558
-     * Gets the payment this IPN is for. Children may often want to
559
-     * override this to inspect the request
560
-     *
561
-     * @param EE_Transaction $transaction
562
-     * @param array          $req_data
563
-     * @return EE_Payment
564
-     */
565
-    protected function find_payment_for_ipn(EE_Transaction $transaction, $req_data = array())
566
-    {
567
-        return $transaction->last_payment();
568
-    }
569
-
570
-
571
-    /**
572
-     * In case generic code cannot provide the payment processor with a specific payment method
573
-     * and transaction, it will try calling this method on each activate payment method.
574
-     * If the payment method is able to identify the request as being for it, it should fetch
575
-     * the payment its for and return it. If not, it should throw an EE_Error to indicate it cannot
576
-     * handle the IPN
577
-     *
578
-     * @param array $req_data
579
-     * @return EE_Payment only if this payment method can find the info its needs from $req_data
580
-     * and identifies the IPN as being for this payment method (not just fo ra payment method of this type)
581
-     * @throws EE_Error
582
-     */
583
-    public function handle_unclaimed_ipn($req_data = array())
584
-    {
585
-        throw new EE_Error(
586
-            sprintf(__("Payment Method '%s' cannot handle unclaimed IPNs", "event_espresso"), get_class($this))
587
-        );
588
-    }
589
-
590
-
591
-    /**
592
-     * Logic to be accomplished when the payment attempt is complete.
593
-     * Most payment methods don't need to do anything at this point; but some, like Mijireh, do.
594
-     * (Mijireh is an offsite gateway which doesn't send an IPN. So when the user returns to EE from
595
-     * mijireh, this method needs to be called so the Mijireh PM can ping Mijireh to know the status
596
-     * of the payment). Fed a transaction because it's always assumed to be the last payment that
597
-     * we're dealing with. Returns that last payment (if there is one)
598
-     *
599
-     * @param EE_Transaction $transaction
600
-     * @return EE_Payment
601
-     */
602
-    public function finalize_payment_for($transaction)
603
-    {
604
-        return $transaction->last_payment();
605
-    }
606
-
607
-
608
-    /**
609
-     * Whether or not this payment method's gateway supports sending refund requests
610
-     *
611
-     * @return boolean
612
-     */
613
-    public function supports_sending_refunds()
614
-    {
615
-        if ($this->_gateway && $this->_gateway instanceof EE_Gateway) {
616
-            return $this->_gateway->supports_sending_refunds();
617
-        } else {
618
-            return false;
619
-        }
620
-    }
621
-
622
-
623
-    /**
624
-     *
625
-     * @param EE_Payment $payment
626
-     * @param array      $refund_info
627
-     * @throws EE_Error
628
-     * @return EE_Payment
629
-     */
630
-    public function process_refund(EE_Payment $payment, $refund_info = array())
631
-    {
632
-        if ($this->_gateway && $this->_gateway instanceof EE_Gateway) {
633
-            return $this->_gateway->do_direct_refund($payment, $refund_info);
634
-        } else {
635
-            throw new EE_Error(
636
-                sprintf(
637
-                    __('Payment Method Type "%s" does not support sending refund requests', 'event_espresso'),
638
-                    get_class($this)
639
-                )
640
-            );
641
-        }
642
-    }
643
-
644
-
645
-    /**
646
-     * Returns one the class's constants onsite,offsite, or offline, depending on this
647
-     * payment method's gateway.
648
-     *
649
-     * @return string
650
-     * @throws EE_Error
651
-     */
652
-    public function payment_occurs()
653
-    {
654
-        if (! $this->_gateway) {
655
-            return EE_PMT_Base::offline;
656
-        } elseif ($this->_gateway instanceof EE_Onsite_Gateway) {
657
-            return EE_PMT_Base::onsite;
658
-        } elseif ($this->_gateway instanceof EE_Offsite_Gateway) {
659
-            return EE_PMT_Base::offsite;
660
-        } else {
661
-            throw new EE_Error(
662
-                sprintf(
663
-                    __(
664
-                        "Payment method type '%s's gateway isn't an instance of EE_Onsite_Gateway, EE_Offsite_Gateway, or null. It must be one of those",
665
-                        "event_espresso"
666
-                    ),
667
-                    get_class($this)
668
-                )
669
-            );
670
-        }
671
-    }
672
-
673
-
674
-    /**
675
-     * For adding any html output ab ove the payment overview.
676
-     * Many gateways won't want ot display anything, so this function just returns an empty string.
677
-     * Other gateways may want to override this, such as offline gateways.
678
-     *
679
-     * @param EE_Payment $payment
680
-     * @return string
681
-     */
682
-    public function payment_overview_content(EE_Payment $payment)
683
-    {
684
-        return EEH_Template::display_template(
685
-            EE_LIBRARIES . 'payment_methods' . DS . 'templates' . DS . 'payment_details_content.template.php',
686
-            array('payment_method' => $this->_pm_instance, 'payment' => $payment),
687
-            true
688
-        );
689
-    }
690
-
691
-
692
-    /**
693
-     * @return array where keys are the help tab name,
694
-     * values are: array {
695
-     * @type string $title         i18n name for the help tab
696
-     * @type string $filename      name of the file located in ./help_tabs/ (ie, in a folder next to this file)
697
-     * @type array  $template_args any arguments you want passed to the template file while rendering.
698
-     *                Keys will be variable names and values with be their values.
699
-     */
700
-    public function help_tabs_config()
701
-    {
702
-        return array();
703
-    }
704
-
705
-
706
-    /**
707
-     * The system name for this PMT (eg AIM, Paypal_Pro, Invoice... what gets put into
708
-     * the payment method's table's PMT_type column)
709
-     *
710
-     * @return string
711
-     */
712
-    public function system_name()
713
-    {
714
-        $classname = get_class($this);
715
-        return str_replace("EE_PMT_", '', $classname);
716
-    }
717
-
718
-
719
-    /**
720
-     * A pretty i18n version of the PMT name
721
-     *
722
-     * @return string
723
-     */
724
-    public function pretty_name()
725
-    {
726
-        return $this->_pretty_name;
727
-    }
728
-
729
-
730
-    /**
731
-     * Gets the default absolute URL to the payment method type's button
732
-     *
733
-     * @return string
734
-     */
735
-    public function default_button_url()
736
-    {
737
-        return $this->_default_button_url;
738
-    }
739
-
740
-
741
-    /**
742
-     * Gets the gateway used by this payment method (if any)
743
-     *
744
-     * @return EE_Gateway
745
-     */
746
-    public function get_gateway()
747
-    {
748
-        return $this->_gateway;
749
-    }
750
-
751
-
752
-    /**
753
-     * @return string html for the link to a help tab
754
-     */
755
-    public function get_help_tab_link()
756
-    {
757
-        return EEH_Template::get_help_tab_link(
758
-            $this->get_help_tab_name(),
759
-            'espresso_payment_settings',
760
-            'default'
761
-        );
762
-    }
763
-
764
-
765
-    /**
766
-     * Returns the name of the help tab for this PMT
767
-     *
768
-     * @return string
769
-     */
770
-    public function get_help_tab_name()
771
-    {
772
-        return 'ee_' . strtolower($this->system_name()) . '_help_tab';
773
-    }
774
-
775
-    /**
776
-     * The name of the wp capability that should be associated with the usage of
777
-     * this PMT by an admin
778
-     *
779
-     * @return string
780
-     */
781
-    public function cap_name()
782
-    {
783
-        return 'ee_payment_method_' . strtolower($this->system_name());
784
-    }
785
-
786
-    /**
787
-     * Called by client code to tell the gateway that if it wants to change
788
-     * the transaction or line items or registrations related to teh payment it already
789
-     * processed (we think, but possibly not) that now's the time to do it.
790
-     * It is expected that gateways will store any info they need for this on the PAY_details,
791
-     * or maybe an extra meta value
792
-     *
793
-     * @param EE_Payment $payment
794
-     * @return void
795
-     */
796
-    public function update_txn_based_on_payment($payment)
797
-    {
798
-        if ($this->_gateway instanceof EE_Gateway) {
799
-            $this->_gateway->update_txn_based_on_payment($payment);
800
-        }
801
-    }
802
-
803
-    /**
804
-     * Returns a string of HTML describing this payment method type for an admin,
805
-     * primarily intended for them to read before activating it.
806
-     * The easiest way to set this is to create a folder 'templates' alongside
807
-     * your EE_PMT_{System_Name} file, and in it create a file named "{system_name}_intro.template.php".
808
-     * Eg, if your payment method file is named "EE_PMT_Foo_Bar.pm.php",
809
-     * then you'd create a file named "templates" in the same folder as it, and name the file
810
-     * "foo_bar_intro.template.php", and its content will be returned by this method
811
-     *
812
-     * @return string
813
-     */
814
-    public function introductory_html()
815
-    {
816
-        return EEH_Template::locate_template(
817
-            $this->file_folder() . 'templates' . DS . strtolower($this->system_name()) . '_intro.template.php',
818
-            array('pmt_obj' => $this, 'pm_instance' => $this->_pm_instance)
819
-        );
820
-    }
24
+	const onsite = 'on-site';
25
+	const offsite = 'off-site';
26
+	const offline = 'off-line';
27
+
28
+	/**
29
+	 * @var EE_Payment_Method
30
+	 */
31
+	protected $_pm_instance = null;
32
+
33
+	/**
34
+	 * @var boolean
35
+	 */
36
+	protected $_requires_https = false;
37
+
38
+	/**
39
+	 * @var boolean
40
+	 */
41
+	protected $_has_billing_form;
42
+
43
+	/**
44
+	 * @var EE_Gateway
45
+	 */
46
+	protected $_gateway = null;
47
+
48
+	/**
49
+	 * @var EE_Payment_Method_Form
50
+	 */
51
+	protected $_settings_form = null;
52
+
53
+	/**
54
+	 * @var EE_Form_Section_Proper
55
+	 */
56
+	protected $_billing_form = null;
57
+
58
+	/**
59
+	 * @var boolean
60
+	 */
61
+	protected $_cache_billing_form = true;
62
+
63
+	/**
64
+	 * String of the absolute path to the folder containing this file, with a trailing slash.
65
+	 * eg '/public_html/wp-site/wp-content/plugins/event-espresso/payment_methods/Invoice/'
66
+	 *
67
+	 * @var string
68
+	 */
69
+	protected $_file_folder = null;
70
+
71
+	/**
72
+	 * String to the absolute URL to this file (useful for getting its web-accessible resources
73
+	 * like images, js, or css)
74
+	 *
75
+	 * @var string
76
+	 */
77
+	protected $_file_url = null;
78
+
79
+	/**
80
+	 * Pretty name for the payment method
81
+	 *
82
+	 * @var string
83
+	 */
84
+	protected $_pretty_name = null;
85
+
86
+	/**
87
+	 *
88
+	 * @var string
89
+	 */
90
+	protected $_default_button_url = null;
91
+
92
+	/**
93
+	 *
94
+	 * @var string
95
+	 */
96
+	protected $_default_description = null;
97
+
98
+
99
+	/**
100
+	 *
101
+	 * @param EE_Payment_Method $pm_instance
102
+	 * @throws EE_Error
103
+	 * @return EE_PMT_Base
104
+	 */
105
+	public function __construct($pm_instance = null)
106
+	{
107
+		if ($pm_instance instanceof EE_Payment_Method) {
108
+			$this->set_instance($pm_instance);
109
+		}
110
+		if ($this->_gateway) {
111
+			$this->_gateway->set_payment_model(EEM_Payment::instance());
112
+			$this->_gateway->set_payment_log(EEM_Change_Log::instance());
113
+			$this->_gateway->set_template_helper(new EEH_Template());
114
+			$this->_gateway->set_line_item_helper(new EEH_Line_Item());
115
+			$this->_gateway->set_money_helper(new EEH_Money());
116
+			$this->_gateway->set_gateway_data_formatter(new GatewayDataFormatter());
117
+			$this->_gateway->set_unsupported_character_remover(new AsciiOnly());
118
+			do_action('AHEE__EE_PMT_Base___construct__done_initializing_gateway_class', $this, $this->_gateway);
119
+		}
120
+		if (! isset($this->_has_billing_form)) {
121
+			// by default, On Site gateways have a billing form
122
+			if ($this->payment_occurs() == EE_PMT_Base::onsite) {
123
+				$this->set_has_billing_form(true);
124
+			} else {
125
+				$this->set_has_billing_form(false);
126
+			}
127
+		}
128
+
129
+		if (! $this->_pretty_name) {
130
+			throw new EE_Error(
131
+				sprintf(
132
+					__(
133
+						"You must set the pretty name for the Payment Method Type in the constructor (_pretty_name), and please make it internationalized",
134
+						"event_espresso"
135
+					)
136
+				)
137
+			);
138
+		}
139
+		// if the child didn't specify a default button, use the credit card one
140
+		if ($this->_default_button_url === null) {
141
+			$this->_default_button_url = EE_PLUGIN_DIR_URL . 'payment_methods' . DS . 'pay-by-credit-card.png';
142
+		}
143
+	}
144
+
145
+
146
+	/**
147
+	 * @param boolean $has_billing_form
148
+	 */
149
+	public function set_has_billing_form($has_billing_form)
150
+	{
151
+		$this->_has_billing_form = filter_var($has_billing_form, FILTER_VALIDATE_BOOLEAN);
152
+	}
153
+
154
+
155
+	/**
156
+	 * sets the file_folder property
157
+	 */
158
+	protected function _set_file_folder()
159
+	{
160
+		$reflector = new ReflectionClass(get_class($this));
161
+		$fn = $reflector->getFileName();
162
+		$this->_file_folder = dirname($fn) . DS;
163
+	}
164
+
165
+
166
+	/**
167
+	 * sets the file URL with a trailing slash for this PMT
168
+	 */
169
+	protected function _set_file_url()
170
+	{
171
+		$plugins_dir_fixed = str_replace('\\', DS, WP_PLUGIN_DIR);
172
+		$file_folder_fixed = str_replace('\\', DS, $this->file_folder());
173
+		$file_path = str_replace($plugins_dir_fixed, WP_PLUGIN_URL, $file_folder_fixed);
174
+		$this->_file_url = $file_path;
175
+	}
176
+
177
+	/**
178
+	 * Gets the default description on all payment methods of this type
179
+	 *
180
+	 * @return string
181
+	 */
182
+	public function default_description()
183
+	{
184
+		return $this->_default_description;
185
+	}
186
+
187
+
188
+	/**
189
+	 * Returns the folder containing the PMT child class, with a trailing slash
190
+	 *
191
+	 * @return string
192
+	 */
193
+	public function file_folder()
194
+	{
195
+		if (! $this->_file_folder) {
196
+			$this->_set_file_folder();
197
+		}
198
+		return $this->_file_folder;
199
+	}
200
+
201
+
202
+	/**
203
+	 * @return string
204
+	 */
205
+	public function file_url()
206
+	{
207
+		if (! $this->_file_url) {
208
+			$this->_set_file_url();
209
+		}
210
+		return $this->_file_url;
211
+	}
212
+
213
+
214
+	/**
215
+	 * Sets the payment method instance this payment method type is for.
216
+	 * Its important teh payment method instance is set before
217
+	 *
218
+	 * @param EE_Payment_Method $payment_method_instance
219
+	 */
220
+	public function set_instance($payment_method_instance)
221
+	{
222
+		$this->_pm_instance = $payment_method_instance;
223
+		// if they have already requested the settings form, make sure its
224
+		// data matches this model object
225
+		if ($this->_settings_form) {
226
+			$this->settings_form()->populate_model_obj($payment_method_instance);
227
+		}
228
+		if ($this->_gateway && $this->_gateway instanceof EE_Gateway) {
229
+			$this->_gateway->set_settings($payment_method_instance->settings_array());
230
+		}
231
+	}
232
+
233
+
234
+	/**
235
+	 * Gets teh form for displaying to admins where they setup the payment method
236
+	 *
237
+	 * @return EE_Payment_Method_Form
238
+	 */
239
+	public function settings_form()
240
+	{
241
+		if (! $this->_settings_form) {
242
+			$this->_settings_form = $this->generate_new_settings_form();
243
+			$this->_settings_form->set_payment_method_type($this);
244
+			// if we have already assigned a model object to this pmt, make
245
+			// sure its reflected in teh form we just generated
246
+			if ($this->_pm_instance) {
247
+				$this->_settings_form->populate_model_obj($this->_pm_instance);
248
+			}
249
+		}
250
+		return $this->_settings_form;
251
+	}
252
+
253
+
254
+	/**
255
+	 * Gets the form for all the settings related to this payment method type
256
+	 *
257
+	 * @return EE_Payment_Method_Form
258
+	 */
259
+	abstract public function generate_new_settings_form();
260
+
261
+
262
+	/**
263
+	 * Sets the form for settings. This may be useful if we have already received
264
+	 * a form submission and have form data it in, and want to use it anytime we're showing
265
+	 * this payment method type's settings form later in the request
266
+	 *
267
+	 * @param EE_Payment_Method_Form $form
268
+	 */
269
+	public function set_settings_form($form)
270
+	{
271
+		$this->_settings_form = $form;
272
+	}
273
+
274
+
275
+	/**
276
+	 * @return boolean
277
+	 */
278
+	public function has_billing_form()
279
+	{
280
+		return $this->_has_billing_form;
281
+	}
282
+
283
+
284
+	/**
285
+	 * Gets the form for displaying to attendees where they can enter their billing info
286
+	 * which will be sent to teh gateway (can be null)
287
+	 *
288
+	 * @param \EE_Transaction $transaction
289
+	 * @param array           $extra_args
290
+	 * @return \EE_Billing_Attendee_Info_Form|\EE_Billing_Info_Form|null
291
+	 */
292
+	public function billing_form(EE_Transaction $transaction = null, $extra_args = array())
293
+	{
294
+		// has billing form already been regenerated ? or overwrite cache?
295
+		if (! $this->_billing_form instanceof EE_Billing_Info_Form || ! $this->_cache_billing_form) {
296
+			$this->_billing_form = $this->generate_new_billing_form($transaction, $extra_args);
297
+		}
298
+		// if we know who the attendee is, and this is a billing form
299
+		// that uses attendee info, populate it
300
+		if (apply_filters(
301
+			'FHEE__populate_billing_form_fields_from_attendee',
302
+			($this->_billing_form instanceof EE_Billing_Attendee_Info_Form
303
+				&& $transaction instanceof EE_Transaction
304
+				&& $transaction->primary_registration() instanceof EE_Registration
305
+				&& $transaction->primary_registration()->attendee() instanceof EE_Attendee
306
+			),
307
+			$this->_billing_form,
308
+			$transaction
309
+		)) {
310
+			$this->_billing_form->populate_from_attendee($transaction->primary_registration()->attendee());
311
+		}
312
+		return $this->_billing_form;
313
+	}
314
+
315
+
316
+	/**
317
+	 * Creates the billing form for this payment method type
318
+	 *
319
+	 * @param \EE_Transaction $transaction
320
+	 * @return \EE_Billing_Info_Form
321
+	 */
322
+	abstract public function generate_new_billing_form(EE_Transaction $transaction = null);
323
+
324
+
325
+	/**
326
+	 * apply_billing_form_debug_settings
327
+	 * applies debug data to the form
328
+	 *
329
+	 * @param \EE_Billing_Info_Form $billing_form
330
+	 * @return \EE_Billing_Info_Form
331
+	 */
332
+	public function apply_billing_form_debug_settings(EE_Billing_Info_Form $billing_form)
333
+	{
334
+		return $billing_form;
335
+	}
336
+
337
+
338
+	/**
339
+	 * Sets the billing form for this payment method type. You may want to use this
340
+	 * if you have form
341
+	 *
342
+	 * @param EE_Payment_Method $form
343
+	 */
344
+	public function set_billing_form($form)
345
+	{
346
+		$this->_billing_form = $form;
347
+	}
348
+
349
+
350
+	/**
351
+	 * Returns whether or not this payment method requires HTTPS to be used
352
+	 *
353
+	 * @return boolean
354
+	 */
355
+	public function requires_https()
356
+	{
357
+		return $this->_requires_https;
358
+	}
359
+
360
+
361
+	/**
362
+	 *
363
+	 * @param EE_Transaction       $transaction
364
+	 * @param float                $amount
365
+	 * @param EE_Billing_Info_Form $billing_info
366
+	 * @param string               $return_url
367
+	 * @param string               $fail_url
368
+	 * @param string               $method
369
+	 * @param bool                 $by_admin
370
+	 * @return EE_Payment
371
+	 * @throws EE_Error
372
+	 */
373
+	public function process_payment(
374
+		EE_Transaction $transaction,
375
+		$amount = null,
376
+		$billing_info = null,
377
+		$return_url = null,
378
+		$fail_url = '',
379
+		$method = 'CART',
380
+		$by_admin = false
381
+	) {
382
+		// @todo: add surcharge for the payment method, if any
383
+		if ($this->_gateway) {
384
+			// there is a gateway, so we're going to make a payment object
385
+			// but wait! do they already have a payment in progress that we thought was failed?
386
+			$duplicate_properties = array(
387
+				'STS_ID'               => EEM_Payment::status_id_failed,
388
+				'TXN_ID'               => $transaction->ID(),
389
+				'PMD_ID'               => $this->_pm_instance->ID(),
390
+				'PAY_source'           => $method,
391
+				'PAY_amount'           => $amount !== null ? $amount : $transaction->remaining(),
392
+				'PAY_gateway_response' => null,
393
+			);
394
+			$payment = EEM_Payment::instance()->get_one(array($duplicate_properties));
395
+			// if we didn't already have a payment in progress for the same thing,
396
+			// then we actually want to make a new payment
397
+			if (! $payment instanceof EE_Payment) {
398
+				$payment = EE_Payment::new_instance(
399
+					array_merge(
400
+						$duplicate_properties,
401
+						array(
402
+							'PAY_timestamp'       => time(),
403
+							'PAY_txn_id_chq_nmbr' => null,
404
+							'PAY_po_number'       => null,
405
+							'PAY_extra_accntng'   => null,
406
+							'PAY_details'         => null,
407
+						)
408
+					)
409
+				);
410
+			}
411
+			// make sure the payment has been saved to show we started it, and so it has an ID should the gateway try to log it
412
+			$payment->save();
413
+			$billing_values = $this->_get_billing_values_from_form($billing_info);
414
+
415
+			//  Offsite Gateway
416
+			if ($this->_gateway instanceof EE_Offsite_Gateway) {
417
+				$payment = $this->_gateway->set_redirection_info(
418
+					$payment,
419
+					$billing_values,
420
+					$return_url,
421
+					EE_Config::instance()->core->txn_page_url(
422
+						array(
423
+							'e_reg_url_link'    => $transaction->primary_registration()->reg_url_link(),
424
+							'ee_payment_method' => $this->_pm_instance->slug(),
425
+						)
426
+					),
427
+					$fail_url
428
+				);
429
+				$payment->save();
430
+				//  Onsite Gateway
431
+			} elseif ($this->_gateway instanceof EE_Onsite_Gateway) {
432
+				$payment = $this->_gateway->do_direct_payment($payment, $billing_values);
433
+				$payment->save();
434
+			} else {
435
+				throw new EE_Error(
436
+					sprintf(
437
+						__(
438
+							'Gateway for payment method type "%s" is "%s", not a subclass of either EE_Offsite_Gateway or EE_Onsite_Gateway, or null (to indicate NO gateway)',
439
+							'event_espresso'
440
+						),
441
+						get_class($this),
442
+						gettype($this->_gateway)
443
+					)
444
+				);
445
+			}
446
+		} else {
447
+			// no gateway provided
448
+			// there is no payment. Must be an offline gateway
449
+			// create a payment object anyways, but dont save it
450
+			$payment = EE_Payment::new_instance(
451
+				array(
452
+					'STS_ID'        => EEM_Payment::status_id_pending,
453
+					'TXN_ID'        => $transaction->ID(),
454
+					'PMD_ID'        => $transaction->payment_method_ID(),
455
+					'PAY_amount'    => 0.00,
456
+					'PAY_timestamp' => time(),
457
+				)
458
+			);
459
+		}
460
+
461
+		// if there is billing info, clean it and save it now
462
+		if ($billing_info instanceof EE_Billing_Attendee_Info_Form) {
463
+			$this->_save_billing_info_to_attendee($billing_info, $transaction);
464
+		}
465
+
466
+		return $payment;
467
+	}
468
+
469
+	/**
470
+	 * Gets the values we want to pass onto the gateway. Normally these
471
+	 * are just the 'pretty' values, but there may be times the data may need
472
+	 * a  little massaging. Proper subsections will become arrays of inputs
473
+	 *
474
+	 * @param EE_Billing_Info_Form $billing_form
475
+	 * @return array
476
+	 */
477
+	protected function _get_billing_values_from_form($billing_form)
478
+	{
479
+		if ($billing_form instanceof EE_Form_Section_Proper) {
480
+			return $billing_form->input_pretty_values(true);
481
+		} else {
482
+			return null;
483
+		}
484
+	}
485
+
486
+
487
+	/**
488
+	 * Handles an instant payment notification when the transaction is known (by default).
489
+	 *
490
+	 * @param array          $req_data
491
+	 * @param EE_Transaction $transaction
492
+	 * @return EE_Payment
493
+	 * @throws EE_Error
494
+	 */
495
+	public function handle_ipn($req_data, $transaction)
496
+	{
497
+		$transaction = EEM_Transaction::instance()->ensure_is_obj($transaction);
498
+		if (! $this->_gateway instanceof EE_Offsite_Gateway) {
499
+			throw new EE_Error(
500
+				sprintf(
501
+					__("Could not handle IPN because '%s' is not an offsite gateway", "event_espresso"),
502
+					print_r($this->_gateway, true)
503
+				)
504
+			);
505
+		}
506
+		$payment = $this->_gateway->handle_payment_update($req_data, $transaction);
507
+		return $payment;
508
+	}
509
+
510
+
511
+	/**
512
+	 * Saves the billing info onto the attendee of the primary registrant on this transaction, and
513
+	 * cleans it first.
514
+	 *
515
+	 * @param EE_Billing_Attendee_Info_Form $billing_form
516
+	 * @param EE_Transaction                $transaction
517
+	 * @return boolean success
518
+	 */
519
+	protected function _save_billing_info_to_attendee($billing_form, $transaction)
520
+	{
521
+		if (! $transaction || ! $transaction instanceof EE_Transaction) {
522
+			EE_Error::add_error(
523
+				__("Cannot save billing info because no transaction was specified", "event_espresso"),
524
+				__FILE__,
525
+				__FUNCTION__,
526
+				__LINE__
527
+			);
528
+			return false;
529
+		}
530
+		$primary_reg = $transaction->primary_registration();
531
+		if (! $primary_reg) {
532
+			EE_Error::add_error(
533
+				__("Cannot save billing info because the transaction has no primary registration", "event_espresso"),
534
+				__FILE__,
535
+				__FUNCTION__,
536
+				__LINE__
537
+			);
538
+			return false;
539
+		}
540
+		$attendee = $primary_reg->attendee();
541
+		if (! $attendee) {
542
+			EE_Error::add_error(
543
+				__(
544
+					"Cannot save billing info because the transaction's primary registration has no attendee!",
545
+					"event_espresso"
546
+				),
547
+				__FILE__,
548
+				__FUNCTION__,
549
+				__LINE__
550
+			);
551
+			return false;
552
+		}
553
+		return $attendee->save_and_clean_billing_info_for_payment_method($billing_form, $transaction->payment_method());
554
+	}
555
+
556
+
557
+	/**
558
+	 * Gets the payment this IPN is for. Children may often want to
559
+	 * override this to inspect the request
560
+	 *
561
+	 * @param EE_Transaction $transaction
562
+	 * @param array          $req_data
563
+	 * @return EE_Payment
564
+	 */
565
+	protected function find_payment_for_ipn(EE_Transaction $transaction, $req_data = array())
566
+	{
567
+		return $transaction->last_payment();
568
+	}
569
+
570
+
571
+	/**
572
+	 * In case generic code cannot provide the payment processor with a specific payment method
573
+	 * and transaction, it will try calling this method on each activate payment method.
574
+	 * If the payment method is able to identify the request as being for it, it should fetch
575
+	 * the payment its for and return it. If not, it should throw an EE_Error to indicate it cannot
576
+	 * handle the IPN
577
+	 *
578
+	 * @param array $req_data
579
+	 * @return EE_Payment only if this payment method can find the info its needs from $req_data
580
+	 * and identifies the IPN as being for this payment method (not just fo ra payment method of this type)
581
+	 * @throws EE_Error
582
+	 */
583
+	public function handle_unclaimed_ipn($req_data = array())
584
+	{
585
+		throw new EE_Error(
586
+			sprintf(__("Payment Method '%s' cannot handle unclaimed IPNs", "event_espresso"), get_class($this))
587
+		);
588
+	}
589
+
590
+
591
+	/**
592
+	 * Logic to be accomplished when the payment attempt is complete.
593
+	 * Most payment methods don't need to do anything at this point; but some, like Mijireh, do.
594
+	 * (Mijireh is an offsite gateway which doesn't send an IPN. So when the user returns to EE from
595
+	 * mijireh, this method needs to be called so the Mijireh PM can ping Mijireh to know the status
596
+	 * of the payment). Fed a transaction because it's always assumed to be the last payment that
597
+	 * we're dealing with. Returns that last payment (if there is one)
598
+	 *
599
+	 * @param EE_Transaction $transaction
600
+	 * @return EE_Payment
601
+	 */
602
+	public function finalize_payment_for($transaction)
603
+	{
604
+		return $transaction->last_payment();
605
+	}
606
+
607
+
608
+	/**
609
+	 * Whether or not this payment method's gateway supports sending refund requests
610
+	 *
611
+	 * @return boolean
612
+	 */
613
+	public function supports_sending_refunds()
614
+	{
615
+		if ($this->_gateway && $this->_gateway instanceof EE_Gateway) {
616
+			return $this->_gateway->supports_sending_refunds();
617
+		} else {
618
+			return false;
619
+		}
620
+	}
621
+
622
+
623
+	/**
624
+	 *
625
+	 * @param EE_Payment $payment
626
+	 * @param array      $refund_info
627
+	 * @throws EE_Error
628
+	 * @return EE_Payment
629
+	 */
630
+	public function process_refund(EE_Payment $payment, $refund_info = array())
631
+	{
632
+		if ($this->_gateway && $this->_gateway instanceof EE_Gateway) {
633
+			return $this->_gateway->do_direct_refund($payment, $refund_info);
634
+		} else {
635
+			throw new EE_Error(
636
+				sprintf(
637
+					__('Payment Method Type "%s" does not support sending refund requests', 'event_espresso'),
638
+					get_class($this)
639
+				)
640
+			);
641
+		}
642
+	}
643
+
644
+
645
+	/**
646
+	 * Returns one the class's constants onsite,offsite, or offline, depending on this
647
+	 * payment method's gateway.
648
+	 *
649
+	 * @return string
650
+	 * @throws EE_Error
651
+	 */
652
+	public function payment_occurs()
653
+	{
654
+		if (! $this->_gateway) {
655
+			return EE_PMT_Base::offline;
656
+		} elseif ($this->_gateway instanceof EE_Onsite_Gateway) {
657
+			return EE_PMT_Base::onsite;
658
+		} elseif ($this->_gateway instanceof EE_Offsite_Gateway) {
659
+			return EE_PMT_Base::offsite;
660
+		} else {
661
+			throw new EE_Error(
662
+				sprintf(
663
+					__(
664
+						"Payment method type '%s's gateway isn't an instance of EE_Onsite_Gateway, EE_Offsite_Gateway, or null. It must be one of those",
665
+						"event_espresso"
666
+					),
667
+					get_class($this)
668
+				)
669
+			);
670
+		}
671
+	}
672
+
673
+
674
+	/**
675
+	 * For adding any html output ab ove the payment overview.
676
+	 * Many gateways won't want ot display anything, so this function just returns an empty string.
677
+	 * Other gateways may want to override this, such as offline gateways.
678
+	 *
679
+	 * @param EE_Payment $payment
680
+	 * @return string
681
+	 */
682
+	public function payment_overview_content(EE_Payment $payment)
683
+	{
684
+		return EEH_Template::display_template(
685
+			EE_LIBRARIES . 'payment_methods' . DS . 'templates' . DS . 'payment_details_content.template.php',
686
+			array('payment_method' => $this->_pm_instance, 'payment' => $payment),
687
+			true
688
+		);
689
+	}
690
+
691
+
692
+	/**
693
+	 * @return array where keys are the help tab name,
694
+	 * values are: array {
695
+	 * @type string $title         i18n name for the help tab
696
+	 * @type string $filename      name of the file located in ./help_tabs/ (ie, in a folder next to this file)
697
+	 * @type array  $template_args any arguments you want passed to the template file while rendering.
698
+	 *                Keys will be variable names and values with be their values.
699
+	 */
700
+	public function help_tabs_config()
701
+	{
702
+		return array();
703
+	}
704
+
705
+
706
+	/**
707
+	 * The system name for this PMT (eg AIM, Paypal_Pro, Invoice... what gets put into
708
+	 * the payment method's table's PMT_type column)
709
+	 *
710
+	 * @return string
711
+	 */
712
+	public function system_name()
713
+	{
714
+		$classname = get_class($this);
715
+		return str_replace("EE_PMT_", '', $classname);
716
+	}
717
+
718
+
719
+	/**
720
+	 * A pretty i18n version of the PMT name
721
+	 *
722
+	 * @return string
723
+	 */
724
+	public function pretty_name()
725
+	{
726
+		return $this->_pretty_name;
727
+	}
728
+
729
+
730
+	/**
731
+	 * Gets the default absolute URL to the payment method type's button
732
+	 *
733
+	 * @return string
734
+	 */
735
+	public function default_button_url()
736
+	{
737
+		return $this->_default_button_url;
738
+	}
739
+
740
+
741
+	/**
742
+	 * Gets the gateway used by this payment method (if any)
743
+	 *
744
+	 * @return EE_Gateway
745
+	 */
746
+	public function get_gateway()
747
+	{
748
+		return $this->_gateway;
749
+	}
750
+
751
+
752
+	/**
753
+	 * @return string html for the link to a help tab
754
+	 */
755
+	public function get_help_tab_link()
756
+	{
757
+		return EEH_Template::get_help_tab_link(
758
+			$this->get_help_tab_name(),
759
+			'espresso_payment_settings',
760
+			'default'
761
+		);
762
+	}
763
+
764
+
765
+	/**
766
+	 * Returns the name of the help tab for this PMT
767
+	 *
768
+	 * @return string
769
+	 */
770
+	public function get_help_tab_name()
771
+	{
772
+		return 'ee_' . strtolower($this->system_name()) . '_help_tab';
773
+	}
774
+
775
+	/**
776
+	 * The name of the wp capability that should be associated with the usage of
777
+	 * this PMT by an admin
778
+	 *
779
+	 * @return string
780
+	 */
781
+	public function cap_name()
782
+	{
783
+		return 'ee_payment_method_' . strtolower($this->system_name());
784
+	}
785
+
786
+	/**
787
+	 * Called by client code to tell the gateway that if it wants to change
788
+	 * the transaction or line items or registrations related to teh payment it already
789
+	 * processed (we think, but possibly not) that now's the time to do it.
790
+	 * It is expected that gateways will store any info they need for this on the PAY_details,
791
+	 * or maybe an extra meta value
792
+	 *
793
+	 * @param EE_Payment $payment
794
+	 * @return void
795
+	 */
796
+	public function update_txn_based_on_payment($payment)
797
+	{
798
+		if ($this->_gateway instanceof EE_Gateway) {
799
+			$this->_gateway->update_txn_based_on_payment($payment);
800
+		}
801
+	}
802
+
803
+	/**
804
+	 * Returns a string of HTML describing this payment method type for an admin,
805
+	 * primarily intended for them to read before activating it.
806
+	 * The easiest way to set this is to create a folder 'templates' alongside
807
+	 * your EE_PMT_{System_Name} file, and in it create a file named "{system_name}_intro.template.php".
808
+	 * Eg, if your payment method file is named "EE_PMT_Foo_Bar.pm.php",
809
+	 * then you'd create a file named "templates" in the same folder as it, and name the file
810
+	 * "foo_bar_intro.template.php", and its content will be returned by this method
811
+	 *
812
+	 * @return string
813
+	 */
814
+	public function introductory_html()
815
+	{
816
+		return EEH_Template::locate_template(
817
+			$this->file_folder() . 'templates' . DS . strtolower($this->system_name()) . '_intro.template.php',
818
+			array('pmt_obj' => $this, 'pm_instance' => $this->_pm_instance)
819
+		);
820
+	}
821 821
 }
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
             $this->_gateway->set_unsupported_character_remover(new AsciiOnly());
118 118
             do_action('AHEE__EE_PMT_Base___construct__done_initializing_gateway_class', $this, $this->_gateway);
119 119
         }
120
-        if (! isset($this->_has_billing_form)) {
120
+        if ( ! isset($this->_has_billing_form)) {
121 121
             // by default, On Site gateways have a billing form
122 122
             if ($this->payment_occurs() == EE_PMT_Base::onsite) {
123 123
                 $this->set_has_billing_form(true);
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
             }
127 127
         }
128 128
 
129
-        if (! $this->_pretty_name) {
129
+        if ( ! $this->_pretty_name) {
130 130
             throw new EE_Error(
131 131
                 sprintf(
132 132
                     __(
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
         }
139 139
         // if the child didn't specify a default button, use the credit card one
140 140
         if ($this->_default_button_url === null) {
141
-            $this->_default_button_url = EE_PLUGIN_DIR_URL . 'payment_methods' . DS . 'pay-by-credit-card.png';
141
+            $this->_default_button_url = EE_PLUGIN_DIR_URL.'payment_methods'.DS.'pay-by-credit-card.png';
142 142
         }
143 143
     }
144 144
 
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
     {
160 160
         $reflector = new ReflectionClass(get_class($this));
161 161
         $fn = $reflector->getFileName();
162
-        $this->_file_folder = dirname($fn) . DS;
162
+        $this->_file_folder = dirname($fn).DS;
163 163
     }
164 164
 
165 165
 
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
      */
193 193
     public function file_folder()
194 194
     {
195
-        if (! $this->_file_folder) {
195
+        if ( ! $this->_file_folder) {
196 196
             $this->_set_file_folder();
197 197
         }
198 198
         return $this->_file_folder;
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
      */
205 205
     public function file_url()
206 206
     {
207
-        if (! $this->_file_url) {
207
+        if ( ! $this->_file_url) {
208 208
             $this->_set_file_url();
209 209
         }
210 210
         return $this->_file_url;
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
      */
239 239
     public function settings_form()
240 240
     {
241
-        if (! $this->_settings_form) {
241
+        if ( ! $this->_settings_form) {
242 242
             $this->_settings_form = $this->generate_new_settings_form();
243 243
             $this->_settings_form->set_payment_method_type($this);
244 244
             // if we have already assigned a model object to this pmt, make
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
     public function billing_form(EE_Transaction $transaction = null, $extra_args = array())
293 293
     {
294 294
         // has billing form already been regenerated ? or overwrite cache?
295
-        if (! $this->_billing_form instanceof EE_Billing_Info_Form || ! $this->_cache_billing_form) {
295
+        if ( ! $this->_billing_form instanceof EE_Billing_Info_Form || ! $this->_cache_billing_form) {
296 296
             $this->_billing_form = $this->generate_new_billing_form($transaction, $extra_args);
297 297
         }
298 298
         // if we know who the attendee is, and this is a billing form
@@ -394,7 +394,7 @@  discard block
 block discarded – undo
394 394
             $payment = EEM_Payment::instance()->get_one(array($duplicate_properties));
395 395
             // if we didn't already have a payment in progress for the same thing,
396 396
             // then we actually want to make a new payment
397
-            if (! $payment instanceof EE_Payment) {
397
+            if ( ! $payment instanceof EE_Payment) {
398 398
                 $payment = EE_Payment::new_instance(
399 399
                     array_merge(
400 400
                         $duplicate_properties,
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
     public function handle_ipn($req_data, $transaction)
496 496
     {
497 497
         $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction);
498
-        if (! $this->_gateway instanceof EE_Offsite_Gateway) {
498
+        if ( ! $this->_gateway instanceof EE_Offsite_Gateway) {
499 499
             throw new EE_Error(
500 500
                 sprintf(
501 501
                     __("Could not handle IPN because '%s' is not an offsite gateway", "event_espresso"),
@@ -518,7 +518,7 @@  discard block
 block discarded – undo
518 518
      */
519 519
     protected function _save_billing_info_to_attendee($billing_form, $transaction)
520 520
     {
521
-        if (! $transaction || ! $transaction instanceof EE_Transaction) {
521
+        if ( ! $transaction || ! $transaction instanceof EE_Transaction) {
522 522
             EE_Error::add_error(
523 523
                 __("Cannot save billing info because no transaction was specified", "event_espresso"),
524 524
                 __FILE__,
@@ -528,7 +528,7 @@  discard block
 block discarded – undo
528 528
             return false;
529 529
         }
530 530
         $primary_reg = $transaction->primary_registration();
531
-        if (! $primary_reg) {
531
+        if ( ! $primary_reg) {
532 532
             EE_Error::add_error(
533 533
                 __("Cannot save billing info because the transaction has no primary registration", "event_espresso"),
534 534
                 __FILE__,
@@ -538,7 +538,7 @@  discard block
 block discarded – undo
538 538
             return false;
539 539
         }
540 540
         $attendee = $primary_reg->attendee();
541
-        if (! $attendee) {
541
+        if ( ! $attendee) {
542 542
             EE_Error::add_error(
543 543
                 __(
544 544
                     "Cannot save billing info because the transaction's primary registration has no attendee!",
@@ -651,7 +651,7 @@  discard block
 block discarded – undo
651 651
      */
652 652
     public function payment_occurs()
653 653
     {
654
-        if (! $this->_gateway) {
654
+        if ( ! $this->_gateway) {
655 655
             return EE_PMT_Base::offline;
656 656
         } elseif ($this->_gateway instanceof EE_Onsite_Gateway) {
657 657
             return EE_PMT_Base::onsite;
@@ -682,7 +682,7 @@  discard block
 block discarded – undo
682 682
     public function payment_overview_content(EE_Payment $payment)
683 683
     {
684 684
         return EEH_Template::display_template(
685
-            EE_LIBRARIES . 'payment_methods' . DS . 'templates' . DS . 'payment_details_content.template.php',
685
+            EE_LIBRARIES.'payment_methods'.DS.'templates'.DS.'payment_details_content.template.php',
686 686
             array('payment_method' => $this->_pm_instance, 'payment' => $payment),
687 687
             true
688 688
         );
@@ -769,7 +769,7 @@  discard block
 block discarded – undo
769 769
      */
770 770
     public function get_help_tab_name()
771 771
     {
772
-        return 'ee_' . strtolower($this->system_name()) . '_help_tab';
772
+        return 'ee_'.strtolower($this->system_name()).'_help_tab';
773 773
     }
774 774
 
775 775
     /**
@@ -780,7 +780,7 @@  discard block
 block discarded – undo
780 780
      */
781 781
     public function cap_name()
782 782
     {
783
-        return 'ee_payment_method_' . strtolower($this->system_name());
783
+        return 'ee_payment_method_'.strtolower($this->system_name());
784 784
     }
785 785
 
786 786
     /**
@@ -814,7 +814,7 @@  discard block
 block discarded – undo
814 814
     public function introductory_html()
815 815
     {
816 816
         return EEH_Template::locate_template(
817
-            $this->file_folder() . 'templates' . DS . strtolower($this->system_name()) . '_intro.template.php',
817
+            $this->file_folder().'templates'.DS.strtolower($this->system_name()).'_intro.template.php',
818 818
             array('pmt_obj' => $this, 'pm_instance' => $this->_pm_instance)
819 819
         );
820 820
     }
Please login to merge, or discard this patch.
core/libraries/payment_methods/EE_Onsite_Gateway.lib.php 1 patch
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -15,36 +15,36 @@
 block discarded – undo
15 15
 abstract class EE_Onsite_Gateway extends EE_Gateway
16 16
 {
17 17
 
18
-    /**
19
-     * @return EE_Onsite_Gateway
20
-     */
21
-    public function __construct()
22
-    {
23
-        $this->_supports_sending_refunds = true;
24
-        parent::__construct();
25
-    }
18
+	/**
19
+	 * @return EE_Onsite_Gateway
20
+	 */
21
+	public function __construct()
22
+	{
23
+		$this->_supports_sending_refunds = true;
24
+		parent::__construct();
25
+	}
26 26
 
27
-    /**
28
-     * Asks the gateway to do whatever it does to process the payment. Onsite gateways will
29
-     * usually send a request directly to the payment provider and update the payment's status based on that;
30
-     * whereas offsite gateways will usually just update the payment with the URL and query parameters to use
31
-     * for sending the request via http_remote_request(). Saving the payment from within this method is unnecessary,
32
-     * as it is the responsibility of client code to save it.
33
-     *
34
-     * @param EEI_Payment $payment
35
-     * @param array       $billing_info {
36
-     * @type              $first_name   string
37
-     * @type              $last_name    string
38
-     * @type              $email        string
39
-     * @type              $address      string
40
-     * @type              $address2     string
41
-     * @type              $city         string
42
-     * @type              $state        string name of the state (NOT int)
43
-     * @type              $country      string 2-character ISO code see http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
44
-     * @type              $zip          string
45
-     * @type              $phone        string
46
-     *                                  } unless a child class specifies these array keys are NOT present
47
-     * @return EE_Payment updated
48
-     */
49
-    abstract public function do_direct_payment($payment, $billing_info = null);
27
+	/**
28
+	 * Asks the gateway to do whatever it does to process the payment. Onsite gateways will
29
+	 * usually send a request directly to the payment provider and update the payment's status based on that;
30
+	 * whereas offsite gateways will usually just update the payment with the URL and query parameters to use
31
+	 * for sending the request via http_remote_request(). Saving the payment from within this method is unnecessary,
32
+	 * as it is the responsibility of client code to save it.
33
+	 *
34
+	 * @param EEI_Payment $payment
35
+	 * @param array       $billing_info {
36
+	 * @type              $first_name   string
37
+	 * @type              $last_name    string
38
+	 * @type              $email        string
39
+	 * @type              $address      string
40
+	 * @type              $address2     string
41
+	 * @type              $city         string
42
+	 * @type              $state        string name of the state (NOT int)
43
+	 * @type              $country      string 2-character ISO code see http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
44
+	 * @type              $zip          string
45
+	 * @type              $phone        string
46
+	 *                                  } unless a child class specifies these array keys are NOT present
47
+	 * @return EE_Payment updated
48
+	 */
49
+	abstract public function do_direct_payment($payment, $billing_info = null);
50 50
 }
Please login to merge, or discard this patch.
libraries/payment_methods/templates/payment_details_content.template.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if (! defined('EVENT_ESPRESSO_VERSION')) {
3
-    exit('No direct script access allowed');
3
+	exit('No direct script access allowed');
4 4
 }
5 5
 /**
6 6
  * payment_details_content
@@ -10,5 +10,5 @@  discard block
 block discarded – undo
10 10
  */
11 11
 $gateway_response = $payment->gateway_response();
12 12
 if (! empty($gateway_response)) {
13
-    echo '<span class="error payment-problem">' . $gateway_response . '</span>';
13
+	echo '<span class="error payment-problem">' . $gateway_response . '</span>';
14 14
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (! defined('EVENT_ESPRESSO_VERSION')) {
2
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3 3
     exit('No direct script access allowed');
4 4
 }
5 5
 /**
@@ -9,6 +9,6 @@  discard block
 block discarded – undo
9 9
  * @var EE_Payment_Method $payment_method
10 10
  */
11 11
 $gateway_response = $payment->gateway_response();
12
-if (! empty($gateway_response)) {
13
-    echo '<span class="error payment-problem">' . $gateway_response . '</span>';
12
+if ( ! empty($gateway_response)) {
13
+    echo '<span class="error payment-problem">'.$gateway_response.'</span>';
14 14
 }
Please login to merge, or discard this patch.
EE_Admin_Table_Registration_Line_Item_Display_Strategy.strategy.php 2 patches
Indentation   +179 added lines, -179 removed lines patch added patch discarded remove patch
@@ -13,183 +13,183 @@
 block discarded – undo
13 13
 class EE_Admin_Table_Registration_Line_Item_Display_Strategy extends EE_Admin_Table_Line_Item_Display_Strategy
14 14
 {
15 15
 
16
-    /**
17
-     * Table header for display.
18
-     * @since   4.8
19
-     * @param array $options
20
-     * @return string
21
-     */
22
-    protected function _table_header($options)
23
-    {
24
-        $html = EEH_HTML::table('', '', $options['table_css_class']);
25
-        $html .= EEH_HTML::thead();
26
-        $html .= EEH_HTML::tr();
27
-        $html .= EEH_HTML::th(__('Name', 'event_espresso'), '', 'jst-left');
28
-        $html .= EEH_HTML::th(__('Type', 'event_espresso'), '', 'jst-left');
29
-        $html .= EEH_HTML::th(__('Date(s)', 'event_espresso'), '', 'jst-left');
30
-        $html .= EEH_HTML::th(__('Amount', 'event_espresso'), '', 'jst-cntr');
31
-        $html .= EEH_HTML::tbody();
32
-        return $html;
33
-    }
34
-
35
-
36
-
37
-
38
-
39
-    /**
40
-     *    _item_row
41
-     *
42
-     * @param EE_Line_Item $line_item
43
-     * @param array        $options
44
-     * @return mixed
45
-     */
46
-    protected function _item_row(EE_Line_Item $line_item, $options = array())
47
-    {
48
-        $line_item_related_object = $line_item->get_object();
49
-        $parent_line_item_related_object = $line_item->parent() instanceof EE_Line_Item
50
-            ? $line_item->parent()->get_object()
51
-            : null;
52
-        // start of row
53
-        $row_class = $options['odd'] ? 'item odd' : 'item';
54
-        $html = EEH_HTML::tr('', '', $row_class);
55
-
56
-
57
-        // Name Column
58
-        $name_link = $line_item_related_object instanceof EEI_Admin_Links ? $line_item_related_object->get_admin_details_link() : '';
59
-
60
-        // related object scope.
61
-        $parent_related_object_name = $parent_line_item_related_object instanceof EEI_Line_Item_Object
62
-            ? $parent_line_item_related_object->name()
63
-            : '';
64
-        $parent_related_object_name = empty($parent_related_object_name) && $line_item->parent() instanceof EE_Line_Item
65
-            ? $line_item->parent()->name()
66
-            : $parent_related_object_name;
67
-        $parent_related_object_link = $parent_line_item_related_object instanceof EEI_Admin_Links
68
-            ? $parent_line_item_related_object->get_admin_details_link()
69
-            : '';
70
-
71
-
72
-        $name_html = $line_item_related_object instanceof EEI_Line_Item_Object
73
-            ? $line_item_related_object->name() : $line_item->name();
74
-        $name_html = $name_link ? '<a href="' . $name_link . '">' . $name_html . '</a>'
75
-            : $name_html;
76
-        $name_html .= $line_item->is_taxable() ? ' *' : '';
77
-        // maybe preface with icon?
78
-        $name_html = $line_item_related_object instanceof EEI_Has_Icon
79
-            ? $line_item_related_object->get_icon() . $name_html
80
-            : $name_html;
81
-        $name_html = '<span class="ee-line-item-name linked">' . $name_html . '</span><br>';
82
-        $name_html .=  sprintf(
83
-            _x('%1$sfor the %2$s: %3$s%4$s', 'eg. "for the Event: My Cool Event"', 'event_espresso'),
84
-            '<span class="ee-line-item-related-parent-object">',
85
-            $line_item->parent() instanceof EE_Line_Item
86
-                ? $line_item->parent()->OBJ_type_i18n()
87
-                : __('Item:', 'event_espresso'),
88
-            $parent_related_object_link
89
-                ? '<a href="' . $parent_related_object_link . '">' . $parent_related_object_name . '</a>'
90
-                : $parent_related_object_name,
91
-            '</span>'
92
-        );
93
-        $html .= EEH_HTML::td($name_html, '', 'jst-left');
94
-        // Type Column
95
-        $type_html = $line_item->OBJ_type() ? $line_item->OBJ_type_i18n() : '';
96
-        $type_html .= $this->_get_cancellations($line_item);
97
-        $type_html .= $line_item->OBJ_type() ? '<br />' : '';
98
-        $code = $line_item_related_object instanceof EEI_Has_Code ? $line_item_related_object->code() : '';
99
-        $type_html .= ! empty($code) ? '<span class="ee-line-item-id">' . sprintf(__('Code: %s', 'event_espresso'), $code) . '</span>' : '';
100
-        $html .= EEH_HTML::td($type_html, '', 'jst-left');
101
-
102
-        // Date column
103
-        $datetime_content = '';
104
-        if ($line_item_related_object instanceof EE_Ticket) {
105
-            $datetimes = $line_item_related_object->datetimes();
106
-            foreach ($datetimes as $datetime) {
107
-                if ($datetime instanceof EE_Datetime) {
108
-                    $datetime_content .= $datetime->get_dtt_display_name() . '<br>';
109
-                }
110
-            }
111
-        }
112
-        $html .= EEH_HTML::td($datetime_content, '', 'jst-left');
113
-
114
-        // Amount Column
115
-        if ($line_item->is_percent()) {
116
-            $html .= EEH_HTML::td($line_item->percent() . '%', '', 'jst-rght');
117
-        } else {
118
-            $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'jst-rght');
119
-        }
120
-
121
-
122
-        // finish things off and return
123
-        $html .= EEH_HTML::trx();
124
-        return $html;
125
-    }
126
-
127
-
128
-
129
-    /**
130
-     *  _tax_row
131
-     *
132
-     * @param EE_Line_Item $line_item
133
-     * @param array        $options
134
-     * @return mixed
135
-     */
136
-    protected function _tax_row(EE_Line_Item $line_item, $options = array())
137
-    {
138
-        // start of row
139
-        $html = EEH_HTML::tr('', 'admin-primary-mbox-taxes-tr');
140
-        // name th
141
-        $html .= EEH_HTML::th($line_item->name() . '(' . $line_item->get_pretty('LIN_percent') . '%)', '', 'jst-rght', '', ' colspan="3"');
142
-        // total th
143
-        $html .= EEH_HTML::th(EEH_Template::format_currency($line_item->total(), false, false), '', 'jst-rght');
144
-        // end of row
145
-        $html .= EEH_HTML::trx();
146
-        return $html;
147
-    }
148
-
149
-
150
-
151
-
152
-
153
-    /**
154
-     *  _total_row
155
-     *
156
-     * @param EE_Line_Item $line_item
157
-     * @param array        $options
158
-     * @return mixed
159
-     */
160
-    protected function _total_row(EE_Line_Item $line_item, $options = array())
161
-    {
162
-
163
-        $registration = isset($options['EE_Registration']) ? $options['EE_Registration'] : null;
164
-        $registration_total = $registration instanceof EE_Registration ? $registration->pretty_final_price() : 0;
165
-        // if no valid registration object then we're not going to show the approximate text.
166
-        $total_match = $registration instanceof EE_Registration
167
-            ? $registration->final_price() === $line_item->total()
168
-            : true;
169
-
170
-        // start of row
171
-        $html = EEH_HTML::tr('', '', 'admin-primary-mbox-total-tr');
172
-        // Total th label
173
-        if ($total_match) {
174
-            $total_label = sprintf(__('This registration\'s total %s:', 'event_espresso'), '(' . EE_Registry::instance()->CFG->currency->code . ')');
175
-        } else {
176
-            $total_label = sprintf(__('This registration\'s approximate total %s', 'event_espresso'), '(' . EE_Registry::instance()->CFG->currency->code . ')');
177
-            $total_label .= '<br>';
178
-            $total_label .= '<p class="ee-footnote-text">'
179
-                            . sprintf(
180
-                                __('The registrations\' share of the transaction total is approximate because it might not be possible to evenly divide the transaction total among each registration, and so some registrations may need to pay a penny more than others.  This registration\'s final share is actually %1$s%2$s%3$s.', 'event_espresso'),
181
-                                '<strong>',
182
-                                $registration_total,
183
-                                '</strong>'
184
-                            )
185
-                            . '</p>';
186
-        }
187
-        $html .= EEH_HTML::th($total_label, '', 'jst-rght', '', ' colspan="3"');
188
-        // total th
189
-
190
-        $html .= EEH_HTML::th(EEH_Template::format_currency($line_item->total(), false, false), '', 'jst-rght');
191
-        // end of row
192
-        $html .= EEH_HTML::trx();
193
-        return $html;
194
-    }
16
+	/**
17
+	 * Table header for display.
18
+	 * @since   4.8
19
+	 * @param array $options
20
+	 * @return string
21
+	 */
22
+	protected function _table_header($options)
23
+	{
24
+		$html = EEH_HTML::table('', '', $options['table_css_class']);
25
+		$html .= EEH_HTML::thead();
26
+		$html .= EEH_HTML::tr();
27
+		$html .= EEH_HTML::th(__('Name', 'event_espresso'), '', 'jst-left');
28
+		$html .= EEH_HTML::th(__('Type', 'event_espresso'), '', 'jst-left');
29
+		$html .= EEH_HTML::th(__('Date(s)', 'event_espresso'), '', 'jst-left');
30
+		$html .= EEH_HTML::th(__('Amount', 'event_espresso'), '', 'jst-cntr');
31
+		$html .= EEH_HTML::tbody();
32
+		return $html;
33
+	}
34
+
35
+
36
+
37
+
38
+
39
+	/**
40
+	 *    _item_row
41
+	 *
42
+	 * @param EE_Line_Item $line_item
43
+	 * @param array        $options
44
+	 * @return mixed
45
+	 */
46
+	protected function _item_row(EE_Line_Item $line_item, $options = array())
47
+	{
48
+		$line_item_related_object = $line_item->get_object();
49
+		$parent_line_item_related_object = $line_item->parent() instanceof EE_Line_Item
50
+			? $line_item->parent()->get_object()
51
+			: null;
52
+		// start of row
53
+		$row_class = $options['odd'] ? 'item odd' : 'item';
54
+		$html = EEH_HTML::tr('', '', $row_class);
55
+
56
+
57
+		// Name Column
58
+		$name_link = $line_item_related_object instanceof EEI_Admin_Links ? $line_item_related_object->get_admin_details_link() : '';
59
+
60
+		// related object scope.
61
+		$parent_related_object_name = $parent_line_item_related_object instanceof EEI_Line_Item_Object
62
+			? $parent_line_item_related_object->name()
63
+			: '';
64
+		$parent_related_object_name = empty($parent_related_object_name) && $line_item->parent() instanceof EE_Line_Item
65
+			? $line_item->parent()->name()
66
+			: $parent_related_object_name;
67
+		$parent_related_object_link = $parent_line_item_related_object instanceof EEI_Admin_Links
68
+			? $parent_line_item_related_object->get_admin_details_link()
69
+			: '';
70
+
71
+
72
+		$name_html = $line_item_related_object instanceof EEI_Line_Item_Object
73
+			? $line_item_related_object->name() : $line_item->name();
74
+		$name_html = $name_link ? '<a href="' . $name_link . '">' . $name_html . '</a>'
75
+			: $name_html;
76
+		$name_html .= $line_item->is_taxable() ? ' *' : '';
77
+		// maybe preface with icon?
78
+		$name_html = $line_item_related_object instanceof EEI_Has_Icon
79
+			? $line_item_related_object->get_icon() . $name_html
80
+			: $name_html;
81
+		$name_html = '<span class="ee-line-item-name linked">' . $name_html . '</span><br>';
82
+		$name_html .=  sprintf(
83
+			_x('%1$sfor the %2$s: %3$s%4$s', 'eg. "for the Event: My Cool Event"', 'event_espresso'),
84
+			'<span class="ee-line-item-related-parent-object">',
85
+			$line_item->parent() instanceof EE_Line_Item
86
+				? $line_item->parent()->OBJ_type_i18n()
87
+				: __('Item:', 'event_espresso'),
88
+			$parent_related_object_link
89
+				? '<a href="' . $parent_related_object_link . '">' . $parent_related_object_name . '</a>'
90
+				: $parent_related_object_name,
91
+			'</span>'
92
+		);
93
+		$html .= EEH_HTML::td($name_html, '', 'jst-left');
94
+		// Type Column
95
+		$type_html = $line_item->OBJ_type() ? $line_item->OBJ_type_i18n() : '';
96
+		$type_html .= $this->_get_cancellations($line_item);
97
+		$type_html .= $line_item->OBJ_type() ? '<br />' : '';
98
+		$code = $line_item_related_object instanceof EEI_Has_Code ? $line_item_related_object->code() : '';
99
+		$type_html .= ! empty($code) ? '<span class="ee-line-item-id">' . sprintf(__('Code: %s', 'event_espresso'), $code) . '</span>' : '';
100
+		$html .= EEH_HTML::td($type_html, '', 'jst-left');
101
+
102
+		// Date column
103
+		$datetime_content = '';
104
+		if ($line_item_related_object instanceof EE_Ticket) {
105
+			$datetimes = $line_item_related_object->datetimes();
106
+			foreach ($datetimes as $datetime) {
107
+				if ($datetime instanceof EE_Datetime) {
108
+					$datetime_content .= $datetime->get_dtt_display_name() . '<br>';
109
+				}
110
+			}
111
+		}
112
+		$html .= EEH_HTML::td($datetime_content, '', 'jst-left');
113
+
114
+		// Amount Column
115
+		if ($line_item->is_percent()) {
116
+			$html .= EEH_HTML::td($line_item->percent() . '%', '', 'jst-rght');
117
+		} else {
118
+			$html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'jst-rght');
119
+		}
120
+
121
+
122
+		// finish things off and return
123
+		$html .= EEH_HTML::trx();
124
+		return $html;
125
+	}
126
+
127
+
128
+
129
+	/**
130
+	 *  _tax_row
131
+	 *
132
+	 * @param EE_Line_Item $line_item
133
+	 * @param array        $options
134
+	 * @return mixed
135
+	 */
136
+	protected function _tax_row(EE_Line_Item $line_item, $options = array())
137
+	{
138
+		// start of row
139
+		$html = EEH_HTML::tr('', 'admin-primary-mbox-taxes-tr');
140
+		// name th
141
+		$html .= EEH_HTML::th($line_item->name() . '(' . $line_item->get_pretty('LIN_percent') . '%)', '', 'jst-rght', '', ' colspan="3"');
142
+		// total th
143
+		$html .= EEH_HTML::th(EEH_Template::format_currency($line_item->total(), false, false), '', 'jst-rght');
144
+		// end of row
145
+		$html .= EEH_HTML::trx();
146
+		return $html;
147
+	}
148
+
149
+
150
+
151
+
152
+
153
+	/**
154
+	 *  _total_row
155
+	 *
156
+	 * @param EE_Line_Item $line_item
157
+	 * @param array        $options
158
+	 * @return mixed
159
+	 */
160
+	protected function _total_row(EE_Line_Item $line_item, $options = array())
161
+	{
162
+
163
+		$registration = isset($options['EE_Registration']) ? $options['EE_Registration'] : null;
164
+		$registration_total = $registration instanceof EE_Registration ? $registration->pretty_final_price() : 0;
165
+		// if no valid registration object then we're not going to show the approximate text.
166
+		$total_match = $registration instanceof EE_Registration
167
+			? $registration->final_price() === $line_item->total()
168
+			: true;
169
+
170
+		// start of row
171
+		$html = EEH_HTML::tr('', '', 'admin-primary-mbox-total-tr');
172
+		// Total th label
173
+		if ($total_match) {
174
+			$total_label = sprintf(__('This registration\'s total %s:', 'event_espresso'), '(' . EE_Registry::instance()->CFG->currency->code . ')');
175
+		} else {
176
+			$total_label = sprintf(__('This registration\'s approximate total %s', 'event_espresso'), '(' . EE_Registry::instance()->CFG->currency->code . ')');
177
+			$total_label .= '<br>';
178
+			$total_label .= '<p class="ee-footnote-text">'
179
+							. sprintf(
180
+								__('The registrations\' share of the transaction total is approximate because it might not be possible to evenly divide the transaction total among each registration, and so some registrations may need to pay a penny more than others.  This registration\'s final share is actually %1$s%2$s%3$s.', 'event_espresso'),
181
+								'<strong>',
182
+								$registration_total,
183
+								'</strong>'
184
+							)
185
+							. '</p>';
186
+		}
187
+		$html .= EEH_HTML::th($total_label, '', 'jst-rght', '', ' colspan="3"');
188
+		// total th
189
+
190
+		$html .= EEH_HTML::th(EEH_Template::format_currency($line_item->total(), false, false), '', 'jst-rght');
191
+		// end of row
192
+		$html .= EEH_HTML::trx();
193
+		return $html;
194
+	}
195 195
 }
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -71,22 +71,22 @@  discard block
 block discarded – undo
71 71
 
72 72
         $name_html = $line_item_related_object instanceof EEI_Line_Item_Object
73 73
             ? $line_item_related_object->name() : $line_item->name();
74
-        $name_html = $name_link ? '<a href="' . $name_link . '">' . $name_html . '</a>'
74
+        $name_html = $name_link ? '<a href="'.$name_link.'">'.$name_html.'</a>'
75 75
             : $name_html;
76 76
         $name_html .= $line_item->is_taxable() ? ' *' : '';
77 77
         // maybe preface with icon?
78 78
         $name_html = $line_item_related_object instanceof EEI_Has_Icon
79
-            ? $line_item_related_object->get_icon() . $name_html
79
+            ? $line_item_related_object->get_icon().$name_html
80 80
             : $name_html;
81
-        $name_html = '<span class="ee-line-item-name linked">' . $name_html . '</span><br>';
82
-        $name_html .=  sprintf(
81
+        $name_html = '<span class="ee-line-item-name linked">'.$name_html.'</span><br>';
82
+        $name_html .= sprintf(
83 83
             _x('%1$sfor the %2$s: %3$s%4$s', 'eg. "for the Event: My Cool Event"', 'event_espresso'),
84 84
             '<span class="ee-line-item-related-parent-object">',
85 85
             $line_item->parent() instanceof EE_Line_Item
86 86
                 ? $line_item->parent()->OBJ_type_i18n()
87 87
                 : __('Item:', 'event_espresso'),
88 88
             $parent_related_object_link
89
-                ? '<a href="' . $parent_related_object_link . '">' . $parent_related_object_name . '</a>'
89
+                ? '<a href="'.$parent_related_object_link.'">'.$parent_related_object_name.'</a>'
90 90
                 : $parent_related_object_name,
91 91
             '</span>'
92 92
         );
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
         $type_html .= $this->_get_cancellations($line_item);
97 97
         $type_html .= $line_item->OBJ_type() ? '<br />' : '';
98 98
         $code = $line_item_related_object instanceof EEI_Has_Code ? $line_item_related_object->code() : '';
99
-        $type_html .= ! empty($code) ? '<span class="ee-line-item-id">' . sprintf(__('Code: %s', 'event_espresso'), $code) . '</span>' : '';
99
+        $type_html .= ! empty($code) ? '<span class="ee-line-item-id">'.sprintf(__('Code: %s', 'event_espresso'), $code).'</span>' : '';
100 100
         $html .= EEH_HTML::td($type_html, '', 'jst-left');
101 101
 
102 102
         // Date column
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
             $datetimes = $line_item_related_object->datetimes();
106 106
             foreach ($datetimes as $datetime) {
107 107
                 if ($datetime instanceof EE_Datetime) {
108
-                    $datetime_content .= $datetime->get_dtt_display_name() . '<br>';
108
+                    $datetime_content .= $datetime->get_dtt_display_name().'<br>';
109 109
                 }
110 110
             }
111 111
         }
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 
114 114
         // Amount Column
115 115
         if ($line_item->is_percent()) {
116
-            $html .= EEH_HTML::td($line_item->percent() . '%', '', 'jst-rght');
116
+            $html .= EEH_HTML::td($line_item->percent().'%', '', 'jst-rght');
117 117
         } else {
118 118
             $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'jst-rght');
119 119
         }
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
         // start of row
139 139
         $html = EEH_HTML::tr('', 'admin-primary-mbox-taxes-tr');
140 140
         // name th
141
-        $html .= EEH_HTML::th($line_item->name() . '(' . $line_item->get_pretty('LIN_percent') . '%)', '', 'jst-rght', '', ' colspan="3"');
141
+        $html .= EEH_HTML::th($line_item->name().'('.$line_item->get_pretty('LIN_percent').'%)', '', 'jst-rght', '', ' colspan="3"');
142 142
         // total th
143 143
         $html .= EEH_HTML::th(EEH_Template::format_currency($line_item->total(), false, false), '', 'jst-rght');
144 144
         // end of row
@@ -171,9 +171,9 @@  discard block
 block discarded – undo
171 171
         $html = EEH_HTML::tr('', '', 'admin-primary-mbox-total-tr');
172 172
         // Total th label
173 173
         if ($total_match) {
174
-            $total_label = sprintf(__('This registration\'s total %s:', 'event_espresso'), '(' . EE_Registry::instance()->CFG->currency->code . ')');
174
+            $total_label = sprintf(__('This registration\'s total %s:', 'event_espresso'), '('.EE_Registry::instance()->CFG->currency->code.')');
175 175
         } else {
176
-            $total_label = sprintf(__('This registration\'s approximate total %s', 'event_espresso'), '(' . EE_Registry::instance()->CFG->currency->code . ')');
176
+            $total_label = sprintf(__('This registration\'s approximate total %s', 'event_espresso'), '('.EE_Registry::instance()->CFG->currency->code.')');
177 177
             $total_label .= '<br>';
178 178
             $total_label .= '<p class="ee-footnote-text">'
179 179
                             . sprintf(
Please login to merge, or discard this patch.
core/libraries/batch/JobHandlerBaseClasses/JobHandlerInterface.php 1 patch
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -22,30 +22,30 @@
 block discarded – undo
22 22
 
23 23
 interface JobHandlerInterface
24 24
 {
25
-    /**
26
-     * Performs any necessary setup for starting the job. This is also a good
27
-     * place to setup the $job_arguments which will be used for subsequent HTTP requests
28
-     * when continue_job will be called
29
-     * @param JobParameters $job_parameters
30
-     * @throws BatchRequestException
31
-     * @return JobStepResponse
32
-     */
33
-    public function create_job(JobParameters $job_parameters);
25
+	/**
26
+	 * Performs any necessary setup for starting the job. This is also a good
27
+	 * place to setup the $job_arguments which will be used for subsequent HTTP requests
28
+	 * when continue_job will be called
29
+	 * @param JobParameters $job_parameters
30
+	 * @throws BatchRequestException
31
+	 * @return JobStepResponse
32
+	 */
33
+	public function create_job(JobParameters $job_parameters);
34 34
 
35
-    /**
36
-     * Performs another step of the job
37
-     * @param JobParameters $job_parameters
38
-     * @param int $batch_size
39
-     * @return JobStepResponse
40
-     * @throws BatchRequestException
41
-     */
42
-    public function continue_job(JobParameters $job_parameters, $batch_size = 50);
35
+	/**
36
+	 * Performs another step of the job
37
+	 * @param JobParameters $job_parameters
38
+	 * @param int $batch_size
39
+	 * @return JobStepResponse
40
+	 * @throws BatchRequestException
41
+	 */
42
+	public function continue_job(JobParameters $job_parameters, $batch_size = 50);
43 43
 
44
-    /**
45
-     * Performs any clean-up logic when we know the job is completed
46
-     * @param JobParameters $job_parameters
47
-     * @return JobStepResponse
48
-     * @throws BatchRequestException
49
-     */
50
-    public function cleanup_job(JobParameters $job_parameters);
44
+	/**
45
+	 * Performs any clean-up logic when we know the job is completed
46
+	 * @param JobParameters $job_parameters
47
+	 * @return JobStepResponse
48
+	 * @throws BatchRequestException
49
+	 */
50
+	public function cleanup_job(JobParameters $job_parameters);
51 51
 }
Please login to merge, or discard this patch.
core/request_stack/EE_Response.core.php 2 patches
Indentation   +142 added lines, -142 removed lines patch added patch discarded remove patch
@@ -13,146 +13,146 @@
 block discarded – undo
13 13
 class EE_Response
14 14
 {
15 15
 
16
-    /**
17
-     * @access    protected
18
-     * @type        array $_notice
19
-     */
20
-    protected $_notice = array();
21
-
22
-    /**
23
-     *    rendered output to be returned to WP
24
-     *
25
-     * @access    protected
26
-     * @type        string
27
-     */
28
-    protected $_output = '';
29
-
30
-    /**
31
-     * @access    protected
32
-     * @type        bool
33
-     */
34
-    protected $request_terminated = false;
35
-
36
-    /**
37
-     * @access    protected
38
-     * @type        bool
39
-     */
40
-    protected $deactivate_plugin = false;
41
-
42
-
43
-    /**
44
-     * @deprecated  4.9.53
45
-     * @return \EE_Response
46
-     */
47
-    public function __construct()
48
-    {
49
-        $this->terminate_request(false);
50
-        EE_Error::doing_it_wrong(
51
-            __METHOD__,
52
-            sprintf(
53
-                esc_html__(
54
-                    'This class is deprecated. Please use %1$s instead. All Event Espresso request stack classes have been moved to %2$s and are now under the %3$s namespace',
55
-                    'event_espresso'
56
-                ),
57
-                'EventEspresso\core\services\request\Response',
58
-                '\core\services\request',
59
-                'EventEspresso\core\services\request'
60
-            ),
61
-            '4.9.53'
62
-        );
63
-    }
64
-
65
-
66
-    /**
67
-     * @deprecated  4.9.53
68
-     * @param $key
69
-     * @param $value
70
-     * @return    void
71
-     */
72
-    public function set_notice($key, $value)
73
-    {
74
-        $this->_notice[ $key ] = $value;
75
-    }
76
-
77
-
78
-    /**
79
-     * @deprecated  4.9.53
80
-     * @param $key
81
-     * @return    mixed
82
-     */
83
-    public function get_notice($key)
84
-    {
85
-        return isset($this->_notice[ $key ]) ? $this->_notice[ $key ] : null;
86
-    }
87
-
88
-
89
-    /**
90
-     * @deprecated  4.9.53
91
-     * @return    array
92
-     */
93
-    public function get_notices()
94
-    {
95
-        return $this->_notice;
96
-    }
97
-
98
-
99
-    /**
100
-     * @deprecated  4.9.53
101
-     * @param      $string
102
-     * @param bool $append
103
-     */
104
-    public function add_output($string, $append = true)
105
-    {
106
-        $this->_output = $append ? $this->_output . $string : $string . $this->_output;
107
-    }
108
-
109
-
110
-    /**
111
-     * @deprecated  4.9.53
112
-     * @return    string
113
-     */
114
-    public function get_output()
115
-    {
116
-        return $this->_output;
117
-    }
118
-
119
-
120
-    /**
121
-     * @deprecated  4.9.53
122
-     * @return boolean
123
-     */
124
-    public function request_terminated()
125
-    {
126
-        return $this->request_terminated;
127
-    }
128
-
129
-
130
-    /**
131
-     * @deprecated  4.9.53
132
-     * @param boolean $request_terminated
133
-     */
134
-    public function terminate_request($request_terminated = true)
135
-    {
136
-        $this->request_terminated = filter_var($request_terminated, FILTER_VALIDATE_BOOLEAN);
137
-    }
138
-
139
-
140
-    /**
141
-     * @deprecated  4.9.53
142
-     * @return boolean
143
-     */
144
-    public function plugin_deactivated()
145
-    {
146
-        return $this->deactivate_plugin;
147
-    }
148
-
149
-
150
-    /**
151
-     * @deprecated  4.9.53
152
-     * sets $deactivate_plugin to true
153
-     */
154
-    public function deactivate_plugin()
155
-    {
156
-        $this->deactivate_plugin = true;
157
-    }
16
+	/**
17
+	 * @access    protected
18
+	 * @type        array $_notice
19
+	 */
20
+	protected $_notice = array();
21
+
22
+	/**
23
+	 *    rendered output to be returned to WP
24
+	 *
25
+	 * @access    protected
26
+	 * @type        string
27
+	 */
28
+	protected $_output = '';
29
+
30
+	/**
31
+	 * @access    protected
32
+	 * @type        bool
33
+	 */
34
+	protected $request_terminated = false;
35
+
36
+	/**
37
+	 * @access    protected
38
+	 * @type        bool
39
+	 */
40
+	protected $deactivate_plugin = false;
41
+
42
+
43
+	/**
44
+	 * @deprecated  4.9.53
45
+	 * @return \EE_Response
46
+	 */
47
+	public function __construct()
48
+	{
49
+		$this->terminate_request(false);
50
+		EE_Error::doing_it_wrong(
51
+			__METHOD__,
52
+			sprintf(
53
+				esc_html__(
54
+					'This class is deprecated. Please use %1$s instead. All Event Espresso request stack classes have been moved to %2$s and are now under the %3$s namespace',
55
+					'event_espresso'
56
+				),
57
+				'EventEspresso\core\services\request\Response',
58
+				'\core\services\request',
59
+				'EventEspresso\core\services\request'
60
+			),
61
+			'4.9.53'
62
+		);
63
+	}
64
+
65
+
66
+	/**
67
+	 * @deprecated  4.9.53
68
+	 * @param $key
69
+	 * @param $value
70
+	 * @return    void
71
+	 */
72
+	public function set_notice($key, $value)
73
+	{
74
+		$this->_notice[ $key ] = $value;
75
+	}
76
+
77
+
78
+	/**
79
+	 * @deprecated  4.9.53
80
+	 * @param $key
81
+	 * @return    mixed
82
+	 */
83
+	public function get_notice($key)
84
+	{
85
+		return isset($this->_notice[ $key ]) ? $this->_notice[ $key ] : null;
86
+	}
87
+
88
+
89
+	/**
90
+	 * @deprecated  4.9.53
91
+	 * @return    array
92
+	 */
93
+	public function get_notices()
94
+	{
95
+		return $this->_notice;
96
+	}
97
+
98
+
99
+	/**
100
+	 * @deprecated  4.9.53
101
+	 * @param      $string
102
+	 * @param bool $append
103
+	 */
104
+	public function add_output($string, $append = true)
105
+	{
106
+		$this->_output = $append ? $this->_output . $string : $string . $this->_output;
107
+	}
108
+
109
+
110
+	/**
111
+	 * @deprecated  4.9.53
112
+	 * @return    string
113
+	 */
114
+	public function get_output()
115
+	{
116
+		return $this->_output;
117
+	}
118
+
119
+
120
+	/**
121
+	 * @deprecated  4.9.53
122
+	 * @return boolean
123
+	 */
124
+	public function request_terminated()
125
+	{
126
+		return $this->request_terminated;
127
+	}
128
+
129
+
130
+	/**
131
+	 * @deprecated  4.9.53
132
+	 * @param boolean $request_terminated
133
+	 */
134
+	public function terminate_request($request_terminated = true)
135
+	{
136
+		$this->request_terminated = filter_var($request_terminated, FILTER_VALIDATE_BOOLEAN);
137
+	}
138
+
139
+
140
+	/**
141
+	 * @deprecated  4.9.53
142
+	 * @return boolean
143
+	 */
144
+	public function plugin_deactivated()
145
+	{
146
+		return $this->deactivate_plugin;
147
+	}
148
+
149
+
150
+	/**
151
+	 * @deprecated  4.9.53
152
+	 * sets $deactivate_plugin to true
153
+	 */
154
+	public function deactivate_plugin()
155
+	{
156
+		$this->deactivate_plugin = true;
157
+	}
158 158
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
      */
72 72
     public function set_notice($key, $value)
73 73
     {
74
-        $this->_notice[ $key ] = $value;
74
+        $this->_notice[$key] = $value;
75 75
     }
76 76
 
77 77
 
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
      */
83 83
     public function get_notice($key)
84 84
     {
85
-        return isset($this->_notice[ $key ]) ? $this->_notice[ $key ] : null;
85
+        return isset($this->_notice[$key]) ? $this->_notice[$key] : null;
86 86
     }
87 87
 
88 88
 
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
      */
104 104
     public function add_output($string, $append = true)
105 105
     {
106
-        $this->_output = $append ? $this->_output . $string : $string . $this->_output;
106
+        $this->_output = $append ? $this->_output.$string : $string.$this->_output;
107 107
     }
108 108
 
109 109
 
Please login to merge, or discard this patch.
core/request_stack/EE_Request_Stack_Builder.core.php 1 patch
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -13,46 +13,46 @@
 block discarded – undo
13 13
 class EE_Request_Stack_Builder
14 14
 {
15 15
 
16
-    /**
17
-     * EE_Request_Stack_Builder
18
-     */
19
-    public function __construct()
20
-    {
21
-        EE_Error::doing_it_wrong(
22
-            __METHOD__,
23
-            sprintf(
24
-                esc_html__(
25
-                    'This class is deprecated. Please use %1$s instead. All Event Espresso request stack classes have been moved to %2$s and are now under the %3$s namespace',
26
-                    'event_espresso'
27
-                ),
28
-                'EventEspresso\core\services\request\RequestStackBuilder',
29
-                '\core\services\request',
30
-                'EventEspresso\core\services\request'
31
-            ),
32
-            '4.9.53'
33
-        );
34
-    }
16
+	/**
17
+	 * EE_Request_Stack_Builder
18
+	 */
19
+	public function __construct()
20
+	{
21
+		EE_Error::doing_it_wrong(
22
+			__METHOD__,
23
+			sprintf(
24
+				esc_html__(
25
+					'This class is deprecated. Please use %1$s instead. All Event Espresso request stack classes have been moved to %2$s and are now under the %3$s namespace',
26
+					'event_espresso'
27
+				),
28
+				'EventEspresso\core\services\request\RequestStackBuilder',
29
+				'\core\services\request',
30
+				'EventEspresso\core\services\request'
31
+			),
32
+			'4.9.53'
33
+		);
34
+	}
35 35
 
36
-    /**
37
-     * @deprecated  4.9.53
38
-     */
39
-    public function unshift()
40
-    {
41
-    }
36
+	/**
37
+	 * @deprecated  4.9.53
38
+	 */
39
+	public function unshift()
40
+	{
41
+	}
42 42
 
43 43
 
44
-    /**
45
-     * @deprecated  4.9.53
46
-     */
47
-    public function push()
48
-    {
49
-    }
44
+	/**
45
+	 * @deprecated  4.9.53
46
+	 */
47
+	public function push()
48
+	{
49
+	}
50 50
 
51 51
 
52
-    /**
53
-     * @deprecated  4.9.53
54
-     */
55
-    public function resolve(EEI_Request_Decorator $application)
56
-    {
57
-    }
52
+	/**
53
+	 * @deprecated  4.9.53
54
+	 */
55
+	public function resolve(EEI_Request_Decorator $application)
56
+	{
57
+	}
58 58
 }
Please login to merge, or discard this patch.
core/request_stack/EE_Request_Stack.core.php 1 patch
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -13,25 +13,25 @@
 block discarded – undo
13 13
 {
14 14
 
15 15
 
16
-    /**
17
-     * @deprecated  4.9.53
18
-     * @param    EEI_Request_Decorator $application
19
-     * @param    array                 $middlewares
20
-     */
21
-    public function __construct(EEI_Request_Decorator $application, $middlewares = array())
22
-    {
23
-        EE_Error::doing_it_wrong(
24
-            __METHOD__,
25
-            sprintf(
26
-                esc_html__(
27
-                    'This class is deprecated. Please use %1$s instead. All Event Espresso request stack classes have been moved to %2$s and are now under the %3$s namespace',
28
-                    'event_espresso'
29
-                ),
30
-                'EventEspresso\core\services\request\RequestStack',
31
-                '\core\services\request',
32
-                'EventEspresso\core\services\request'
33
-            ),
34
-            '4.9.53'
35
-        );
36
-    }
16
+	/**
17
+	 * @deprecated  4.9.53
18
+	 * @param    EEI_Request_Decorator $application
19
+	 * @param    array                 $middlewares
20
+	 */
21
+	public function __construct(EEI_Request_Decorator $application, $middlewares = array())
22
+	{
23
+		EE_Error::doing_it_wrong(
24
+			__METHOD__,
25
+			sprintf(
26
+				esc_html__(
27
+					'This class is deprecated. Please use %1$s instead. All Event Espresso request stack classes have been moved to %2$s and are now under the %3$s namespace',
28
+					'event_espresso'
29
+				),
30
+				'EventEspresso\core\services\request\RequestStack',
31
+				'\core\services\request',
32
+				'EventEspresso\core\services\request'
33
+			),
34
+			'4.9.53'
35
+		);
36
+	}
37 37
 }
Please login to merge, or discard this patch.