Completed
Branch FET/allow-prices-to-be-more-pr... (276f1f)
by
unknown
17:02 queued 13:56
created
form_sections/strategies/display/EE_Display_Strategy_Base.strategy.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
      */
57 57
     protected function _append_chars($string = '', $chars = '-')
58 58
     {
59
-        return $this->_remove_chars($string, $chars) . $chars;
59
+        return $this->_remove_chars($string, $chars).$chars;
60 60
     }
61 61
 
62 62
 
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
         );
187 187
         $filtered_attributes = array_filter(
188 188
             $attributes,
189
-            function ($value, $attribute) {
189
+            function($value, $attribute) {
190 190
                 // always add 'value' attribute or arrays of attributes
191 191
                 if ($attribute === 'value' || is_array($value)) {
192 192
                     return true;
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
                 $processed_attributes[] = trim($attribute_string);
217 217
             }
218 218
         }
219
-        return ! empty($processed_attributes) ? ' ' . implode(' ', $processed_attributes) : '';
219
+        return ! empty($processed_attributes) ? ' '.implode(' ', $processed_attributes) : '';
220 220
     }
221 221
 
222 222
 
Please login to merge, or discard this patch.
Indentation   +278 added lines, -278 removed lines patch added patch discarded remove patch
@@ -10,283 +10,283 @@
 block discarded – undo
10 10
  */
11 11
 abstract class EE_Display_Strategy_Base extends EE_Form_Input_Strategy_Base
12 12
 {
13
-    /**
14
-     * @var string $_tag
15
-     */
16
-    protected $_tag = '';
17
-
18
-
19
-
20
-
21
-
22
-    /**
23
-     * returns HTML and javascript related to the displaying of this input
24
-     *
25
-     * @return string
26
-     */
27
-    abstract public function display();
28
-
29
-
30
-
31
-    /**
32
-     * _remove_chars - takes an incoming string, and removes the string $chars from the end of it, but only if $chars
33
-     * is already there
34
-     *
35
-     * @param string $string - the string being processed
36
-     * @param string $chars  - exact string of characters to remove
37
-     * @return string
38
-     */
39
-    protected function _remove_chars($string = '', $chars = '-')
40
-    {
41
-        $char_length = strlen($chars) * -1;
42
-        // if last three characters of string is  " - ", then remove it
43
-        return substr($string, $char_length) === $chars ? substr($string, 0, $char_length) : $string;
44
-    }
45
-
46
-
13
+	/**
14
+	 * @var string $_tag
15
+	 */
16
+	protected $_tag = '';
17
+
18
+
19
+
20
+
21
+
22
+	/**
23
+	 * returns HTML and javascript related to the displaying of this input
24
+	 *
25
+	 * @return string
26
+	 */
27
+	abstract public function display();
28
+
29
+
30
+
31
+	/**
32
+	 * _remove_chars - takes an incoming string, and removes the string $chars from the end of it, but only if $chars
33
+	 * is already there
34
+	 *
35
+	 * @param string $string - the string being processed
36
+	 * @param string $chars  - exact string of characters to remove
37
+	 * @return string
38
+	 */
39
+	protected function _remove_chars($string = '', $chars = '-')
40
+	{
41
+		$char_length = strlen($chars) * -1;
42
+		// if last three characters of string is  " - ", then remove it
43
+		return substr($string, $char_length) === $chars ? substr($string, 0, $char_length) : $string;
44
+	}
45
+
46
+
47 47
 
48
-    /**
49
-     * _append_chars - takes an incoming string, and adds the string $chars to the end of it, but only if $chars is not
50
-     * already there
51
-     *
52
-     * @param string $string - the string being processed
53
-     * @param string $chars  - exact string of characters to be added to end of string
54
-     * @return string
55
-     */
56
-    protected function _append_chars($string = '', $chars = '-')
57
-    {
58
-        return $this->_remove_chars($string, $chars) . $chars;
59
-    }
60
-
61
-
62
-
63
-    /**
64
-     * Gets the HTML IDs of all the inputs
65
-     *
66
-     * @param bool $add_pound_sign
67
-     * @return array
68
-     */
69
-    public function get_html_input_ids($add_pound_sign = false)
70
-    {
71
-        return array($this->get_input()->html_id($add_pound_sign));
72
-    }
73
-
74
-
75
-
76
-    /**
77
-     * Adds js variables for localization to the $other_js_data. These should be put
78
-     * in each form's "other_data" javascript object.
79
-     *
80
-     * @param array $other_js_data
81
-     * @return array
82
-     */
83
-    public function get_other_js_data($other_js_data = array())
84
-    {
85
-        return $other_js_data;
86
-    }
87
-
88
-
89
-
90
-    /**
91
-     * Opportunity for this display strategy to call wp_enqueue_script and wp_enqueue_style.
92
-     * This should be called during wp_enqueue_scripts
93
-     */
94
-    public function enqueue_js()
95
-    {
96
-    }
97
-
98
-
99
-
100
-    /**
101
-     * returns string like: '<tag'
102
-     *
103
-     * @param string $tag
104
-     * @return string
105
-     */
106
-    protected function _opening_tag($tag)
107
-    {
108
-        $this->_tag = $tag;
109
-        return "<{$this->_tag}";
110
-    }
111
-
112
-
113
-    /**
114
-     * returns '>'
115
-     *
116
-     * @return string
117
-     */
118
-    protected function _end_opening_tag()
119
-    {
120
-        return '>';
121
-    }
122
-
123
-
124
-
125
-    /**
126
-     * returns string like: '</tag>
127
-     *
128
-     * @return string
129
-     */
130
-    protected function _closing_tag()
131
-    {
132
-        return "</{$this->_tag}>";
133
-    }
134
-
135
-
136
-
137
-    /**
138
-     * returns string like: '/>'
139
-     *
140
-     * @return string
141
-     */
142
-    protected function _close_tag()
143
-    {
144
-        return '/>';
145
-    }
146
-
147
-
148
-    /**
149
-     * returns an array of standard HTML attributes that get added to nearly all inputs,
150
-     * where string keys represent named attributes like id, class, etc
151
-     * and numeric keys represent single attributes like 'required'.
152
-     * Note: this does not include "value" because many inputs (like dropdowns, textareas, and checkboxes) don't use
153
-     * it.
154
-     *
155
-     * @return array
156
-     * @throws EE_Error
157
-     */
158
-    protected function _standard_attributes_array()
159
-    {
160
-        return [
161
-            'name'  => $this->_input->html_name(),
162
-            'id'    => $this->_input->html_id(),
163
-            'class' => $this->_input->html_class(true),
164
-            0       => ['required', $this->_input->required()],
165
-            1       => $this->_input->other_html_attributes(),
166
-            'style' => $this->_input->html_style(),
167
-        ];
168
-    }
169
-
170
-
171
-    /**
172
-     * sets the attributes using the incoming array
173
-     * and returns a string of all attributes rendered as valid HTML
174
-     *
175
-     * @param array $attributes
176
-     * @return string
177
-     */
178
-    protected function _attributes_string($attributes = array())
179
-    {
180
-        $attributes = apply_filters(
181
-            'FHEE__EE_Display_Strategy_Base__attributes_string__attributes',
182
-            $attributes,
183
-            $this,
184
-            $this->_input
185
-        );
186
-        $filtered_attributes = array_filter(
187
-            $attributes,
188
-            function ($value, $attribute) {
189
-                // always add 'value' attribute or arrays of attributes
190
-                if ($attribute === 'value' || is_array($value)) {
191
-                    return true;
192
-                }
193
-                // otherwise only add those with a value (ie: attribute has been set)
194
-                return ! empty($value);
195
-            },
196
-            ARRAY_FILTER_USE_BOTH
197
-        );
198
-        $processed_attributes = [];
199
-        foreach ($filtered_attributes as $attribute => $value) {
200
-            $attribute = trim($attribute);
201
-            if (is_numeric($attribute)) {
202
-                $add = true;
203
-                if (is_array($value)) {
204
-                    $attribute = isset($value[0]) ? $value[0] : '';
205
-                    $add = isset($value[1]) ? $value[1] : false;
206
-                } else {
207
-                    $attribute = $value;
208
-                }
209
-                $attribute_string = $this->_single_attribute($attribute, $add);
210
-            } else {
211
-                $attribute_string = $this->_attribute($attribute, $value);
212
-            }
213
-            $attribute_string = trim($attribute_string);
214
-            if ($attribute_string) {
215
-                $processed_attributes[] = trim($attribute_string);
216
-            }
217
-        }
218
-        return ! empty($processed_attributes) ? ' ' . implode(' ', $processed_attributes) : '';
219
-    }
220
-
221
-
222
-
223
-    /**
224
-     * returns string like: ' attribute="value"'
225
-     * returns an empty string if $value is null
226
-     *
227
-     * @param string $attribute
228
-     * @param string $value
229
-     * @return string
230
-     */
231
-    protected function _attribute($attribute, $value = '')
232
-    {
233
-        if ($value === null) {
234
-            return '';
235
-        }
236
-        $value = esc_attr(trim($value));
237
-        return "{$attribute}=\"{$value}\"";
238
-    }
239
-
240
-
241
-
242
-    /**
243
-     * returns string like: ' data-attribute="value"'
244
-     * returns an empty string if $value is null
245
-     *
246
-     * @param string $attribute
247
-     * @param string $value
248
-     * @return string
249
-     */
250
-    protected function _data_attribute($attribute, $value = '')
251
-    {
252
-        if ($value === null) {
253
-            return '';
254
-        }
255
-        $value = esc_attr($value);
256
-        return "data-{$attribute}=\"{$value}\"";
257
-    }
258
-
259
-
260
-
261
-    /**
262
-     * returns string like: ' attribute' if $add is true
263
-     *
264
-     * @param string  $attribute
265
-     * @param boolean $add
266
-     * @return string
267
-     */
268
-    protected function _single_attribute($attribute, $add = true)
269
-    {
270
-        $attribute = trim($attribute);
271
-        return $add ? "{$attribute}" : '';
272
-    }
273
-
274
-
275
-    /**
276
-     * @param string $tag
277
-     * @param string $children
278
-     * @return string
279
-     * @throws EE_Error
280
-     * @since   $VID:$
281
-     */
282
-    protected function fullDisplayString($tag, $children)
283
-    {
284
-        return EEH_HTML::nl(0, $tag)
285
-               . $this->_opening_tag($tag)
286
-               . $this->_attributes_string($this->_standard_attributes_array())
287
-               . $this->_end_opening_tag()
288
-               . $children
289
-               . EEH_HTML::nl(0, $tag)
290
-               . $this->_closing_tag();
291
-    }
48
+	/**
49
+	 * _append_chars - takes an incoming string, and adds the string $chars to the end of it, but only if $chars is not
50
+	 * already there
51
+	 *
52
+	 * @param string $string - the string being processed
53
+	 * @param string $chars  - exact string of characters to be added to end of string
54
+	 * @return string
55
+	 */
56
+	protected function _append_chars($string = '', $chars = '-')
57
+	{
58
+		return $this->_remove_chars($string, $chars) . $chars;
59
+	}
60
+
61
+
62
+
63
+	/**
64
+	 * Gets the HTML IDs of all the inputs
65
+	 *
66
+	 * @param bool $add_pound_sign
67
+	 * @return array
68
+	 */
69
+	public function get_html_input_ids($add_pound_sign = false)
70
+	{
71
+		return array($this->get_input()->html_id($add_pound_sign));
72
+	}
73
+
74
+
75
+
76
+	/**
77
+	 * Adds js variables for localization to the $other_js_data. These should be put
78
+	 * in each form's "other_data" javascript object.
79
+	 *
80
+	 * @param array $other_js_data
81
+	 * @return array
82
+	 */
83
+	public function get_other_js_data($other_js_data = array())
84
+	{
85
+		return $other_js_data;
86
+	}
87
+
88
+
89
+
90
+	/**
91
+	 * Opportunity for this display strategy to call wp_enqueue_script and wp_enqueue_style.
92
+	 * This should be called during wp_enqueue_scripts
93
+	 */
94
+	public function enqueue_js()
95
+	{
96
+	}
97
+
98
+
99
+
100
+	/**
101
+	 * returns string like: '<tag'
102
+	 *
103
+	 * @param string $tag
104
+	 * @return string
105
+	 */
106
+	protected function _opening_tag($tag)
107
+	{
108
+		$this->_tag = $tag;
109
+		return "<{$this->_tag}";
110
+	}
111
+
112
+
113
+	/**
114
+	 * returns '>'
115
+	 *
116
+	 * @return string
117
+	 */
118
+	protected function _end_opening_tag()
119
+	{
120
+		return '>';
121
+	}
122
+
123
+
124
+
125
+	/**
126
+	 * returns string like: '</tag>
127
+	 *
128
+	 * @return string
129
+	 */
130
+	protected function _closing_tag()
131
+	{
132
+		return "</{$this->_tag}>";
133
+	}
134
+
135
+
136
+
137
+	/**
138
+	 * returns string like: '/>'
139
+	 *
140
+	 * @return string
141
+	 */
142
+	protected function _close_tag()
143
+	{
144
+		return '/>';
145
+	}
146
+
147
+
148
+	/**
149
+	 * returns an array of standard HTML attributes that get added to nearly all inputs,
150
+	 * where string keys represent named attributes like id, class, etc
151
+	 * and numeric keys represent single attributes like 'required'.
152
+	 * Note: this does not include "value" because many inputs (like dropdowns, textareas, and checkboxes) don't use
153
+	 * it.
154
+	 *
155
+	 * @return array
156
+	 * @throws EE_Error
157
+	 */
158
+	protected function _standard_attributes_array()
159
+	{
160
+		return [
161
+			'name'  => $this->_input->html_name(),
162
+			'id'    => $this->_input->html_id(),
163
+			'class' => $this->_input->html_class(true),
164
+			0       => ['required', $this->_input->required()],
165
+			1       => $this->_input->other_html_attributes(),
166
+			'style' => $this->_input->html_style(),
167
+		];
168
+	}
169
+
170
+
171
+	/**
172
+	 * sets the attributes using the incoming array
173
+	 * and returns a string of all attributes rendered as valid HTML
174
+	 *
175
+	 * @param array $attributes
176
+	 * @return string
177
+	 */
178
+	protected function _attributes_string($attributes = array())
179
+	{
180
+		$attributes = apply_filters(
181
+			'FHEE__EE_Display_Strategy_Base__attributes_string__attributes',
182
+			$attributes,
183
+			$this,
184
+			$this->_input
185
+		);
186
+		$filtered_attributes = array_filter(
187
+			$attributes,
188
+			function ($value, $attribute) {
189
+				// always add 'value' attribute or arrays of attributes
190
+				if ($attribute === 'value' || is_array($value)) {
191
+					return true;
192
+				}
193
+				// otherwise only add those with a value (ie: attribute has been set)
194
+				return ! empty($value);
195
+			},
196
+			ARRAY_FILTER_USE_BOTH
197
+		);
198
+		$processed_attributes = [];
199
+		foreach ($filtered_attributes as $attribute => $value) {
200
+			$attribute = trim($attribute);
201
+			if (is_numeric($attribute)) {
202
+				$add = true;
203
+				if (is_array($value)) {
204
+					$attribute = isset($value[0]) ? $value[0] : '';
205
+					$add = isset($value[1]) ? $value[1] : false;
206
+				} else {
207
+					$attribute = $value;
208
+				}
209
+				$attribute_string = $this->_single_attribute($attribute, $add);
210
+			} else {
211
+				$attribute_string = $this->_attribute($attribute, $value);
212
+			}
213
+			$attribute_string = trim($attribute_string);
214
+			if ($attribute_string) {
215
+				$processed_attributes[] = trim($attribute_string);
216
+			}
217
+		}
218
+		return ! empty($processed_attributes) ? ' ' . implode(' ', $processed_attributes) : '';
219
+	}
220
+
221
+
222
+
223
+	/**
224
+	 * returns string like: ' attribute="value"'
225
+	 * returns an empty string if $value is null
226
+	 *
227
+	 * @param string $attribute
228
+	 * @param string $value
229
+	 * @return string
230
+	 */
231
+	protected function _attribute($attribute, $value = '')
232
+	{
233
+		if ($value === null) {
234
+			return '';
235
+		}
236
+		$value = esc_attr(trim($value));
237
+		return "{$attribute}=\"{$value}\"";
238
+	}
239
+
240
+
241
+
242
+	/**
243
+	 * returns string like: ' data-attribute="value"'
244
+	 * returns an empty string if $value is null
245
+	 *
246
+	 * @param string $attribute
247
+	 * @param string $value
248
+	 * @return string
249
+	 */
250
+	protected function _data_attribute($attribute, $value = '')
251
+	{
252
+		if ($value === null) {
253
+			return '';
254
+		}
255
+		$value = esc_attr($value);
256
+		return "data-{$attribute}=\"{$value}\"";
257
+	}
258
+
259
+
260
+
261
+	/**
262
+	 * returns string like: ' attribute' if $add is true
263
+	 *
264
+	 * @param string  $attribute
265
+	 * @param boolean $add
266
+	 * @return string
267
+	 */
268
+	protected function _single_attribute($attribute, $add = true)
269
+	{
270
+		$attribute = trim($attribute);
271
+		return $add ? "{$attribute}" : '';
272
+	}
273
+
274
+
275
+	/**
276
+	 * @param string $tag
277
+	 * @param string $children
278
+	 * @return string
279
+	 * @throws EE_Error
280
+	 * @since   $VID:$
281
+	 */
282
+	protected function fullDisplayString($tag, $children)
283
+	{
284
+		return EEH_HTML::nl(0, $tag)
285
+			   . $this->_opening_tag($tag)
286
+			   . $this->_attributes_string($this->_standard_attributes_array())
287
+			   . $this->_end_opening_tag()
288
+			   . $children
289
+			   . EEH_HTML::nl(0, $tag)
290
+			   . $this->_closing_tag();
291
+	}
292 292
 }
Please login to merge, or discard this patch.
core/domain/EnqueueAssetsInterface.php 1 patch
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -5,47 +5,47 @@
 block discarded – undo
5 5
 interface EnqueueAssetsInterface
6 6
 {
7 7
 
8
-    /**
9
-     * a place to register scripts and stylesheets with WordPress core
10
-     * IMPORTANT !!!
11
-     * ALL JavaScript files need to be registered for loading in the footer
12
-     * by setting the 5th parameter of wp_register_script() to ` true `
13
-     *
14
-     * @return void
15
-     */
16
-    public function registerScriptsAndStylesheets();
17
-
18
-
19
-    /**
20
-     * a place to enqueue previously registered stylesheets
21
-     * this will be called during the wp_enqueue_scripts hook for frontend requests
22
-     *
23
-     * @return void
24
-     */
25
-    public function enqueueStylesheets();
26
-
27
-
28
-    /**
29
-     * a place to enqueue previously registered stylesheets
30
-     * this will be called during the admin_enqueue_scripts hook for admin requests
31
-     *
32
-     * @return void
33
-     */
34
-    public function enqueueAdminStylesheets();
35
-
36
-
37
-    /**
38
-     * a place to enqueue previously registered scripts for frontend requests
39
-     *
40
-     * @return void
41
-     */
42
-    public function enqueueScripts();
43
-
44
-
45
-    /**
46
-     * a place to enqueue previously registered scripts for admin requests
47
-     *
48
-     * @return void
49
-     */
50
-    public function enqueueAdminScripts();
8
+	/**
9
+	 * a place to register scripts and stylesheets with WordPress core
10
+	 * IMPORTANT !!!
11
+	 * ALL JavaScript files need to be registered for loading in the footer
12
+	 * by setting the 5th parameter of wp_register_script() to ` true `
13
+	 *
14
+	 * @return void
15
+	 */
16
+	public function registerScriptsAndStylesheets();
17
+
18
+
19
+	/**
20
+	 * a place to enqueue previously registered stylesheets
21
+	 * this will be called during the wp_enqueue_scripts hook for frontend requests
22
+	 *
23
+	 * @return void
24
+	 */
25
+	public function enqueueStylesheets();
26
+
27
+
28
+	/**
29
+	 * a place to enqueue previously registered stylesheets
30
+	 * this will be called during the admin_enqueue_scripts hook for admin requests
31
+	 *
32
+	 * @return void
33
+	 */
34
+	public function enqueueAdminStylesheets();
35
+
36
+
37
+	/**
38
+	 * a place to enqueue previously registered scripts for frontend requests
39
+	 *
40
+	 * @return void
41
+	 */
42
+	public function enqueueScripts();
43
+
44
+
45
+	/**
46
+	 * a place to enqueue previously registered scripts for admin requests
47
+	 *
48
+	 * @return void
49
+	 */
50
+	public function enqueueAdminScripts();
51 51
 }
Please login to merge, or discard this patch.
Paypal_Pro/help_tabs/payment_methods_overview_paypalpro.help_tab.php 1 patch
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -4,12 +4,12 @@  discard block
 block discarded – undo
4 4
 </p>
5 5
 <p>
6 6
     <?php
7
-    printf(
8
-        esc_html__('See %1$shere%2$s for list of currencies supported by Paypal Pro.', 'event_espresso'),
9
-        "<a href='https://www.paypal.com/multicurrency' target='_blank' rel='noopener noreferrer'>",
10
-        "</a>"
11
-    );
12
-    ?>
7
+	printf(
8
+		esc_html__('See %1$shere%2$s for list of currencies supported by Paypal Pro.', 'event_espresso'),
9
+		"<a href='https://www.paypal.com/multicurrency' target='_blank' rel='noopener noreferrer'>",
10
+		"</a>"
11
+	);
12
+	?>
13 13
 </p>
14 14
 <p><strong><?php esc_html_e('PayPal Pro Settings', 'event_espresso'); ?></strong></p>
15 15
 <ul>
@@ -20,48 +20,48 @@  discard block
 block discarded – undo
20 20
     <li>
21 21
         <strong><?php esc_html_e('PayPal API Username', 'event_espresso'); ?></strong><br/>
22 22
         <?php
23
-        printf(
24
-            esc_html__(
25
-                'Enter your API Username for PayPal. Learn how to find your %1$sAPI Username%2$s.',
26
-                'event_espresso'
27
-            ),
28
-            '<a href="https://www.paypal.com/us/cgi-bin/webscr?cmd=xpt/cps/merchant/wppro/WPProIntegrationSteps-outside#SectionB" target="_blank" rel="noopener noreferrer">',
29
-            '</a>'
30
-        );
31
-        ?>
23
+		printf(
24
+			esc_html__(
25
+				'Enter your API Username for PayPal. Learn how to find your %1$sAPI Username%2$s.',
26
+				'event_espresso'
27
+			),
28
+			'<a href="https://www.paypal.com/us/cgi-bin/webscr?cmd=xpt/cps/merchant/wppro/WPProIntegrationSteps-outside#SectionB" target="_blank" rel="noopener noreferrer">',
29
+			'</a>'
30
+		);
31
+		?>
32 32
     </li>
33 33
     <li>
34 34
         <strong><?php esc_html_e('PayPal API Password', 'event_espresso'); ?></strong><br/>
35 35
         <?php
36
-        printf(
37
-            esc_html__(
38
-                'Enter your API Password for PayPal. Learn how to find your %1$sAPI Password%2$s.',
39
-                'event_espresso'
40
-            ),
41
-            '<a href="https://www.paypal.com/us/cgi-bin/webscr?cmd=xpt/cps/merchant/wppro/WPProIntegrationSteps-outside#SectionB" target="_blank" rel="noopener noreferrer">',
42
-            '</a>'
43
-        );
44
-        ?>
36
+		printf(
37
+			esc_html__(
38
+				'Enter your API Password for PayPal. Learn how to find your %1$sAPI Password%2$s.',
39
+				'event_espresso'
40
+			),
41
+			'<a href="https://www.paypal.com/us/cgi-bin/webscr?cmd=xpt/cps/merchant/wppro/WPProIntegrationSteps-outside#SectionB" target="_blank" rel="noopener noreferrer">',
42
+			'</a>'
43
+		);
44
+		?>
45 45
     </li>
46 46
     <li>
47 47
         <strong><?php esc_html_e('PayPal API Signature', 'event_espresso'); ?></strong><br/>
48 48
         <?php
49
-        printf(
50
-            esc_html__(
51
-                'Enter your API Signature for PayPal. Learn how to find your %1$sAPI Signature%2$s.',
52
-                'event_espresso'
53
-            ),
54
-            '<a href="https://www.paypal.com/us/cgi-bin/webscr?cmd=xpt/cps/merchant/wppro/WPProIntegrationSteps-outside#SectionB" target="_blank" rel="noopener noreferrer">',
55
-            '</a>'
56
-        );
57
-        ?>
49
+		printf(
50
+			esc_html__(
51
+				'Enter your API Signature for PayPal. Learn how to find your %1$sAPI Signature%2$s.',
52
+				'event_espresso'
53
+			),
54
+			'<a href="https://www.paypal.com/us/cgi-bin/webscr?cmd=xpt/cps/merchant/wppro/WPProIntegrationSteps-outside#SectionB" target="_blank" rel="noopener noreferrer">',
55
+			'</a>'
56
+		);
57
+		?>
58 58
     </li>
59 59
     <li>
60 60
         <strong><?php esc_html_e('Country Currency', 'event_espresso'); ?></strong><br/>
61 61
         <?php esc_html_e(
62
-            'Select the currency for your country. Payments will be accepted in this currency.',
63
-            'event_espresso'
64
-        ); ?>
62
+			'Select the currency for your country. Payments will be accepted in this currency.',
63
+			'event_espresso'
64
+		); ?>
65 65
     </li>
66 66
     <li>
67 67
         <strong><?php esc_html_e('Accepted Card Types', 'event_espresso'); ?></strong><br/>
@@ -70,9 +70,9 @@  discard block
 block discarded – undo
70 70
     <li>
71 71
         <strong><?php esc_html_e('Use the Debugging Feature and the PayPal Sandbox', 'event_espresso'); ?></strong><br/>
72 72
         <?php esc_html_e(
73
-            'Specify if you want to test the payment gateway by submitting a test transaction. If this option is enabled, be sure to enter your PayPal sandbox credentials in the fields above. Be sure to turn this setting off when you are done testing.',
74
-            'event_espresso'
75
-        ); ?>
73
+			'Specify if you want to test the payment gateway by submitting a test transaction. If this option is enabled, be sure to enter your PayPal sandbox credentials in the fields above. Be sure to turn this setting off when you are done testing.',
74
+			'event_espresso'
75
+		); ?>
76 76
     </li>
77 77
     <li>
78 78
         <strong><?php esc_html_e('Button Image URL', 'event_espresso'); ?></strong><br/>
Please login to merge, or discard this patch.
payment_methods/Bank/templates/bank_intro.template.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 esc_html_e(
4
-    'Bank is an offline payment method for accepting payments. Payments are processed manually by providing your registrants/attendees with information on how to pay with a bank transfer.',
5
-    'event_espresso'
4
+	'Bank is an offline payment method for accepting payments. Payments are processed manually by providing your registrants/attendees with information on how to pay with a bank transfer.',
5
+	'event_espresso'
6 6
 );
Please login to merge, or discard this patch.
payment_methods/Check/templates/check_intro.template.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 esc_html_e(
4
-    'Check is an offline payment method for accepting payments. Payments are processed manually by providing your registrants/attendees with information on how to pay with a check.',
5
-    'event_espresso'
4
+	'Check is an offline payment method for accepting payments. Payments are processed manually by providing your registrants/attendees with information on how to pay with a check.',
5
+	'event_espresso'
6 6
 );
Please login to merge, or discard this patch.
payment_methods/Invoice/EE_PMT_Invoice.pm.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
             '<br />'
41 41
         );
42 42
         parent::__construct($pm_instance);
43
-        $this->_default_button_url = $this->file_url() . 'lib/invoice-logo.png';
43
+        $this->_default_button_url = $this->file_url().'lib/invoice-logo.png';
44 44
     }
45 45
 
46 46
 
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
     {
66 66
         $pdf_payee_input_name = 'pdf_payee_name';
67 67
         $confirmation_text_input_name = 'page_confirmation_text';
68
-        $form =  new EE_Payment_Method_Form(array(
68
+        $form = new EE_Payment_Method_Form(array(
69 69
 //              'payment_method_type' => $this,
70 70
                 'extra_meta_inputs' => array(
71 71
                     $pdf_payee_input_name => new EE_Text_Input(array(
@@ -79,12 +79,12 @@  discard block
 block discarded – undo
79 79
                         )),
80 80
                     'pdf_payee_address' => new EE_Text_Area_Input(array(
81 81
                         'html_label_text' => sprintf(esc_html__('Payee Address %s', 'event_espresso'), $this->get_help_tab_link()),
82
-                        'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
82
+                        'validation_strategies' => array(new EE_Full_HTML_Validation_Strategy()),
83 83
                     )),
84 84
                     'pdf_instructions' => new EE_Text_Area_Input(array(
85 85
                         'html_label_text' =>  sprintf(esc_html__("Instructions %s", "event_espresso"), $this->get_help_tab_link()),
86 86
                         'default' =>  esc_html__("Please send this invoice with payment attached to the address above, or use the payment link below. Payment must be received within 48 hours of event date.", 'event_espresso'),
87
-                        'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
87
+                        'validation_strategies' => array(new EE_Full_HTML_Validation_Strategy()),
88 88
                     )),
89 89
                     'pdf_logo_image' => new EE_Admin_File_Uploader_Input(array(
90 90
                         'html_label_text' =>  sprintf(esc_html__("Logo Image %s", "event_espresso"), $this->get_help_tab_link()),
@@ -94,24 +94,24 @@  discard block
 block discarded – undo
94 94
                     $confirmation_text_input_name => new EE_Text_Area_Input(array(
95 95
                         'html_label_text' =>  sprintf(esc_html__("Confirmation Text %s", "event_espresso"), $this->get_help_tab_link()),
96 96
                         'default' =>  esc_html__("Payment must be received within 48 hours of event date. Details about where to send the payment are included on the invoice.", 'event_espresso'),
97
-                        'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
97
+                        'validation_strategies' => array(new EE_Full_HTML_Validation_Strategy()),
98 98
                     )),
99 99
                     'page_extra_info' => new EE_Text_Area_Input(array(
100 100
                         'html_label_text' =>  sprintf(esc_html__("Extra Info %s", "event_espresso"), $this->get_help_tab_link()),
101
-                        'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
101
+                        'validation_strategies' => array(new EE_Full_HTML_Validation_Strategy()),
102 102
                     )),
103 103
                 ),
104 104
                 'include' => array(
105
-                    'PMD_ID', 'PMD_name','PMD_desc','PMD_admin_name','PMD_admin_desc', 'PMD_type','PMD_slug', 'PMD_open_by_default','PMD_button_url','PMD_scope','Currency','PMD_order',
106
-                    $pdf_payee_input_name, 'pdf_payee_email', 'pdf_payee_tax_number', 'pdf_payee_address', 'pdf_instructions','pdf_logo_image',
105
+                    'PMD_ID', 'PMD_name', 'PMD_desc', 'PMD_admin_name', 'PMD_admin_desc', 'PMD_type', 'PMD_slug', 'PMD_open_by_default', 'PMD_button_url', 'PMD_scope', 'Currency', 'PMD_order',
106
+                    $pdf_payee_input_name, 'pdf_payee_email', 'pdf_payee_tax_number', 'pdf_payee_address', 'pdf_instructions', 'pdf_logo_image',
107 107
                     $confirmation_text_input_name, 'page_extra_info'),
108 108
             ));
109 109
         $form->add_subsections(
110
-            array( 'header1' => new EE_Form_Section_HTML_From_Template('payment_methods/Invoice/templates/invoice_settings_header_display.template.php')),
110
+            array('header1' => new EE_Form_Section_HTML_From_Template('payment_methods/Invoice/templates/invoice_settings_header_display.template.php')),
111 111
             $pdf_payee_input_name
112 112
         );
113 113
         $form->add_subsections(
114
-            array( 'header2' => new EE_Form_Section_HTML_From_Template('payment_methods/Invoice/templates/invoice_settings_header_gateway.template.php')),
114
+            array('header2' => new EE_Form_Section_HTML_From_Template('payment_methods/Invoice/templates/invoice_settings_header_gateway.template.php')),
115 115
             $confirmation_text_input_name
116 116
         );
117 117
         return $form;
Please login to merge, or discard this patch.
Indentation   +120 added lines, -120 removed lines patch added patch discarded remove patch
@@ -24,136 +24,136 @@
 block discarded – undo
24 24
  */
25 25
 class EE_PMT_Invoice extends EE_PMT_Base
26 26
 {
27
-    /**
28
-     *
29
-     * @param EE_Payment_Method $pm_instance
30
-     * @return EE_PMT_Invoice
31
-     */
32
-    public function __construct($pm_instance = null)
33
-    {
34
-        $this->_pretty_name = esc_html__("Invoice", 'event_espresso');
35
-        $this->_default_description = sprintf(
36
-            esc_html__('After clicking "Finalize Registration", you will be given instructions on how to access your invoice and complete your payment.%sPlease note that event spaces will not be reserved until payment is received in full, and any remaining tickets could be sold to others in the meantime.', 'event_espresso'),
37
-            '<br />'
38
-        );
39
-        parent::__construct($pm_instance);
40
-        $this->_default_button_url = $this->file_url() . 'lib/invoice-logo.png';
41
-    }
27
+	/**
28
+	 *
29
+	 * @param EE_Payment_Method $pm_instance
30
+	 * @return EE_PMT_Invoice
31
+	 */
32
+	public function __construct($pm_instance = null)
33
+	{
34
+		$this->_pretty_name = esc_html__("Invoice", 'event_espresso');
35
+		$this->_default_description = sprintf(
36
+			esc_html__('After clicking "Finalize Registration", you will be given instructions on how to access your invoice and complete your payment.%sPlease note that event spaces will not be reserved until payment is received in full, and any remaining tickets could be sold to others in the meantime.', 'event_espresso'),
37
+			'<br />'
38
+		);
39
+		parent::__construct($pm_instance);
40
+		$this->_default_button_url = $this->file_url() . 'lib/invoice-logo.png';
41
+	}
42 42
 
43 43
 
44 44
 
45
-    /**
46
-     * Creates the billing form for this payment method type
47
-     * @param \EE_Transaction $transaction
48
-     * @return NULL
49
-     */
50
-    public function generate_new_billing_form(EE_Transaction $transaction = null)
51
-    {
52
-        return null;
53
-    }
45
+	/**
46
+	 * Creates the billing form for this payment method type
47
+	 * @param \EE_Transaction $transaction
48
+	 * @return NULL
49
+	 */
50
+	public function generate_new_billing_form(EE_Transaction $transaction = null)
51
+	{
52
+		return null;
53
+	}
54 54
 
55 55
 
56 56
 
57
-    /**
58
-     * Gets the form for all the settings related to this payment method type
59
-     * @return EE_Payment_Method_Form
60
-     */
61
-    public function generate_new_settings_form()
62
-    {
63
-        $pdf_payee_input_name = 'pdf_payee_name';
64
-        $confirmation_text_input_name = 'page_confirmation_text';
65
-        $form =  new EE_Payment_Method_Form(array(
57
+	/**
58
+	 * Gets the form for all the settings related to this payment method type
59
+	 * @return EE_Payment_Method_Form
60
+	 */
61
+	public function generate_new_settings_form()
62
+	{
63
+		$pdf_payee_input_name = 'pdf_payee_name';
64
+		$confirmation_text_input_name = 'page_confirmation_text';
65
+		$form =  new EE_Payment_Method_Form(array(
66 66
 //              'payment_method_type' => $this,
67
-                'extra_meta_inputs' => array(
68
-                    $pdf_payee_input_name => new EE_Text_Input(array(
69
-                        'html_label_text' => sprintf(esc_html__('Payee Name %s', 'event_espresso'), $this->get_help_tab_link())
70
-                    )),
71
-                    'pdf_payee_email' => new EE_Email_Input(array(
72
-                        'html_label_text' => sprintf(esc_html__('Payee Email %s', 'event_espresso'), $this->get_help_tab_link()),
73
-                    )),
74
-                    'pdf_payee_tax_number' => new EE_Text_Input(array(
75
-                        'html_label_text' => sprintf(esc_html__('Payee Tax Number %s', 'event_espresso'), $this->get_help_tab_link()),
76
-                        )),
77
-                    'pdf_payee_address' => new EE_Text_Area_Input(array(
78
-                        'html_label_text' => sprintf(esc_html__('Payee Address %s', 'event_espresso'), $this->get_help_tab_link()),
79
-                        'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
80
-                    )),
81
-                    'pdf_instructions' => new EE_Text_Area_Input(array(
82
-                        'html_label_text' =>  sprintf(esc_html__("Instructions %s", "event_espresso"), $this->get_help_tab_link()),
83
-                        'default' =>  esc_html__("Please send this invoice with payment attached to the address above, or use the payment link below. Payment must be received within 48 hours of event date.", 'event_espresso'),
84
-                        'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
85
-                    )),
86
-                    'pdf_logo_image' => new EE_Admin_File_Uploader_Input(array(
87
-                        'html_label_text' =>  sprintf(esc_html__("Logo Image %s", "event_espresso"), $this->get_help_tab_link()),
88
-                        'default' =>  EE_Config::instance()->organization->logo_url,
89
-                        'html_help_text' =>  esc_html__("(Logo for the top left of the invoice)", 'event_espresso'),
90
-                    )),
91
-                    $confirmation_text_input_name => new EE_Text_Area_Input(array(
92
-                        'html_label_text' =>  sprintf(esc_html__("Confirmation Text %s", "event_espresso"), $this->get_help_tab_link()),
93
-                        'default' =>  esc_html__("Payment must be received within 48 hours of event date. Details about where to send the payment are included on the invoice.", 'event_espresso'),
94
-                        'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
95
-                    )),
96
-                    'page_extra_info' => new EE_Text_Area_Input(array(
97
-                        'html_label_text' =>  sprintf(esc_html__("Extra Info %s", "event_espresso"), $this->get_help_tab_link()),
98
-                        'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
99
-                    )),
100
-                ),
101
-                'include' => array(
102
-                    'PMD_ID', 'PMD_name','PMD_desc','PMD_admin_name','PMD_admin_desc', 'PMD_type','PMD_slug', 'PMD_open_by_default','PMD_button_url','PMD_scope','Currency','PMD_order',
103
-                    $pdf_payee_input_name, 'pdf_payee_email', 'pdf_payee_tax_number', 'pdf_payee_address', 'pdf_instructions','pdf_logo_image',
104
-                    $confirmation_text_input_name, 'page_extra_info'),
105
-            ));
106
-        $form->add_subsections(
107
-            array( 'header1' => new EE_Form_Section_HTML_From_Template('payment_methods/Invoice/templates/invoice_settings_header_display.template.php')),
108
-            $pdf_payee_input_name
109
-        );
110
-        $form->add_subsections(
111
-            array( 'header2' => new EE_Form_Section_HTML_From_Template('payment_methods/Invoice/templates/invoice_settings_header_gateway.template.php')),
112
-            $confirmation_text_input_name
113
-        );
114
-        return $form;
115
-    }
67
+				'extra_meta_inputs' => array(
68
+					$pdf_payee_input_name => new EE_Text_Input(array(
69
+						'html_label_text' => sprintf(esc_html__('Payee Name %s', 'event_espresso'), $this->get_help_tab_link())
70
+					)),
71
+					'pdf_payee_email' => new EE_Email_Input(array(
72
+						'html_label_text' => sprintf(esc_html__('Payee Email %s', 'event_espresso'), $this->get_help_tab_link()),
73
+					)),
74
+					'pdf_payee_tax_number' => new EE_Text_Input(array(
75
+						'html_label_text' => sprintf(esc_html__('Payee Tax Number %s', 'event_espresso'), $this->get_help_tab_link()),
76
+						)),
77
+					'pdf_payee_address' => new EE_Text_Area_Input(array(
78
+						'html_label_text' => sprintf(esc_html__('Payee Address %s', 'event_espresso'), $this->get_help_tab_link()),
79
+						'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
80
+					)),
81
+					'pdf_instructions' => new EE_Text_Area_Input(array(
82
+						'html_label_text' =>  sprintf(esc_html__("Instructions %s", "event_espresso"), $this->get_help_tab_link()),
83
+						'default' =>  esc_html__("Please send this invoice with payment attached to the address above, or use the payment link below. Payment must be received within 48 hours of event date.", 'event_espresso'),
84
+						'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
85
+					)),
86
+					'pdf_logo_image' => new EE_Admin_File_Uploader_Input(array(
87
+						'html_label_text' =>  sprintf(esc_html__("Logo Image %s", "event_espresso"), $this->get_help_tab_link()),
88
+						'default' =>  EE_Config::instance()->organization->logo_url,
89
+						'html_help_text' =>  esc_html__("(Logo for the top left of the invoice)", 'event_espresso'),
90
+					)),
91
+					$confirmation_text_input_name => new EE_Text_Area_Input(array(
92
+						'html_label_text' =>  sprintf(esc_html__("Confirmation Text %s", "event_espresso"), $this->get_help_tab_link()),
93
+						'default' =>  esc_html__("Payment must be received within 48 hours of event date. Details about where to send the payment are included on the invoice.", 'event_espresso'),
94
+						'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
95
+					)),
96
+					'page_extra_info' => new EE_Text_Area_Input(array(
97
+						'html_label_text' =>  sprintf(esc_html__("Extra Info %s", "event_espresso"), $this->get_help_tab_link()),
98
+						'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
99
+					)),
100
+				),
101
+				'include' => array(
102
+					'PMD_ID', 'PMD_name','PMD_desc','PMD_admin_name','PMD_admin_desc', 'PMD_type','PMD_slug', 'PMD_open_by_default','PMD_button_url','PMD_scope','Currency','PMD_order',
103
+					$pdf_payee_input_name, 'pdf_payee_email', 'pdf_payee_tax_number', 'pdf_payee_address', 'pdf_instructions','pdf_logo_image',
104
+					$confirmation_text_input_name, 'page_extra_info'),
105
+			));
106
+		$form->add_subsections(
107
+			array( 'header1' => new EE_Form_Section_HTML_From_Template('payment_methods/Invoice/templates/invoice_settings_header_display.template.php')),
108
+			$pdf_payee_input_name
109
+		);
110
+		$form->add_subsections(
111
+			array( 'header2' => new EE_Form_Section_HTML_From_Template('payment_methods/Invoice/templates/invoice_settings_header_gateway.template.php')),
112
+			$confirmation_text_input_name
113
+		);
114
+		return $form;
115
+	}
116 116
 
117 117
 
118 118
 
119
-    /**
120
-     * Adds the help tab
121
-     * @see EE_PMT_Base::help_tabs_config()
122
-     * @return array
123
-     */
124
-    public function help_tabs_config()
125
-    {
126
-        return array(
127
-            $this->get_help_tab_name() => array(
128
-                'title' => esc_html__('Invoice Settings', 'event_espresso'),
129
-                'filename' => 'payment_methods_overview_invoice'
130
-            ),
131
-        );
132
-    }
119
+	/**
120
+	 * Adds the help tab
121
+	 * @see EE_PMT_Base::help_tabs_config()
122
+	 * @return array
123
+	 */
124
+	public function help_tabs_config()
125
+	{
126
+		return array(
127
+			$this->get_help_tab_name() => array(
128
+				'title' => esc_html__('Invoice Settings', 'event_espresso'),
129
+				'filename' => 'payment_methods_overview_invoice'
130
+			),
131
+		);
132
+	}
133 133
 
134 134
 
135
-    /**
136
-     * For adding any html output above the payment overview.
137
-     * Many gateways won't want ot display anything, so this function just returns an empty string.
138
-     * Other gateways may want to override this, such as offline gateways.
139
-     *
140
-     * @param \EE_Payment $payment
141
-     * @return string
142
-     */
143
-    public function payment_overview_content(EE_Payment $payment)
144
-    {
145
-        return EEH_Template::locate_template(
146
-            'payment_methods/Invoice/templates/invoice_payment_details_content.template.php',
147
-            array_merge(
148
-                array(
149
-                    'payment_method'            => $this->_pm_instance,
150
-                    'payment'                       => $payment,
151
-                    'page_confirmation_text'                    => '',
152
-                    'page_extra_info'   => '',
153
-                    'invoice_url'                   => $payment->transaction()->primary_registration()->invoice_url('html')
154
-                ),
155
-                $this->_pm_instance->all_extra_meta_array()
156
-            )
157
-        );
158
-    }
135
+	/**
136
+	 * For adding any html output above the payment overview.
137
+	 * Many gateways won't want ot display anything, so this function just returns an empty string.
138
+	 * Other gateways may want to override this, such as offline gateways.
139
+	 *
140
+	 * @param \EE_Payment $payment
141
+	 * @return string
142
+	 */
143
+	public function payment_overview_content(EE_Payment $payment)
144
+	{
145
+		return EEH_Template::locate_template(
146
+			'payment_methods/Invoice/templates/invoice_payment_details_content.template.php',
147
+			array_merge(
148
+				array(
149
+					'payment_method'            => $this->_pm_instance,
150
+					'payment'                       => $payment,
151
+					'page_confirmation_text'                    => '',
152
+					'page_extra_info'   => '',
153
+					'invoice_url'                   => $payment->transaction()->primary_registration()->invoice_url('html')
154
+				),
155
+				$this->_pm_instance->all_extra_meta_array()
156
+			)
157
+		);
158
+	}
159 159
 }
Please login to merge, or discard this patch.
payment_methods/Invoice/templates/invoice_intro.template.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 esc_html_e(
4
-    'Invoice is an offline payment method for accepting payments. Payments are processed manually by providing your registrants/attendees with information on how to pay their invoice.',
5
-    'event_espresso'
4
+	'Invoice is an offline payment method for accepting payments. Payments are processed manually by providing your registrants/attendees with information on how to pay their invoice.',
5
+	'event_espresso'
6 6
 );
Please login to merge, or discard this patch.
payment_methods/Paypal_Express/EEG_Paypal_Express.gateway.php 2 patches
Indentation   +669 added lines, -669 removed lines patch added patch discarded remove patch
@@ -13,677 +13,677 @@
 block discarded – undo
13 13
 
14 14
 // Quickfix to address https://events.codebasehq.com/projects/event-espresso/tickets/11089 ASAP
15 15
 if (! function_exists('mb_strcut')) {
16
-    /**
17
-     * Very simple mimic of mb_substr (which WP ensures exists in wp-includes/compat.php). Still has all the problems of mb_substr
18
-     * (namely, that we might send too many characters to PayPal; however in this case they just issue a warning but nothing breaks)
19
-     * @param $string
20
-     * @param $start
21
-     * @param $length
22
-     * @return bool|string
23
-     */
24
-    function mb_strcut($string, $start, $length = null)
25
-    {
26
-        return mb_substr($string, $start, $length);
27
-    }
16
+	/**
17
+	 * Very simple mimic of mb_substr (which WP ensures exists in wp-includes/compat.php). Still has all the problems of mb_substr
18
+	 * (namely, that we might send too many characters to PayPal; however in this case they just issue a warning but nothing breaks)
19
+	 * @param $string
20
+	 * @param $start
21
+	 * @param $length
22
+	 * @return bool|string
23
+	 */
24
+	function mb_strcut($string, $start, $length = null)
25
+	{
26
+		return mb_substr($string, $start, $length);
27
+	}
28 28
 }
29 29
 class EEG_Paypal_Express extends EE_Offsite_Gateway
30 30
 {
31 31
 
32
-    /**
33
-     * Merchant API Username.
34
-     *
35
-     * @var string
36
-     */
37
-    protected $_api_username;
38
-
39
-    /**
40
-     * Merchant API Password.
41
-     *
42
-     * @var string
43
-     */
44
-    protected $_api_password;
45
-
46
-    /**
47
-     * API Signature.
48
-     *
49
-     * @var string
50
-     */
51
-    protected $_api_signature;
52
-
53
-    /**
54
-     * Request Shipping address on PP checkout page.
55
-     *
56
-     * @var string
57
-     */
58
-    protected $_request_shipping_addr;
59
-
60
-    /**
61
-     * Business/personal logo.
62
-     *
63
-     * @var string
64
-     */
65
-    protected $_image_url;
66
-
67
-    /**
68
-     * gateway URL variable
69
-     *
70
-     * @var string
71
-     */
72
-    protected $_base_gateway_url = '';
73
-
74
-
75
-
76
-    /**
77
-     * EEG_Paypal_Express constructor.
78
-     */
79
-    public function __construct()
80
-    {
81
-        $this->_currencies_supported = array(
82
-            'USD',
83
-            'AUD',
84
-            'BRL',
85
-            'CAD',
86
-            'CZK',
87
-            'DKK',
88
-            'EUR',
89
-            'HKD',
90
-            'HUF',
91
-            'ILS',
92
-            'JPY',
93
-            'MYR',
94
-            'MXN',
95
-            'NOK',
96
-            'NZD',
97
-            'PHP',
98
-            'PLN',
99
-            'GBP',
100
-            'RUB',
101
-            'SGD',
102
-            'SEK',
103
-            'CHF',
104
-            'TWD',
105
-            'THB',
106
-            'TRY',
107
-            'INR',
108
-        );
109
-        parent::__construct();
110
-    }
111
-
112
-
113
-
114
-    /**
115
-     * Sets the gateway URL variable based on whether debug mode is enabled or not.
116
-     *
117
-     * @param array $settings_array
118
-     */
119
-    public function set_settings($settings_array)
120
-    {
121
-        parent::set_settings($settings_array);
122
-        // Redirect URL.
123
-        $this->_base_gateway_url = $this->_debug_mode
124
-            ? 'https://api-3t.sandbox.paypal.com/nvp'
125
-            : 'https://api-3t.paypal.com/nvp';
126
-    }
127
-
128
-
129
-
130
-    /**
131
-     * @param EEI_Payment $payment
132
-     * @param array       $billing_info
133
-     * @param string      $return_url
134
-     * @param string      $notify_url
135
-     * @param string      $cancel_url
136
-     * @return \EE_Payment|\EEI_Payment
137
-     * @throws \EE_Error
138
-     */
139
-    public function set_redirection_info(
140
-        $payment,
141
-        $billing_info = array(),
142
-        $return_url = null,
143
-        $notify_url = null,
144
-        $cancel_url = null
145
-    ) {
146
-        if (! $payment instanceof EEI_Payment) {
147
-            $payment->set_gateway_response(
148
-                esc_html__(
149
-                    'Error. No associated payment was found.',
150
-                    'event_espresso'
151
-                )
152
-            );
153
-            $payment->set_status($this->_pay_model->failed_status());
154
-            return $payment;
155
-        }
156
-        $transaction = $payment->transaction();
157
-        if (! $transaction instanceof EEI_Transaction) {
158
-            $payment->set_gateway_response(
159
-                esc_html__(
160
-                    'Could not process this payment because it has no associated transaction.',
161
-                    'event_espresso'
162
-                )
163
-            );
164
-            $payment->set_status($this->_pay_model->failed_status());
165
-            return $payment;
166
-        }
167
-        $gateway_formatter = $this->_get_gateway_formatter();
168
-        $order_description = mb_strcut($gateway_formatter->formatOrderDescription($payment), 0, 127);
169
-        $primary_registration = $transaction->primary_registration();
170
-        $primary_attendee = $primary_registration instanceof EE_Registration
171
-            ? $primary_registration->attendee()
172
-            : false;
173
-        $locale = explode('-', get_bloginfo('language'));
174
-        // Gather request parameters.
175
-        $token_request_dtls = array(
176
-            'METHOD'                         => 'SetExpressCheckout',
177
-            'PAYMENTREQUEST_0_AMT'           => $payment->amount(),
178
-            'PAYMENTREQUEST_0_CURRENCYCODE'  => $payment->currency_code(),
179
-            'PAYMENTREQUEST_0_DESC'          => $order_description,
180
-            'RETURNURL'                      => $return_url,
181
-            'CANCELURL'                      => $cancel_url,
182
-            'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale',
183
-            // Buyer does not need to create a PayPal account to check out.
184
-            // This is referred to as PayPal Account Optional.
185
-            'SOLUTIONTYPE'                   => 'Sole',
186
-            // Locale of the pages displayed by PayPal during Express Checkout.
187
-            'LOCALECODE'                     => $locale[1]
188
-        );
189
-        // Show itemized list.
190
-        $itemized_list = $this->itemize_list($payment, $transaction);
191
-        $token_request_dtls = array_merge($token_request_dtls, $itemized_list);
192
-        // Automatically filling out shipping and contact information.
193
-        if ($this->_request_shipping_addr && $primary_attendee instanceof EEI_Attendee) {
194
-            // If you do not pass the shipping address, PayPal obtains it from the buyer's account profile.
195
-            $token_request_dtls['NOSHIPPING'] = '2';
196
-            $token_request_dtls['PAYMENTREQUEST_0_SHIPTOSTREET'] = $primary_attendee->address();
197
-            $token_request_dtls['PAYMENTREQUEST_0_SHIPTOSTREET2'] = $primary_attendee->address2();
198
-            $token_request_dtls['PAYMENTREQUEST_0_SHIPTOCITY'] = $primary_attendee->city();
199
-            $token_request_dtls['PAYMENTREQUEST_0_SHIPTOSTATE'] = $primary_attendee->state_abbrev();
200
-            $token_request_dtls['PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE'] = $primary_attendee->country_ID();
201
-            $token_request_dtls['PAYMENTREQUEST_0_SHIPTOZIP'] = $primary_attendee->zip();
202
-            $token_request_dtls['PAYMENTREQUEST_0_EMAIL'] = $primary_attendee->email();
203
-            $token_request_dtls['PAYMENTREQUEST_0_SHIPTOPHONENUM'] = $primary_attendee->phone();
204
-        } elseif (! $this->_request_shipping_addr) {
205
-            // Do not request shipping details on the PP Checkout page.
206
-            $token_request_dtls['NOSHIPPING'] = '1';
207
-            $token_request_dtls['REQCONFIRMSHIPPING'] = '0';
208
-        }
209
-        // Used a business/personal logo on the PayPal page.
210
-        if (! empty($this->_image_url)) {
211
-            $token_request_dtls['LOGOIMG'] = $this->_image_url;
212
-        }
213
-        $token_request_dtls = apply_filters(
214
-            'FHEE__EEG_Paypal_Express__set_redirection_info__arguments',
215
-            $token_request_dtls,
216
-            $this
217
-        );
218
-        // Request PayPal token.
219
-        $token_request_response = $this->_ppExpress_request($token_request_dtls, 'Payment Token', $payment);
220
-        $token_rstatus = $this->_ppExpress_check_response($token_request_response);
221
-        $response_args = (isset($token_rstatus['args']) && is_array($token_rstatus['args']))
222
-            ? $token_rstatus['args']
223
-            : array();
224
-        if ($token_rstatus['status']) {
225
-            // We got the Token so we may continue with the payment and redirect the client.
226
-            $payment->set_details($response_args);
227
-            $gateway_url = $this->_debug_mode ? 'https://www.sandbox.paypal.com' : 'https://www.paypal.com';
228
-            $payment->set_redirect_url(
229
-                $gateway_url
230
-                . '/checkoutnow?useraction=commit&cmd=_express-checkout&token='
231
-                . $response_args['TOKEN']
232
-            );
233
-        } else {
234
-            if (isset($response_args['L_ERRORCODE'])) {
235
-                $payment->set_gateway_response($response_args['L_ERRORCODE'] . '; ' . $response_args['L_SHORTMESSAGE']);
236
-            } else {
237
-                $payment->set_gateway_response(
238
-                    esc_html__(
239
-                        'Error occurred while trying to setup the Express Checkout.',
240
-                        'event_espresso'
241
-                    )
242
-                );
243
-            }
244
-            $payment->set_details($response_args);
245
-            $payment->set_status($this->_pay_model->failed_status());
246
-        }
247
-        return $payment;
248
-    }
249
-
250
-
251
-
252
-    /**
253
-     * @param array           $update_info {
254
-     * @type string           $gateway_txn_id
255
-     * @type string status an EEMI_Payment status
256
-     *                                     }
257
-     * @param EEI_Transaction $transaction
258
-     * @return EEI_Payment
259
-     */
260
-    public function handle_payment_update($update_info, $transaction)
261
-    {
262
-        $payment = $transaction instanceof EEI_Transaction ? $transaction->last_payment() : null;
263
-        if ($payment instanceof EEI_Payment) {
264
-            $this->log(array('Return from Authorization' => $update_info), $payment);
265
-            $transaction = $payment->transaction();
266
-            if (! $transaction instanceof EEI_Transaction) {
267
-                $payment->set_gateway_response(
268
-                    esc_html__(
269
-                        'Could not process this payment because it has no associated transaction.',
270
-                        'event_espresso'
271
-                    )
272
-                );
273
-                $payment->set_status($this->_pay_model->failed_status());
274
-                return $payment;
275
-            }
276
-            $primary_registrant = $transaction->primary_registration();
277
-            $payment_details = $payment->details();
278
-            // Check if we still have the token.
279
-            if (! isset($payment_details['TOKEN']) || empty($payment_details['TOKEN'])) {
280
-                $payment->set_status($this->_pay_model->failed_status());
281
-                return $payment;
282
-            }
283
-            $cdetails_request_dtls = array(
284
-                'METHOD' => 'GetExpressCheckoutDetails',
285
-                'TOKEN'  => $payment_details['TOKEN'],
286
-            );
287
-            // Request Customer Details.
288
-            $cdetails_request_response = $this->_ppExpress_request(
289
-                $cdetails_request_dtls,
290
-                'Customer Details',
291
-                $payment
292
-            );
293
-            $cdetails_rstatus = $this->_ppExpress_check_response($cdetails_request_response);
294
-            $cdata_response_args = (isset($cdetails_rstatus['args']) && is_array($cdetails_rstatus['args']))
295
-                ? $cdetails_rstatus['args']
296
-                : array();
297
-            if ($cdetails_rstatus['status']) {
298
-                // We got the PayerID so now we can Complete the transaction.
299
-                $docheckout_request_dtls = array(
300
-                    'METHOD'                         => 'DoExpressCheckoutPayment',
301
-                    'PAYERID'                        => $cdata_response_args['PAYERID'],
302
-                    'TOKEN'                          => $payment_details['TOKEN'],
303
-                    'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale',
304
-                    'PAYMENTREQUEST_0_AMT'           => $payment->amount(),
305
-                    'PAYMENTREQUEST_0_CURRENCYCODE'  => $payment->currency_code(),
306
-                );
307
-                 // Include itemized list.
308
-                $itemized_list = $this->itemize_list(
309
-                    $payment,
310
-                    $transaction,
311
-                    $cdata_response_args
312
-                );
313
-                $docheckout_request_dtls = array_merge($docheckout_request_dtls, $itemized_list);
314
-                // Payment Checkout/Capture.
315
-                $docheckout_request_response = $this->_ppExpress_request(
316
-                    $docheckout_request_dtls,
317
-                    'Do Payment',
318
-                    $payment
319
-                );
320
-                $docheckout_rstatus = $this->_ppExpress_check_response($docheckout_request_response);
321
-                $docheckout_response_args = (isset($docheckout_rstatus['args']) && is_array($docheckout_rstatus['args']))
322
-                    ? $docheckout_rstatus['args']
323
-                    : array();
324
-                if ($docheckout_rstatus['status']) {
325
-                    // All is well, payment approved.
326
-                    $primary_registration_code = $primary_registrant instanceof EE_Registration ?
327
-                        $primary_registrant->reg_code()
328
-                        : '';
329
-                    $payment->set_extra_accntng($primary_registration_code);
330
-                    $payment->set_amount(isset($docheckout_response_args['PAYMENTINFO_0_AMT'])
331
-                        ? (float) $docheckout_response_args['PAYMENTINFO_0_AMT']
332
-                        : 0);
333
-                    $payment->set_txn_id_chq_nmbr(isset($docheckout_response_args['PAYMENTINFO_0_TRANSACTIONID'])
334
-                        ? $docheckout_response_args['PAYMENTINFO_0_TRANSACTIONID']
335
-                        : null);
336
-                    $payment->set_details($cdata_response_args);
337
-                    $payment->set_gateway_response(isset($docheckout_response_args['PAYMENTINFO_0_ACK'])
338
-                        ? $docheckout_response_args['PAYMENTINFO_0_ACK']
339
-                        : '');
340
-                    $payment->set_status($this->_pay_model->approved_status());
341
-                } else {
342
-                    if (isset($docheckout_response_args['L_ERRORCODE'])) {
343
-                        $payment->set_gateway_response(
344
-                            $docheckout_response_args['L_ERRORCODE']
345
-                            . '; '
346
-                            . $docheckout_response_args['L_SHORTMESSAGE']
347
-                        );
348
-                    } else {
349
-                        $payment->set_gateway_response(
350
-                            esc_html__(
351
-                                'Error occurred while trying to Capture the funds.',
352
-                                'event_espresso'
353
-                            )
354
-                        );
355
-                    }
356
-                    $payment->set_details($docheckout_response_args);
357
-                    $payment->set_status($this->_pay_model->declined_status());
358
-                }
359
-            } else {
360
-                if (isset($cdata_response_args['L_ERRORCODE'])) {
361
-                    $payment->set_gateway_response(
362
-                        $cdata_response_args['L_ERRORCODE']
363
-                        . '; '
364
-                        . $cdata_response_args['L_SHORTMESSAGE']
365
-                    );
366
-                } else {
367
-                    $payment->set_gateway_response(
368
-                        esc_html__(
369
-                            'Error occurred while trying to get payment Details from PayPal.',
370
-                            'event_espresso'
371
-                        )
372
-                    );
373
-                }
374
-                $payment->set_details($cdata_response_args);
375
-                $payment->set_status($this->_pay_model->failed_status());
376
-            }
377
-        } else {
378
-            $payment->set_gateway_response(
379
-                esc_html__(
380
-                    'Error occurred while trying to process the payment.',
381
-                    'event_espresso'
382
-                )
383
-            );
384
-            $payment->set_status($this->_pay_model->failed_status());
385
-        }
386
-        return $payment;
387
-    }
388
-
389
-
390
-
391
-    /**
392
-     *  Make a list of items that are in the giver transaction.
393
-     *
394
-     * @param EEI_Payment     $payment
395
-     * @param EEI_Transaction $transaction
396
-     * @param array           $request_response_args Data from a previous communication with PP.
397
-     * @return array
398
-     */
399
-    public function itemize_list(EEI_Payment $payment, EEI_Transaction $transaction, $request_response_args = array())
400
-    {
401
-        $itemized_list = array();
402
-        $gateway_formatter = $this->_get_gateway_formatter();
403
-        // If we have data from a previous communication with PP (on this transaction) we may use that for our list...
404
-        if (
405
-            ! empty($request_response_args)
406
-            && array_key_exists('L_PAYMENTREQUEST_0_AMT0', $request_response_args)
407
-            && array_key_exists('PAYMENTREQUEST_0_ITEMAMT', $request_response_args)
408
-        ) {
409
-            foreach ($request_response_args as $arg_key => $arg_val) {
410
-                if (
411
-                    strpos($arg_key, 'PAYMENTREQUEST_') !== false
412
-                    && strpos($arg_key, 'NOTIFYURL') === false
413
-                ) {
414
-                    $itemized_list[ $arg_key ] = $arg_val;
415
-                }
416
-            }
417
-            // If we got only a few Items then something is not right.
418
-            if (count($itemized_list) > 2) {
419
-                return $itemized_list;
420
-            } else {
421
-                if (WP_DEBUG) {
422
-                    throw new EE_Error(
423
-                        sprintf(
424
-                            esc_html__(
425
-                                // @codingStandardsIgnoreStart
426
-                                'Unable to continue with the checkout because a proper purchase list could not be generated. The purchased list we could have sent was %1$s',
427
-                                // @codingStandardsIgnoreEnd
428
-                                'event_espresso'
429
-                            ),
430
-                            wp_json_encode($itemized_list)
431
-                        )
432
-                    );
433
-                }
434
-                // Reset the list and log an error, maybe allow to try and generate a new list (below).
435
-                $itemized_list = array();
436
-                $this->log(
437
-                    array(
438
-                        (string) esc_html__(
439
-                            'Could not generate a proper item list with:',
440
-                            'event_espresso'
441
-                        ) => $request_response_args
442
-                    ),
443
-                    $payment
444
-                );
445
-            }
446
-        }
447
-        // ...otherwise we generate a new list for this transaction.
448
-        if ($this->_money->compare_floats($payment->amount(), $transaction->total(), '==')) {
449
-            $item_num = 0;
450
-            $itemized_sum = 0;
451
-            $total_line_items = $transaction->total_line_item();
452
-            // Go through each item in the list.
453
-            foreach ($total_line_items->get_items() as $line_item) {
454
-                if ($line_item instanceof EE_Line_Item) {
455
-                    // PayPal doesn't like line items with 0.00 amount, so we may skip those.
456
-                    if (EEH_Money::compare_floats($line_item->total(), '0.00', '==')) {
457
-                        continue;
458
-                    }
459
-                    $unit_price = $line_item->unit_price();
460
-                    $line_item_quantity = $line_item->quantity();
461
-                    // This is a discount.
462
-                    if ($line_item->is_percent()) {
463
-                        $unit_price = $line_item->total();
464
-                        $line_item_quantity = 1;
465
-                    }
466
-                    // Item Name.
467
-                    $itemized_list[ 'L_PAYMENTREQUEST_0_NAME' . $item_num ] = mb_strcut(
468
-                        $gateway_formatter->formatLineItemName($line_item, $payment),
469
-                        0,
470
-                        127
471
-                    );
472
-                    // Item description.
473
-                    $itemized_list[ 'L_PAYMENTREQUEST_0_DESC' . $item_num ] = mb_strcut(
474
-                        $gateway_formatter->formatLineItemDesc($line_item, $payment),
475
-                        0,
476
-                        127
477
-                    );
478
-                    // Cost of individual item.
479
-                    $itemized_list[ 'L_PAYMENTREQUEST_0_AMT' . $item_num ] = $gateway_formatter->formatCurrency($unit_price);
480
-                    // Item Number.
481
-                    $itemized_list[ 'L_PAYMENTREQUEST_0_NUMBER' . $item_num ] = $item_num + 1;
482
-                    // Item quantity.
483
-                    $itemized_list[ 'L_PAYMENTREQUEST_0_QTY' . $item_num ] = $line_item_quantity;
484
-                    // Digital item is sold.
485
-                    $itemized_list[ 'L_PAYMENTREQUEST_0_ITEMCATEGORY' . $item_num ] = 'Physical';
486
-                    $itemized_sum += $line_item->total();
487
-                    ++$item_num;
488
-                }
489
-            }
490
-            // Item's sales S/H and tax amount.
491
-            $itemized_list['PAYMENTREQUEST_0_ITEMAMT'] = $total_line_items->get_items_total();
492
-            $itemized_list['PAYMENTREQUEST_0_TAXAMT'] = $total_line_items->get_total_tax();
493
-            $itemized_list['PAYMENTREQUEST_0_SHIPPINGAMT'] = '0';
494
-            $itemized_list['PAYMENTREQUEST_0_HANDLINGAMT'] = '0';
495
-            $itemized_sum_diff_from_txn_total = round(
496
-                $transaction->total() - $itemized_sum - $total_line_items->get_total_tax(),
497
-                2
498
-            );
499
-            // If we were not able to recognize some item like promotion, surcharge or cancellation,
500
-            // add the difference as an extra line item.
501
-            if ($this->_money->compare_floats($itemized_sum_diff_from_txn_total, 0, '!=')) {
502
-                // Item Name.
503
-                $itemized_list[ 'L_PAYMENTREQUEST_0_NAME' . $item_num ] = mb_strcut(
504
-                    esc_html__(
505
-                        'Other (promotion/surcharge/cancellation)',
506
-                        'event_espresso'
507
-                    ),
508
-                    0,
509
-                    127
510
-                );
511
-                // Item description.
512
-                $itemized_list[ 'L_PAYMENTREQUEST_0_DESC' . $item_num ] = '';
513
-                // Cost of individual item.
514
-                $itemized_list[ 'L_PAYMENTREQUEST_0_AMT' . $item_num ] = $gateway_formatter->formatCurrency(
515
-                    $itemized_sum_diff_from_txn_total
516
-                );
517
-                // Item Number.
518
-                $itemized_list[ 'L_PAYMENTREQUEST_0_NUMBER' . $item_num ] = $item_num + 1;
519
-                // Item quantity.
520
-                $itemized_list[ 'L_PAYMENTREQUEST_0_QTY' . $item_num ] = 1;
521
-                // Digital item is sold.
522
-                $itemized_list[ 'L_PAYMENTREQUEST_0_ITEMCATEGORY' . $item_num ] = 'Physical';
523
-                $item_num++;
524
-            }
525
-        } else {
526
-            // Just one Item.
527
-            // Item Name.
528
-            $itemized_list['L_PAYMENTREQUEST_0_NAME0'] = mb_strcut(
529
-                $gateway_formatter->formatPartialPaymentLineItemName($payment),
530
-                0,
531
-                127
532
-            );
533
-            // Item description.
534
-            $itemized_list['L_PAYMENTREQUEST_0_DESC0'] = mb_strcut(
535
-                $gateway_formatter->formatPartialPaymentLineItemDesc($payment),
536
-                0,
537
-                127
538
-            );
539
-            // Cost of individual item.
540
-            $itemized_list['L_PAYMENTREQUEST_0_AMT0'] = $gateway_formatter->formatCurrency($payment->amount());
541
-            // Item Number.
542
-            $itemized_list['L_PAYMENTREQUEST_0_NUMBER0'] = 1;
543
-            // Item quantity.
544
-            $itemized_list['L_PAYMENTREQUEST_0_QTY0'] = 1;
545
-            // Digital item is sold.
546
-            $itemized_list['L_PAYMENTREQUEST_0_ITEMCATEGORY0'] = 'Physical';
547
-            // Item's sales S/H and tax amount.
548
-            $itemized_list['PAYMENTREQUEST_0_ITEMAMT'] = $gateway_formatter->formatCurrency($payment->amount());
549
-            $itemized_list['PAYMENTREQUEST_0_TAXAMT'] = '0';
550
-            $itemized_list['PAYMENTREQUEST_0_SHIPPINGAMT'] = '0';
551
-            $itemized_list['PAYMENTREQUEST_0_HANDLINGAMT'] = '0';
552
-        }
553
-        return $itemized_list;
554
-    }
555
-
556
-
557
-
558
-    /**
559
-     *  Make the Express checkout request.
560
-     *
561
-     * @param array       $request_params
562
-     * @param string      $request_text
563
-     * @param EEI_Payment $payment
564
-     * @return mixed
565
-     */
566
-    public function _ppExpress_request($request_params, $request_text, $payment)
567
-    {
568
-        $request_dtls = array(
569
-            'VERSION' => '204.0',
570
-            'USER' => $this->_api_username,
571
-            'PWD' => $this->_api_password,
572
-            'SIGNATURE' => $this->_api_signature,
573
-            // EE will blow up if you change this
574
-            'BUTTONSOURCE' => 'EventEspresso_SP',
575
-        );
576
-        $dtls = array_merge($request_dtls, $request_params);
577
-        $this->_log_clean_request($dtls, $payment, $request_text . ' Request');
578
-        // Request Customer Details.
579
-        $request_response = wp_remote_post(
580
-            $this->_base_gateway_url,
581
-            array(
582
-                'method'      => 'POST',
583
-                'timeout'     => 45,
584
-                'httpversion' => '1.1',
585
-                'cookies'     => array(),
586
-                'headers'     => array(),
587
-                'body'        => http_build_query($dtls, '', '&'),
588
-            )
589
-        );
590
-        // Log the response.
591
-        $this->log(array($request_text . ' Response' => $request_response), $payment);
592
-        return $request_response;
593
-    }
594
-
595
-
596
-
597
-    /**
598
-     *  Check the response status.
599
-     *
600
-     * @param mixed $request_response
601
-     * @return array
602
-     */
603
-    public function _ppExpress_check_response($request_response)
604
-    {
605
-        if (is_wp_error($request_response) || empty($request_response['body'])) {
606
-            // If we got here then there was an error in this request.
607
-            return array('status' => false, 'args' => $request_response);
608
-        }
609
-        $response_args = array();
610
-        parse_str(urldecode($request_response['body']), $response_args);
611
-        if (! isset($response_args['ACK'])) {
612
-            return array('status' => false, 'args' => $request_response);
613
-        }
614
-        if (
615
-            (
616
-                isset($response_args['PAYERID'])
617
-                || isset($response_args['TOKEN'])
618
-                || isset($response_args['PAYMENTINFO_0_TRANSACTIONID'])
619
-                || (isset($response_args['PAYMENTSTATUS']) && $response_args['PAYMENTSTATUS'] === 'Completed')
620
-            )
621
-            && in_array($response_args['ACK'], array('Success', 'SuccessWithWarning'), true)
622
-        ) {
623
-            // Response status OK, return response parameters for further processing.
624
-            return array('status' => true, 'args' => $response_args);
625
-        }
626
-        $errors = $this->_get_errors($response_args);
627
-        return array('status' => false, 'args' => $errors);
628
-    }
629
-
630
-
631
-
632
-    /**
633
-     *  Log a "Cleared" request.
634
-     *
635
-     * @param array       $request
636
-     * @param EEI_Payment $payment
637
-     * @param string      $info
638
-     * @return void
639
-     */
640
-    private function _log_clean_request($request, $payment, $info)
641
-    {
642
-        $cleaned_request_data = $request;
643
-        unset($cleaned_request_data['PWD'], $cleaned_request_data['USER'], $cleaned_request_data['SIGNATURE']);
644
-        $this->log(array($info => $cleaned_request_data), $payment);
645
-    }
646
-
647
-
648
-
649
-    /**
650
-     *  Get error from the response data.
651
-     *
652
-     * @param array $data_array
653
-     * @return array
654
-     */
655
-    private function _get_errors($data_array)
656
-    {
657
-        $errors = array();
658
-        $n = 0;
659
-        while (isset($data_array[ "L_ERRORCODE{$n}" ])) {
660
-            $l_error_code = isset($data_array[ "L_ERRORCODE{$n}" ])
661
-                ? $data_array[ "L_ERRORCODE{$n}" ]
662
-                : '';
663
-            $l_severity_code = isset($data_array[ "L_SEVERITYCODE{$n}" ])
664
-                ? $data_array[ "L_SEVERITYCODE{$n}" ]
665
-                : '';
666
-            $l_short_message = isset($data_array[ "L_SHORTMESSAGE{$n}" ])
667
-                ? $data_array[ "L_SHORTMESSAGE{$n}" ]
668
-                : '';
669
-            $l_long_message = isset($data_array[ "L_LONGMESSAGE{$n}" ])
670
-                ? $data_array[ "L_LONGMESSAGE{$n}" ]
671
-                : '';
672
-            if ($n === 0) {
673
-                $errors = array(
674
-                    'L_ERRORCODE'    => $l_error_code,
675
-                    'L_SHORTMESSAGE' => $l_short_message,
676
-                    'L_LONGMESSAGE'  => $l_long_message,
677
-                    'L_SEVERITYCODE' => $l_severity_code,
678
-                );
679
-            } else {
680
-                $errors['L_ERRORCODE'] .= ', ' . $l_error_code;
681
-                $errors['L_SHORTMESSAGE'] .= ', ' . $l_short_message;
682
-                $errors['L_LONGMESSAGE'] .= ', ' . $l_long_message;
683
-                $errors['L_SEVERITYCODE'] .= ', ' . $l_severity_code;
684
-            }
685
-            $n++;
686
-        }
687
-        return $errors;
688
-    }
32
+	/**
33
+	 * Merchant API Username.
34
+	 *
35
+	 * @var string
36
+	 */
37
+	protected $_api_username;
38
+
39
+	/**
40
+	 * Merchant API Password.
41
+	 *
42
+	 * @var string
43
+	 */
44
+	protected $_api_password;
45
+
46
+	/**
47
+	 * API Signature.
48
+	 *
49
+	 * @var string
50
+	 */
51
+	protected $_api_signature;
52
+
53
+	/**
54
+	 * Request Shipping address on PP checkout page.
55
+	 *
56
+	 * @var string
57
+	 */
58
+	protected $_request_shipping_addr;
59
+
60
+	/**
61
+	 * Business/personal logo.
62
+	 *
63
+	 * @var string
64
+	 */
65
+	protected $_image_url;
66
+
67
+	/**
68
+	 * gateway URL variable
69
+	 *
70
+	 * @var string
71
+	 */
72
+	protected $_base_gateway_url = '';
73
+
74
+
75
+
76
+	/**
77
+	 * EEG_Paypal_Express constructor.
78
+	 */
79
+	public function __construct()
80
+	{
81
+		$this->_currencies_supported = array(
82
+			'USD',
83
+			'AUD',
84
+			'BRL',
85
+			'CAD',
86
+			'CZK',
87
+			'DKK',
88
+			'EUR',
89
+			'HKD',
90
+			'HUF',
91
+			'ILS',
92
+			'JPY',
93
+			'MYR',
94
+			'MXN',
95
+			'NOK',
96
+			'NZD',
97
+			'PHP',
98
+			'PLN',
99
+			'GBP',
100
+			'RUB',
101
+			'SGD',
102
+			'SEK',
103
+			'CHF',
104
+			'TWD',
105
+			'THB',
106
+			'TRY',
107
+			'INR',
108
+		);
109
+		parent::__construct();
110
+	}
111
+
112
+
113
+
114
+	/**
115
+	 * Sets the gateway URL variable based on whether debug mode is enabled or not.
116
+	 *
117
+	 * @param array $settings_array
118
+	 */
119
+	public function set_settings($settings_array)
120
+	{
121
+		parent::set_settings($settings_array);
122
+		// Redirect URL.
123
+		$this->_base_gateway_url = $this->_debug_mode
124
+			? 'https://api-3t.sandbox.paypal.com/nvp'
125
+			: 'https://api-3t.paypal.com/nvp';
126
+	}
127
+
128
+
129
+
130
+	/**
131
+	 * @param EEI_Payment $payment
132
+	 * @param array       $billing_info
133
+	 * @param string      $return_url
134
+	 * @param string      $notify_url
135
+	 * @param string      $cancel_url
136
+	 * @return \EE_Payment|\EEI_Payment
137
+	 * @throws \EE_Error
138
+	 */
139
+	public function set_redirection_info(
140
+		$payment,
141
+		$billing_info = array(),
142
+		$return_url = null,
143
+		$notify_url = null,
144
+		$cancel_url = null
145
+	) {
146
+		if (! $payment instanceof EEI_Payment) {
147
+			$payment->set_gateway_response(
148
+				esc_html__(
149
+					'Error. No associated payment was found.',
150
+					'event_espresso'
151
+				)
152
+			);
153
+			$payment->set_status($this->_pay_model->failed_status());
154
+			return $payment;
155
+		}
156
+		$transaction = $payment->transaction();
157
+		if (! $transaction instanceof EEI_Transaction) {
158
+			$payment->set_gateway_response(
159
+				esc_html__(
160
+					'Could not process this payment because it has no associated transaction.',
161
+					'event_espresso'
162
+				)
163
+			);
164
+			$payment->set_status($this->_pay_model->failed_status());
165
+			return $payment;
166
+		}
167
+		$gateway_formatter = $this->_get_gateway_formatter();
168
+		$order_description = mb_strcut($gateway_formatter->formatOrderDescription($payment), 0, 127);
169
+		$primary_registration = $transaction->primary_registration();
170
+		$primary_attendee = $primary_registration instanceof EE_Registration
171
+			? $primary_registration->attendee()
172
+			: false;
173
+		$locale = explode('-', get_bloginfo('language'));
174
+		// Gather request parameters.
175
+		$token_request_dtls = array(
176
+			'METHOD'                         => 'SetExpressCheckout',
177
+			'PAYMENTREQUEST_0_AMT'           => $payment->amount(),
178
+			'PAYMENTREQUEST_0_CURRENCYCODE'  => $payment->currency_code(),
179
+			'PAYMENTREQUEST_0_DESC'          => $order_description,
180
+			'RETURNURL'                      => $return_url,
181
+			'CANCELURL'                      => $cancel_url,
182
+			'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale',
183
+			// Buyer does not need to create a PayPal account to check out.
184
+			// This is referred to as PayPal Account Optional.
185
+			'SOLUTIONTYPE'                   => 'Sole',
186
+			// Locale of the pages displayed by PayPal during Express Checkout.
187
+			'LOCALECODE'                     => $locale[1]
188
+		);
189
+		// Show itemized list.
190
+		$itemized_list = $this->itemize_list($payment, $transaction);
191
+		$token_request_dtls = array_merge($token_request_dtls, $itemized_list);
192
+		// Automatically filling out shipping and contact information.
193
+		if ($this->_request_shipping_addr && $primary_attendee instanceof EEI_Attendee) {
194
+			// If you do not pass the shipping address, PayPal obtains it from the buyer's account profile.
195
+			$token_request_dtls['NOSHIPPING'] = '2';
196
+			$token_request_dtls['PAYMENTREQUEST_0_SHIPTOSTREET'] = $primary_attendee->address();
197
+			$token_request_dtls['PAYMENTREQUEST_0_SHIPTOSTREET2'] = $primary_attendee->address2();
198
+			$token_request_dtls['PAYMENTREQUEST_0_SHIPTOCITY'] = $primary_attendee->city();
199
+			$token_request_dtls['PAYMENTREQUEST_0_SHIPTOSTATE'] = $primary_attendee->state_abbrev();
200
+			$token_request_dtls['PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE'] = $primary_attendee->country_ID();
201
+			$token_request_dtls['PAYMENTREQUEST_0_SHIPTOZIP'] = $primary_attendee->zip();
202
+			$token_request_dtls['PAYMENTREQUEST_0_EMAIL'] = $primary_attendee->email();
203
+			$token_request_dtls['PAYMENTREQUEST_0_SHIPTOPHONENUM'] = $primary_attendee->phone();
204
+		} elseif (! $this->_request_shipping_addr) {
205
+			// Do not request shipping details on the PP Checkout page.
206
+			$token_request_dtls['NOSHIPPING'] = '1';
207
+			$token_request_dtls['REQCONFIRMSHIPPING'] = '0';
208
+		}
209
+		// Used a business/personal logo on the PayPal page.
210
+		if (! empty($this->_image_url)) {
211
+			$token_request_dtls['LOGOIMG'] = $this->_image_url;
212
+		}
213
+		$token_request_dtls = apply_filters(
214
+			'FHEE__EEG_Paypal_Express__set_redirection_info__arguments',
215
+			$token_request_dtls,
216
+			$this
217
+		);
218
+		// Request PayPal token.
219
+		$token_request_response = $this->_ppExpress_request($token_request_dtls, 'Payment Token', $payment);
220
+		$token_rstatus = $this->_ppExpress_check_response($token_request_response);
221
+		$response_args = (isset($token_rstatus['args']) && is_array($token_rstatus['args']))
222
+			? $token_rstatus['args']
223
+			: array();
224
+		if ($token_rstatus['status']) {
225
+			// We got the Token so we may continue with the payment and redirect the client.
226
+			$payment->set_details($response_args);
227
+			$gateway_url = $this->_debug_mode ? 'https://www.sandbox.paypal.com' : 'https://www.paypal.com';
228
+			$payment->set_redirect_url(
229
+				$gateway_url
230
+				. '/checkoutnow?useraction=commit&cmd=_express-checkout&token='
231
+				. $response_args['TOKEN']
232
+			);
233
+		} else {
234
+			if (isset($response_args['L_ERRORCODE'])) {
235
+				$payment->set_gateway_response($response_args['L_ERRORCODE'] . '; ' . $response_args['L_SHORTMESSAGE']);
236
+			} else {
237
+				$payment->set_gateway_response(
238
+					esc_html__(
239
+						'Error occurred while trying to setup the Express Checkout.',
240
+						'event_espresso'
241
+					)
242
+				);
243
+			}
244
+			$payment->set_details($response_args);
245
+			$payment->set_status($this->_pay_model->failed_status());
246
+		}
247
+		return $payment;
248
+	}
249
+
250
+
251
+
252
+	/**
253
+	 * @param array           $update_info {
254
+	 * @type string           $gateway_txn_id
255
+	 * @type string status an EEMI_Payment status
256
+	 *                                     }
257
+	 * @param EEI_Transaction $transaction
258
+	 * @return EEI_Payment
259
+	 */
260
+	public function handle_payment_update($update_info, $transaction)
261
+	{
262
+		$payment = $transaction instanceof EEI_Transaction ? $transaction->last_payment() : null;
263
+		if ($payment instanceof EEI_Payment) {
264
+			$this->log(array('Return from Authorization' => $update_info), $payment);
265
+			$transaction = $payment->transaction();
266
+			if (! $transaction instanceof EEI_Transaction) {
267
+				$payment->set_gateway_response(
268
+					esc_html__(
269
+						'Could not process this payment because it has no associated transaction.',
270
+						'event_espresso'
271
+					)
272
+				);
273
+				$payment->set_status($this->_pay_model->failed_status());
274
+				return $payment;
275
+			}
276
+			$primary_registrant = $transaction->primary_registration();
277
+			$payment_details = $payment->details();
278
+			// Check if we still have the token.
279
+			if (! isset($payment_details['TOKEN']) || empty($payment_details['TOKEN'])) {
280
+				$payment->set_status($this->_pay_model->failed_status());
281
+				return $payment;
282
+			}
283
+			$cdetails_request_dtls = array(
284
+				'METHOD' => 'GetExpressCheckoutDetails',
285
+				'TOKEN'  => $payment_details['TOKEN'],
286
+			);
287
+			// Request Customer Details.
288
+			$cdetails_request_response = $this->_ppExpress_request(
289
+				$cdetails_request_dtls,
290
+				'Customer Details',
291
+				$payment
292
+			);
293
+			$cdetails_rstatus = $this->_ppExpress_check_response($cdetails_request_response);
294
+			$cdata_response_args = (isset($cdetails_rstatus['args']) && is_array($cdetails_rstatus['args']))
295
+				? $cdetails_rstatus['args']
296
+				: array();
297
+			if ($cdetails_rstatus['status']) {
298
+				// We got the PayerID so now we can Complete the transaction.
299
+				$docheckout_request_dtls = array(
300
+					'METHOD'                         => 'DoExpressCheckoutPayment',
301
+					'PAYERID'                        => $cdata_response_args['PAYERID'],
302
+					'TOKEN'                          => $payment_details['TOKEN'],
303
+					'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale',
304
+					'PAYMENTREQUEST_0_AMT'           => $payment->amount(),
305
+					'PAYMENTREQUEST_0_CURRENCYCODE'  => $payment->currency_code(),
306
+				);
307
+				 // Include itemized list.
308
+				$itemized_list = $this->itemize_list(
309
+					$payment,
310
+					$transaction,
311
+					$cdata_response_args
312
+				);
313
+				$docheckout_request_dtls = array_merge($docheckout_request_dtls, $itemized_list);
314
+				// Payment Checkout/Capture.
315
+				$docheckout_request_response = $this->_ppExpress_request(
316
+					$docheckout_request_dtls,
317
+					'Do Payment',
318
+					$payment
319
+				);
320
+				$docheckout_rstatus = $this->_ppExpress_check_response($docheckout_request_response);
321
+				$docheckout_response_args = (isset($docheckout_rstatus['args']) && is_array($docheckout_rstatus['args']))
322
+					? $docheckout_rstatus['args']
323
+					: array();
324
+				if ($docheckout_rstatus['status']) {
325
+					// All is well, payment approved.
326
+					$primary_registration_code = $primary_registrant instanceof EE_Registration ?
327
+						$primary_registrant->reg_code()
328
+						: '';
329
+					$payment->set_extra_accntng($primary_registration_code);
330
+					$payment->set_amount(isset($docheckout_response_args['PAYMENTINFO_0_AMT'])
331
+						? (float) $docheckout_response_args['PAYMENTINFO_0_AMT']
332
+						: 0);
333
+					$payment->set_txn_id_chq_nmbr(isset($docheckout_response_args['PAYMENTINFO_0_TRANSACTIONID'])
334
+						? $docheckout_response_args['PAYMENTINFO_0_TRANSACTIONID']
335
+						: null);
336
+					$payment->set_details($cdata_response_args);
337
+					$payment->set_gateway_response(isset($docheckout_response_args['PAYMENTINFO_0_ACK'])
338
+						? $docheckout_response_args['PAYMENTINFO_0_ACK']
339
+						: '');
340
+					$payment->set_status($this->_pay_model->approved_status());
341
+				} else {
342
+					if (isset($docheckout_response_args['L_ERRORCODE'])) {
343
+						$payment->set_gateway_response(
344
+							$docheckout_response_args['L_ERRORCODE']
345
+							. '; '
346
+							. $docheckout_response_args['L_SHORTMESSAGE']
347
+						);
348
+					} else {
349
+						$payment->set_gateway_response(
350
+							esc_html__(
351
+								'Error occurred while trying to Capture the funds.',
352
+								'event_espresso'
353
+							)
354
+						);
355
+					}
356
+					$payment->set_details($docheckout_response_args);
357
+					$payment->set_status($this->_pay_model->declined_status());
358
+				}
359
+			} else {
360
+				if (isset($cdata_response_args['L_ERRORCODE'])) {
361
+					$payment->set_gateway_response(
362
+						$cdata_response_args['L_ERRORCODE']
363
+						. '; '
364
+						. $cdata_response_args['L_SHORTMESSAGE']
365
+					);
366
+				} else {
367
+					$payment->set_gateway_response(
368
+						esc_html__(
369
+							'Error occurred while trying to get payment Details from PayPal.',
370
+							'event_espresso'
371
+						)
372
+					);
373
+				}
374
+				$payment->set_details($cdata_response_args);
375
+				$payment->set_status($this->_pay_model->failed_status());
376
+			}
377
+		} else {
378
+			$payment->set_gateway_response(
379
+				esc_html__(
380
+					'Error occurred while trying to process the payment.',
381
+					'event_espresso'
382
+				)
383
+			);
384
+			$payment->set_status($this->_pay_model->failed_status());
385
+		}
386
+		return $payment;
387
+	}
388
+
389
+
390
+
391
+	/**
392
+	 *  Make a list of items that are in the giver transaction.
393
+	 *
394
+	 * @param EEI_Payment     $payment
395
+	 * @param EEI_Transaction $transaction
396
+	 * @param array           $request_response_args Data from a previous communication with PP.
397
+	 * @return array
398
+	 */
399
+	public function itemize_list(EEI_Payment $payment, EEI_Transaction $transaction, $request_response_args = array())
400
+	{
401
+		$itemized_list = array();
402
+		$gateway_formatter = $this->_get_gateway_formatter();
403
+		// If we have data from a previous communication with PP (on this transaction) we may use that for our list...
404
+		if (
405
+			! empty($request_response_args)
406
+			&& array_key_exists('L_PAYMENTREQUEST_0_AMT0', $request_response_args)
407
+			&& array_key_exists('PAYMENTREQUEST_0_ITEMAMT', $request_response_args)
408
+		) {
409
+			foreach ($request_response_args as $arg_key => $arg_val) {
410
+				if (
411
+					strpos($arg_key, 'PAYMENTREQUEST_') !== false
412
+					&& strpos($arg_key, 'NOTIFYURL') === false
413
+				) {
414
+					$itemized_list[ $arg_key ] = $arg_val;
415
+				}
416
+			}
417
+			// If we got only a few Items then something is not right.
418
+			if (count($itemized_list) > 2) {
419
+				return $itemized_list;
420
+			} else {
421
+				if (WP_DEBUG) {
422
+					throw new EE_Error(
423
+						sprintf(
424
+							esc_html__(
425
+								// @codingStandardsIgnoreStart
426
+								'Unable to continue with the checkout because a proper purchase list could not be generated. The purchased list we could have sent was %1$s',
427
+								// @codingStandardsIgnoreEnd
428
+								'event_espresso'
429
+							),
430
+							wp_json_encode($itemized_list)
431
+						)
432
+					);
433
+				}
434
+				// Reset the list and log an error, maybe allow to try and generate a new list (below).
435
+				$itemized_list = array();
436
+				$this->log(
437
+					array(
438
+						(string) esc_html__(
439
+							'Could not generate a proper item list with:',
440
+							'event_espresso'
441
+						) => $request_response_args
442
+					),
443
+					$payment
444
+				);
445
+			}
446
+		}
447
+		// ...otherwise we generate a new list for this transaction.
448
+		if ($this->_money->compare_floats($payment->amount(), $transaction->total(), '==')) {
449
+			$item_num = 0;
450
+			$itemized_sum = 0;
451
+			$total_line_items = $transaction->total_line_item();
452
+			// Go through each item in the list.
453
+			foreach ($total_line_items->get_items() as $line_item) {
454
+				if ($line_item instanceof EE_Line_Item) {
455
+					// PayPal doesn't like line items with 0.00 amount, so we may skip those.
456
+					if (EEH_Money::compare_floats($line_item->total(), '0.00', '==')) {
457
+						continue;
458
+					}
459
+					$unit_price = $line_item->unit_price();
460
+					$line_item_quantity = $line_item->quantity();
461
+					// This is a discount.
462
+					if ($line_item->is_percent()) {
463
+						$unit_price = $line_item->total();
464
+						$line_item_quantity = 1;
465
+					}
466
+					// Item Name.
467
+					$itemized_list[ 'L_PAYMENTREQUEST_0_NAME' . $item_num ] = mb_strcut(
468
+						$gateway_formatter->formatLineItemName($line_item, $payment),
469
+						0,
470
+						127
471
+					);
472
+					// Item description.
473
+					$itemized_list[ 'L_PAYMENTREQUEST_0_DESC' . $item_num ] = mb_strcut(
474
+						$gateway_formatter->formatLineItemDesc($line_item, $payment),
475
+						0,
476
+						127
477
+					);
478
+					// Cost of individual item.
479
+					$itemized_list[ 'L_PAYMENTREQUEST_0_AMT' . $item_num ] = $gateway_formatter->formatCurrency($unit_price);
480
+					// Item Number.
481
+					$itemized_list[ 'L_PAYMENTREQUEST_0_NUMBER' . $item_num ] = $item_num + 1;
482
+					// Item quantity.
483
+					$itemized_list[ 'L_PAYMENTREQUEST_0_QTY' . $item_num ] = $line_item_quantity;
484
+					// Digital item is sold.
485
+					$itemized_list[ 'L_PAYMENTREQUEST_0_ITEMCATEGORY' . $item_num ] = 'Physical';
486
+					$itemized_sum += $line_item->total();
487
+					++$item_num;
488
+				}
489
+			}
490
+			// Item's sales S/H and tax amount.
491
+			$itemized_list['PAYMENTREQUEST_0_ITEMAMT'] = $total_line_items->get_items_total();
492
+			$itemized_list['PAYMENTREQUEST_0_TAXAMT'] = $total_line_items->get_total_tax();
493
+			$itemized_list['PAYMENTREQUEST_0_SHIPPINGAMT'] = '0';
494
+			$itemized_list['PAYMENTREQUEST_0_HANDLINGAMT'] = '0';
495
+			$itemized_sum_diff_from_txn_total = round(
496
+				$transaction->total() - $itemized_sum - $total_line_items->get_total_tax(),
497
+				2
498
+			);
499
+			// If we were not able to recognize some item like promotion, surcharge or cancellation,
500
+			// add the difference as an extra line item.
501
+			if ($this->_money->compare_floats($itemized_sum_diff_from_txn_total, 0, '!=')) {
502
+				// Item Name.
503
+				$itemized_list[ 'L_PAYMENTREQUEST_0_NAME' . $item_num ] = mb_strcut(
504
+					esc_html__(
505
+						'Other (promotion/surcharge/cancellation)',
506
+						'event_espresso'
507
+					),
508
+					0,
509
+					127
510
+				);
511
+				// Item description.
512
+				$itemized_list[ 'L_PAYMENTREQUEST_0_DESC' . $item_num ] = '';
513
+				// Cost of individual item.
514
+				$itemized_list[ 'L_PAYMENTREQUEST_0_AMT' . $item_num ] = $gateway_formatter->formatCurrency(
515
+					$itemized_sum_diff_from_txn_total
516
+				);
517
+				// Item Number.
518
+				$itemized_list[ 'L_PAYMENTREQUEST_0_NUMBER' . $item_num ] = $item_num + 1;
519
+				// Item quantity.
520
+				$itemized_list[ 'L_PAYMENTREQUEST_0_QTY' . $item_num ] = 1;
521
+				// Digital item is sold.
522
+				$itemized_list[ 'L_PAYMENTREQUEST_0_ITEMCATEGORY' . $item_num ] = 'Physical';
523
+				$item_num++;
524
+			}
525
+		} else {
526
+			// Just one Item.
527
+			// Item Name.
528
+			$itemized_list['L_PAYMENTREQUEST_0_NAME0'] = mb_strcut(
529
+				$gateway_formatter->formatPartialPaymentLineItemName($payment),
530
+				0,
531
+				127
532
+			);
533
+			// Item description.
534
+			$itemized_list['L_PAYMENTREQUEST_0_DESC0'] = mb_strcut(
535
+				$gateway_formatter->formatPartialPaymentLineItemDesc($payment),
536
+				0,
537
+				127
538
+			);
539
+			// Cost of individual item.
540
+			$itemized_list['L_PAYMENTREQUEST_0_AMT0'] = $gateway_formatter->formatCurrency($payment->amount());
541
+			// Item Number.
542
+			$itemized_list['L_PAYMENTREQUEST_0_NUMBER0'] = 1;
543
+			// Item quantity.
544
+			$itemized_list['L_PAYMENTREQUEST_0_QTY0'] = 1;
545
+			// Digital item is sold.
546
+			$itemized_list['L_PAYMENTREQUEST_0_ITEMCATEGORY0'] = 'Physical';
547
+			// Item's sales S/H and tax amount.
548
+			$itemized_list['PAYMENTREQUEST_0_ITEMAMT'] = $gateway_formatter->formatCurrency($payment->amount());
549
+			$itemized_list['PAYMENTREQUEST_0_TAXAMT'] = '0';
550
+			$itemized_list['PAYMENTREQUEST_0_SHIPPINGAMT'] = '0';
551
+			$itemized_list['PAYMENTREQUEST_0_HANDLINGAMT'] = '0';
552
+		}
553
+		return $itemized_list;
554
+	}
555
+
556
+
557
+
558
+	/**
559
+	 *  Make the Express checkout request.
560
+	 *
561
+	 * @param array       $request_params
562
+	 * @param string      $request_text
563
+	 * @param EEI_Payment $payment
564
+	 * @return mixed
565
+	 */
566
+	public function _ppExpress_request($request_params, $request_text, $payment)
567
+	{
568
+		$request_dtls = array(
569
+			'VERSION' => '204.0',
570
+			'USER' => $this->_api_username,
571
+			'PWD' => $this->_api_password,
572
+			'SIGNATURE' => $this->_api_signature,
573
+			// EE will blow up if you change this
574
+			'BUTTONSOURCE' => 'EventEspresso_SP',
575
+		);
576
+		$dtls = array_merge($request_dtls, $request_params);
577
+		$this->_log_clean_request($dtls, $payment, $request_text . ' Request');
578
+		// Request Customer Details.
579
+		$request_response = wp_remote_post(
580
+			$this->_base_gateway_url,
581
+			array(
582
+				'method'      => 'POST',
583
+				'timeout'     => 45,
584
+				'httpversion' => '1.1',
585
+				'cookies'     => array(),
586
+				'headers'     => array(),
587
+				'body'        => http_build_query($dtls, '', '&'),
588
+			)
589
+		);
590
+		// Log the response.
591
+		$this->log(array($request_text . ' Response' => $request_response), $payment);
592
+		return $request_response;
593
+	}
594
+
595
+
596
+
597
+	/**
598
+	 *  Check the response status.
599
+	 *
600
+	 * @param mixed $request_response
601
+	 * @return array
602
+	 */
603
+	public function _ppExpress_check_response($request_response)
604
+	{
605
+		if (is_wp_error($request_response) || empty($request_response['body'])) {
606
+			// If we got here then there was an error in this request.
607
+			return array('status' => false, 'args' => $request_response);
608
+		}
609
+		$response_args = array();
610
+		parse_str(urldecode($request_response['body']), $response_args);
611
+		if (! isset($response_args['ACK'])) {
612
+			return array('status' => false, 'args' => $request_response);
613
+		}
614
+		if (
615
+			(
616
+				isset($response_args['PAYERID'])
617
+				|| isset($response_args['TOKEN'])
618
+				|| isset($response_args['PAYMENTINFO_0_TRANSACTIONID'])
619
+				|| (isset($response_args['PAYMENTSTATUS']) && $response_args['PAYMENTSTATUS'] === 'Completed')
620
+			)
621
+			&& in_array($response_args['ACK'], array('Success', 'SuccessWithWarning'), true)
622
+		) {
623
+			// Response status OK, return response parameters for further processing.
624
+			return array('status' => true, 'args' => $response_args);
625
+		}
626
+		$errors = $this->_get_errors($response_args);
627
+		return array('status' => false, 'args' => $errors);
628
+	}
629
+
630
+
631
+
632
+	/**
633
+	 *  Log a "Cleared" request.
634
+	 *
635
+	 * @param array       $request
636
+	 * @param EEI_Payment $payment
637
+	 * @param string      $info
638
+	 * @return void
639
+	 */
640
+	private function _log_clean_request($request, $payment, $info)
641
+	{
642
+		$cleaned_request_data = $request;
643
+		unset($cleaned_request_data['PWD'], $cleaned_request_data['USER'], $cleaned_request_data['SIGNATURE']);
644
+		$this->log(array($info => $cleaned_request_data), $payment);
645
+	}
646
+
647
+
648
+
649
+	/**
650
+	 *  Get error from the response data.
651
+	 *
652
+	 * @param array $data_array
653
+	 * @return array
654
+	 */
655
+	private function _get_errors($data_array)
656
+	{
657
+		$errors = array();
658
+		$n = 0;
659
+		while (isset($data_array[ "L_ERRORCODE{$n}" ])) {
660
+			$l_error_code = isset($data_array[ "L_ERRORCODE{$n}" ])
661
+				? $data_array[ "L_ERRORCODE{$n}" ]
662
+				: '';
663
+			$l_severity_code = isset($data_array[ "L_SEVERITYCODE{$n}" ])
664
+				? $data_array[ "L_SEVERITYCODE{$n}" ]
665
+				: '';
666
+			$l_short_message = isset($data_array[ "L_SHORTMESSAGE{$n}" ])
667
+				? $data_array[ "L_SHORTMESSAGE{$n}" ]
668
+				: '';
669
+			$l_long_message = isset($data_array[ "L_LONGMESSAGE{$n}" ])
670
+				? $data_array[ "L_LONGMESSAGE{$n}" ]
671
+				: '';
672
+			if ($n === 0) {
673
+				$errors = array(
674
+					'L_ERRORCODE'    => $l_error_code,
675
+					'L_SHORTMESSAGE' => $l_short_message,
676
+					'L_LONGMESSAGE'  => $l_long_message,
677
+					'L_SEVERITYCODE' => $l_severity_code,
678
+				);
679
+			} else {
680
+				$errors['L_ERRORCODE'] .= ', ' . $l_error_code;
681
+				$errors['L_SHORTMESSAGE'] .= ', ' . $l_short_message;
682
+				$errors['L_LONGMESSAGE'] .= ', ' . $l_long_message;
683
+				$errors['L_SEVERITYCODE'] .= ', ' . $l_severity_code;
684
+			}
685
+			$n++;
686
+		}
687
+		return $errors;
688
+	}
689 689
 }
Please login to merge, or discard this patch.
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  */
13 13
 
14 14
 // Quickfix to address https://events.codebasehq.com/projects/event-espresso/tickets/11089 ASAP
15
-if (! function_exists('mb_strcut')) {
15
+if ( ! function_exists('mb_strcut')) {
16 16
     /**
17 17
      * Very simple mimic of mb_substr (which WP ensures exists in wp-includes/compat.php). Still has all the problems of mb_substr
18 18
      * (namely, that we might send too many characters to PayPal; however in this case they just issue a warning but nothing breaks)
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
         $notify_url = null,
144 144
         $cancel_url = null
145 145
     ) {
146
-        if (! $payment instanceof EEI_Payment) {
146
+        if ( ! $payment instanceof EEI_Payment) {
147 147
             $payment->set_gateway_response(
148 148
                 esc_html__(
149 149
                     'Error. No associated payment was found.',
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
             return $payment;
155 155
         }
156 156
         $transaction = $payment->transaction();
157
-        if (! $transaction instanceof EEI_Transaction) {
157
+        if ( ! $transaction instanceof EEI_Transaction) {
158 158
             $payment->set_gateway_response(
159 159
                 esc_html__(
160 160
                     'Could not process this payment because it has no associated transaction.',
@@ -201,13 +201,13 @@  discard block
 block discarded – undo
201 201
             $token_request_dtls['PAYMENTREQUEST_0_SHIPTOZIP'] = $primary_attendee->zip();
202 202
             $token_request_dtls['PAYMENTREQUEST_0_EMAIL'] = $primary_attendee->email();
203 203
             $token_request_dtls['PAYMENTREQUEST_0_SHIPTOPHONENUM'] = $primary_attendee->phone();
204
-        } elseif (! $this->_request_shipping_addr) {
204
+        } elseif ( ! $this->_request_shipping_addr) {
205 205
             // Do not request shipping details on the PP Checkout page.
206 206
             $token_request_dtls['NOSHIPPING'] = '1';
207 207
             $token_request_dtls['REQCONFIRMSHIPPING'] = '0';
208 208
         }
209 209
         // Used a business/personal logo on the PayPal page.
210
-        if (! empty($this->_image_url)) {
210
+        if ( ! empty($this->_image_url)) {
211 211
             $token_request_dtls['LOGOIMG'] = $this->_image_url;
212 212
         }
213 213
         $token_request_dtls = apply_filters(
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
             );
233 233
         } else {
234 234
             if (isset($response_args['L_ERRORCODE'])) {
235
-                $payment->set_gateway_response($response_args['L_ERRORCODE'] . '; ' . $response_args['L_SHORTMESSAGE']);
235
+                $payment->set_gateway_response($response_args['L_ERRORCODE'].'; '.$response_args['L_SHORTMESSAGE']);
236 236
             } else {
237 237
                 $payment->set_gateway_response(
238 238
                     esc_html__(
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
         if ($payment instanceof EEI_Payment) {
264 264
             $this->log(array('Return from Authorization' => $update_info), $payment);
265 265
             $transaction = $payment->transaction();
266
-            if (! $transaction instanceof EEI_Transaction) {
266
+            if ( ! $transaction instanceof EEI_Transaction) {
267 267
                 $payment->set_gateway_response(
268 268
                     esc_html__(
269 269
                         'Could not process this payment because it has no associated transaction.',
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
             $primary_registrant = $transaction->primary_registration();
277 277
             $payment_details = $payment->details();
278 278
             // Check if we still have the token.
279
-            if (! isset($payment_details['TOKEN']) || empty($payment_details['TOKEN'])) {
279
+            if ( ! isset($payment_details['TOKEN']) || empty($payment_details['TOKEN'])) {
280 280
                 $payment->set_status($this->_pay_model->failed_status());
281 281
                 return $payment;
282 282
             }
@@ -411,7 +411,7 @@  discard block
 block discarded – undo
411 411
                     strpos($arg_key, 'PAYMENTREQUEST_') !== false
412 412
                     && strpos($arg_key, 'NOTIFYURL') === false
413 413
                 ) {
414
-                    $itemized_list[ $arg_key ] = $arg_val;
414
+                    $itemized_list[$arg_key] = $arg_val;
415 415
                 }
416 416
             }
417 417
             // If we got only a few Items then something is not right.
@@ -464,25 +464,25 @@  discard block
 block discarded – undo
464 464
                         $line_item_quantity = 1;
465 465
                     }
466 466
                     // Item Name.
467
-                    $itemized_list[ 'L_PAYMENTREQUEST_0_NAME' . $item_num ] = mb_strcut(
467
+                    $itemized_list['L_PAYMENTREQUEST_0_NAME'.$item_num] = mb_strcut(
468 468
                         $gateway_formatter->formatLineItemName($line_item, $payment),
469 469
                         0,
470 470
                         127
471 471
                     );
472 472
                     // Item description.
473
-                    $itemized_list[ 'L_PAYMENTREQUEST_0_DESC' . $item_num ] = mb_strcut(
473
+                    $itemized_list['L_PAYMENTREQUEST_0_DESC'.$item_num] = mb_strcut(
474 474
                         $gateway_formatter->formatLineItemDesc($line_item, $payment),
475 475
                         0,
476 476
                         127
477 477
                     );
478 478
                     // Cost of individual item.
479
-                    $itemized_list[ 'L_PAYMENTREQUEST_0_AMT' . $item_num ] = $gateway_formatter->formatCurrency($unit_price);
479
+                    $itemized_list['L_PAYMENTREQUEST_0_AMT'.$item_num] = $gateway_formatter->formatCurrency($unit_price);
480 480
                     // Item Number.
481
-                    $itemized_list[ 'L_PAYMENTREQUEST_0_NUMBER' . $item_num ] = $item_num + 1;
481
+                    $itemized_list['L_PAYMENTREQUEST_0_NUMBER'.$item_num] = $item_num + 1;
482 482
                     // Item quantity.
483
-                    $itemized_list[ 'L_PAYMENTREQUEST_0_QTY' . $item_num ] = $line_item_quantity;
483
+                    $itemized_list['L_PAYMENTREQUEST_0_QTY'.$item_num] = $line_item_quantity;
484 484
                     // Digital item is sold.
485
-                    $itemized_list[ 'L_PAYMENTREQUEST_0_ITEMCATEGORY' . $item_num ] = 'Physical';
485
+                    $itemized_list['L_PAYMENTREQUEST_0_ITEMCATEGORY'.$item_num] = 'Physical';
486 486
                     $itemized_sum += $line_item->total();
487 487
                     ++$item_num;
488 488
                 }
@@ -500,7 +500,7 @@  discard block
 block discarded – undo
500 500
             // add the difference as an extra line item.
501 501
             if ($this->_money->compare_floats($itemized_sum_diff_from_txn_total, 0, '!=')) {
502 502
                 // Item Name.
503
-                $itemized_list[ 'L_PAYMENTREQUEST_0_NAME' . $item_num ] = mb_strcut(
503
+                $itemized_list['L_PAYMENTREQUEST_0_NAME'.$item_num] = mb_strcut(
504 504
                     esc_html__(
505 505
                         'Other (promotion/surcharge/cancellation)',
506 506
                         'event_espresso'
@@ -509,17 +509,17 @@  discard block
 block discarded – undo
509 509
                     127
510 510
                 );
511 511
                 // Item description.
512
-                $itemized_list[ 'L_PAYMENTREQUEST_0_DESC' . $item_num ] = '';
512
+                $itemized_list['L_PAYMENTREQUEST_0_DESC'.$item_num] = '';
513 513
                 // Cost of individual item.
514
-                $itemized_list[ 'L_PAYMENTREQUEST_0_AMT' . $item_num ] = $gateway_formatter->formatCurrency(
514
+                $itemized_list['L_PAYMENTREQUEST_0_AMT'.$item_num] = $gateway_formatter->formatCurrency(
515 515
                     $itemized_sum_diff_from_txn_total
516 516
                 );
517 517
                 // Item Number.
518
-                $itemized_list[ 'L_PAYMENTREQUEST_0_NUMBER' . $item_num ] = $item_num + 1;
518
+                $itemized_list['L_PAYMENTREQUEST_0_NUMBER'.$item_num] = $item_num + 1;
519 519
                 // Item quantity.
520
-                $itemized_list[ 'L_PAYMENTREQUEST_0_QTY' . $item_num ] = 1;
520
+                $itemized_list['L_PAYMENTREQUEST_0_QTY'.$item_num] = 1;
521 521
                 // Digital item is sold.
522
-                $itemized_list[ 'L_PAYMENTREQUEST_0_ITEMCATEGORY' . $item_num ] = 'Physical';
522
+                $itemized_list['L_PAYMENTREQUEST_0_ITEMCATEGORY'.$item_num] = 'Physical';
523 523
                 $item_num++;
524 524
             }
525 525
         } else {
@@ -574,7 +574,7 @@  discard block
 block discarded – undo
574 574
             'BUTTONSOURCE' => 'EventEspresso_SP',
575 575
         );
576 576
         $dtls = array_merge($request_dtls, $request_params);
577
-        $this->_log_clean_request($dtls, $payment, $request_text . ' Request');
577
+        $this->_log_clean_request($dtls, $payment, $request_text.' Request');
578 578
         // Request Customer Details.
579 579
         $request_response = wp_remote_post(
580 580
             $this->_base_gateway_url,
@@ -588,7 +588,7 @@  discard block
 block discarded – undo
588 588
             )
589 589
         );
590 590
         // Log the response.
591
-        $this->log(array($request_text . ' Response' => $request_response), $payment);
591
+        $this->log(array($request_text.' Response' => $request_response), $payment);
592 592
         return $request_response;
593 593
     }
594 594
 
@@ -608,7 +608,7 @@  discard block
 block discarded – undo
608 608
         }
609 609
         $response_args = array();
610 610
         parse_str(urldecode($request_response['body']), $response_args);
611
-        if (! isset($response_args['ACK'])) {
611
+        if ( ! isset($response_args['ACK'])) {
612 612
             return array('status' => false, 'args' => $request_response);
613 613
         }
614 614
         if (
@@ -656,18 +656,18 @@  discard block
 block discarded – undo
656 656
     {
657 657
         $errors = array();
658 658
         $n = 0;
659
-        while (isset($data_array[ "L_ERRORCODE{$n}" ])) {
660
-            $l_error_code = isset($data_array[ "L_ERRORCODE{$n}" ])
661
-                ? $data_array[ "L_ERRORCODE{$n}" ]
659
+        while (isset($data_array["L_ERRORCODE{$n}"])) {
660
+            $l_error_code = isset($data_array["L_ERRORCODE{$n}"])
661
+                ? $data_array["L_ERRORCODE{$n}"]
662 662
                 : '';
663
-            $l_severity_code = isset($data_array[ "L_SEVERITYCODE{$n}" ])
664
-                ? $data_array[ "L_SEVERITYCODE{$n}" ]
663
+            $l_severity_code = isset($data_array["L_SEVERITYCODE{$n}"])
664
+                ? $data_array["L_SEVERITYCODE{$n}"]
665 665
                 : '';
666
-            $l_short_message = isset($data_array[ "L_SHORTMESSAGE{$n}" ])
667
-                ? $data_array[ "L_SHORTMESSAGE{$n}" ]
666
+            $l_short_message = isset($data_array["L_SHORTMESSAGE{$n}"])
667
+                ? $data_array["L_SHORTMESSAGE{$n}"]
668 668
                 : '';
669
-            $l_long_message = isset($data_array[ "L_LONGMESSAGE{$n}" ])
670
-                ? $data_array[ "L_LONGMESSAGE{$n}" ]
669
+            $l_long_message = isset($data_array["L_LONGMESSAGE{$n}"])
670
+                ? $data_array["L_LONGMESSAGE{$n}"]
671 671
                 : '';
672 672
             if ($n === 0) {
673 673
                 $errors = array(
@@ -677,10 +677,10 @@  discard block
 block discarded – undo
677 677
                     'L_SEVERITYCODE' => $l_severity_code,
678 678
                 );
679 679
             } else {
680
-                $errors['L_ERRORCODE'] .= ', ' . $l_error_code;
681
-                $errors['L_SHORTMESSAGE'] .= ', ' . $l_short_message;
682
-                $errors['L_LONGMESSAGE'] .= ', ' . $l_long_message;
683
-                $errors['L_SEVERITYCODE'] .= ', ' . $l_severity_code;
680
+                $errors['L_ERRORCODE'] .= ', '.$l_error_code;
681
+                $errors['L_SHORTMESSAGE'] .= ', '.$l_short_message;
682
+                $errors['L_LONGMESSAGE'] .= ', '.$l_long_message;
683
+                $errors['L_SEVERITYCODE'] .= ', '.$l_severity_code;
684 684
             }
685 685
             $n++;
686 686
         }
Please login to merge, or discard this patch.
caffeinated/admin/new/pricing/Price_Types_List_Table.class.php 2 patches
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
     public function __construct($admin_page)
20 20
     {
21 21
         parent::__construct($admin_page);
22
-        require_once(EE_MODELS . 'EEM_Price_Type.model.php');
22
+        require_once(EE_MODELS.'EEM_Price_Type.model.php');
23 23
         $this->_PRT = EEM_Price_Type::instance();
24 24
     }
25 25
 
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
         $this->_columns = array(
46 46
             'cb'        => '<input type="checkbox" />', // Render a checkbox instead of text
47 47
             'name'      => esc_html__('Name', 'event_espresso'),
48
-            'base_type' => '<div class="jst-cntr">' . esc_html__('Base Type', 'event_espresso') . '</div>',
48
+            'base_type' => '<div class="jst-cntr">'.esc_html__('Base Type', 'event_espresso').'</div>',
49 49
             'percent'   => '<div class="jst-cntr">'
50 50
                            . sprintf(
51 51
                                /* translators: 1: HTML new line, 2: open span tag, 3: close span tag */
@@ -121,14 +121,14 @@  discard block
 block discarded – undo
121 121
                 'action' => 'edit_price_type',
122 122
                 'id'     => $item->ID(),
123 123
             ), PRICING_ADMIN_URL);
124
-            $actions['edit'] = '<a href="' . $edit_lnk_url . '" aria-label="'
124
+            $actions['edit'] = '<a href="'.$edit_lnk_url.'" aria-label="'
125 125
                                . sprintf(
126 126
                                    /* translators: The name of the price type */
127 127
                                    esc_attr__('Edit Price Type (%s)', 'event_espresso'),
128 128
                                    $item->name()
129 129
                                )
130 130
                                . '">'
131
-                               . esc_html__('Edit', 'event_espresso') . '</a>';
131
+                               . esc_html__('Edit', 'event_espresso').'</a>';
132 132
         }
133 133
 
134 134
         $name_link = EE_Registry::instance()->CAP->current_user_can(
@@ -136,14 +136,14 @@  discard block
 block discarded – undo
136 136
             'pricing_edit_price_type',
137 137
             $item->ID()
138 138
         )
139
-            ? '<a href="' . $edit_lnk_url . '" aria-label="'
139
+            ? '<a href="'.$edit_lnk_url.'" aria-label="'
140 140
               . sprintf(
141 141
                   /* translators: The name of the price type */
142 142
                   esc_attr__('Edit Price Type (%s)', 'event_espresso'),
143 143
                   $item->name()
144 144
               )
145 145
               . '">'
146
-              . stripslashes($item->name()) . '</a>'
146
+              . stripslashes($item->name()).'</a>'
147 147
             : $item->name();
148 148
 
149 149
         if ($item->base_type() !== 1) {
@@ -161,14 +161,14 @@  discard block
 block discarded – undo
161 161
                         'id'       => $item->ID(),
162 162
                         'noheader' => true,
163 163
                     ), PRICING_ADMIN_URL);
164
-                    $actions['trash'] = '<a href="' . $trash_lnk_url . '" aria-label="'
164
+                    $actions['trash'] = '<a href="'.$trash_lnk_url.'" aria-label="'
165 165
                                         . sprintf(
166 166
                                             /* translators: The name of the price type */
167 167
                                             esc_attr__('Move Price Type %s to Trash', 'event_espresso'),
168 168
                                             $item->name()
169 169
                                         )
170 170
                                         . '">'
171
-                                        . esc_html__('Move to Trash', 'event_espresso') . '</a>';
171
+                                        . esc_html__('Move to Trash', 'event_espresso').'</a>';
172 172
                 }
173 173
             } else {
174 174
                 // restore price link
@@ -184,14 +184,14 @@  discard block
 block discarded – undo
184 184
                         'id'       => $item->ID(),
185 185
                         'noheader' => true,
186 186
                     ), PRICING_ADMIN_URL);
187
-                    $actions['restore'] = '<a href="' . $restore_lnk_url . '" aria-label="'
187
+                    $actions['restore'] = '<a href="'.$restore_lnk_url.'" aria-label="'
188 188
                                           . sprintf(
189 189
                                               /* translators: The name of the price type */
190 190
                                               esc_attr__('Restore Price Type (%s)', 'event_espresso'),
191 191
                                               $item->name()
192 192
                                           )
193 193
                                           . '">'
194
-                                          . esc_html__('Restore', 'event_espresso') . '</a>';
194
+                                          . esc_html__('Restore', 'event_espresso').'</a>';
195 195
                 }
196 196
                 // delete price link
197 197
                 if (
@@ -206,14 +206,14 @@  discard block
 block discarded – undo
206 206
                         'id'       => $item->ID(),
207 207
                         'noheader' => true,
208 208
                     ), PRICING_ADMIN_URL);
209
-                    $actions['delete'] = '<a href="' . $delete_lnk_url . '" aria-label="'
209
+                    $actions['delete'] = '<a href="'.$delete_lnk_url.'" aria-label="'
210 210
                                          . sprintf(
211 211
                                              /* translators: The name of the price type */
212 212
                                              esc_attr__('Delete Price Type %s Permanently', 'event_espresso'),
213 213
                                              $item->name()
214 214
                                          )
215 215
                                          . '">'
216
-                                         . esc_html__('Delete Permanently', 'event_espresso') . '</a>';
216
+                                         . esc_html__('Delete Permanently', 'event_espresso').'</a>';
217 217
                 }
218 218
             }
219 219
         }
@@ -230,18 +230,18 @@  discard block
 block discarded – undo
230 230
 
231 231
     public function column_base_type($item)
232 232
     {
233
-        return '<div class="jst-cntr">' . $item->base_type_name() . '</div>';
233
+        return '<div class="jst-cntr">'.$item->base_type_name().'</div>';
234 234
     }
235 235
 
236 236
 
237 237
     public function column_percent($item)
238 238
     {
239
-        return '<div class="jst-cntr">' . ($item->is_percent() ? '%' : EE_Registry::instance()->CFG->currency->sign) . '</div>';
239
+        return '<div class="jst-cntr">'.($item->is_percent() ? '%' : EE_Registry::instance()->CFG->currency->sign).'</div>';
240 240
     }
241 241
 
242 242
 
243 243
     public function column_order($item)
244 244
     {
245
-        return '<div class="jst-cntr">' . $item->order() . '</div>';
245
+        return '<div class="jst-cntr">'.$item->order().'</div>';
246 246
     }
247 247
 }
Please login to merge, or discard this patch.
Indentation   +228 added lines, -228 removed lines patch added patch discarded remove patch
@@ -15,232 +15,232 @@
 block discarded – undo
15 15
  */
16 16
 class Price_Types_List_Table extends EE_Admin_List_Table
17 17
 {
18
-    public function __construct($admin_page)
19
-    {
20
-        parent::__construct($admin_page);
21
-        require_once(EE_MODELS . 'EEM_Price_Type.model.php');
22
-        $this->_PRT = EEM_Price_Type::instance();
23
-    }
24
-
25
-
26
-    protected function _setup_data()
27
-    {
28
-        $trashed = $this->_admin_page->get_view() == 'trashed' ? true : false;
29
-        $this->_data = $this->_admin_page->get_price_types_overview_data($this->_per_page, false, $trashed);
30
-        $this->_all_data_count = $this->_admin_page->get_price_types_overview_data($this->_per_page, true, false);
31
-        $this->_trashed_count = $this->_admin_page->get_price_types_overview_data($this->_per_page, true, true);
32
-    }
33
-
34
-
35
-    protected function _set_properties()
36
-    {
37
-        $this->_wp_list_args = array(
38
-            'singular' => esc_html__('price type', 'event_espresso'),
39
-            'plural'   => esc_html__('price types', 'event_espresso'),
40
-            'ajax'     => true,
41
-            'screen'   => $this->_admin_page->get_current_screen()->id,
42
-        );
43
-
44
-        $this->_columns = array(
45
-            'cb'        => '<input type="checkbox" />', // Render a checkbox instead of text
46
-            'name'      => esc_html__('Name', 'event_espresso'),
47
-            'base_type' => '<div class="jst-cntr">' . esc_html__('Base Type', 'event_espresso') . '</div>',
48
-            'percent'   => '<div class="jst-cntr">'
49
-                           . sprintf(
50
-                               /* translators: 1: HTML new line, 2: open span tag, 3: close span tag */
51
-                               esc_html__('Applied %1$s as %2$s%%%3$s or %2$s$%3$s', 'event_espresso'),
52
-                               '<br/>',
53
-                               '<span class="big-text">',
54
-                               '</span>'
55
-                           )
56
-                           . '</div>',
57
-            'order'     => '<div class="jst-cntr">'
58
-                           . sprintf(
59
-                               /* translators: HTML new line */
60
-                               esc_html__('Order of %s Application', 'event_espresso'),
61
-                               '<br/>'
62
-                           )
63
-                           . '</div>',
64
-        );
65
-
66
-        $this->_sortable_columns = array(
67
-            // TRUE means its already sorted
68
-            'name' => array('name' => false),
69
-        );
70
-
71
-        $this->_hidden_columns = array();
72
-    }
73
-
74
-
75
-    protected function _get_table_filters()
76
-    {
77
-    }
78
-
79
-
80
-    protected function _add_view_counts()
81
-    {
82
-        $this->_views['all']['count'] = $this->_all_data_count;
83
-        if (
84
-            EE_Registry::instance()->CAP->current_user_can(
85
-                'ee_delete_default_price_types',
86
-                'pricing_trash_price_type'
87
-            )
88
-        ) {
89
-            $this->_views['trashed']['count'] = $this->_trashed_count;
90
-        }
91
-    }
92
-
93
-
94
-    public function column_cb($item)
95
-    {
96
-        if ($item->base_type() !== 1) {
97
-            return sprintf(
98
-                '<input type="checkbox" name="checkbox[%1$s]" />',
99
-                $item->ID()
100
-            );
101
-        }
102
-        return '';
103
-    }
104
-
105
-
106
-    public function column_name($item)
107
-    {
108
-
109
-        // Build row actions
110
-        $actions = array();
111
-        // edit price link
112
-        if (
113
-            EE_Registry::instance()->CAP->current_user_can(
114
-                'ee_edit_default_price_type',
115
-                'pricing_edit_price_type',
116
-                $item->ID()
117
-            )
118
-        ) {
119
-            $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
120
-                'action' => 'edit_price_type',
121
-                'id'     => $item->ID(),
122
-            ), PRICING_ADMIN_URL);
123
-            $actions['edit'] = '<a href="' . $edit_lnk_url . '" aria-label="'
124
-                               . sprintf(
125
-                                   /* translators: The name of the price type */
126
-                                   esc_attr__('Edit Price Type (%s)', 'event_espresso'),
127
-                                   $item->name()
128
-                               )
129
-                               . '">'
130
-                               . esc_html__('Edit', 'event_espresso') . '</a>';
131
-        }
132
-
133
-        $name_link = EE_Registry::instance()->CAP->current_user_can(
134
-            'ee_edit_default_price_type',
135
-            'pricing_edit_price_type',
136
-            $item->ID()
137
-        )
138
-            ? '<a href="' . $edit_lnk_url . '" aria-label="'
139
-              . sprintf(
140
-                  /* translators: The name of the price type */
141
-                  esc_attr__('Edit Price Type (%s)', 'event_espresso'),
142
-                  $item->name()
143
-              )
144
-              . '">'
145
-              . stripslashes($item->name()) . '</a>'
146
-            : $item->name();
147
-
148
-        if ($item->base_type() !== 1) {
149
-            if ($this->_view == 'all') {
150
-                // trash price link
151
-                if (
152
-                    EE_Registry::instance()->CAP->current_user_can(
153
-                        'ee_delete_default_price_type',
154
-                        'pricing_trash_price_type',
155
-                        $item->ID()
156
-                    )
157
-                ) {
158
-                    $trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
159
-                        'action'   => 'trash_price_type',
160
-                        'id'       => $item->ID(),
161
-                        'noheader' => true,
162
-                    ), PRICING_ADMIN_URL);
163
-                    $actions['trash'] = '<a href="' . $trash_lnk_url . '" aria-label="'
164
-                                        . sprintf(
165
-                                            /* translators: The name of the price type */
166
-                                            esc_attr__('Move Price Type %s to Trash', 'event_espresso'),
167
-                                            $item->name()
168
-                                        )
169
-                                        . '">'
170
-                                        . esc_html__('Move to Trash', 'event_espresso') . '</a>';
171
-                }
172
-            } else {
173
-                // restore price link
174
-                if (
175
-                    EE_Registry::instance()->CAP->current_user_can(
176
-                        'ee_delete_default_price_type',
177
-                        'pricing_restore_price_type',
178
-                        $item->ID()
179
-                    )
180
-                ) {
181
-                    $restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
182
-                        'action'   => 'restore_price_type',
183
-                        'id'       => $item->ID(),
184
-                        'noheader' => true,
185
-                    ), PRICING_ADMIN_URL);
186
-                    $actions['restore'] = '<a href="' . $restore_lnk_url . '" aria-label="'
187
-                                          . sprintf(
188
-                                              /* translators: The name of the price type */
189
-                                              esc_attr__('Restore Price Type (%s)', 'event_espresso'),
190
-                                              $item->name()
191
-                                          )
192
-                                          . '">'
193
-                                          . esc_html__('Restore', 'event_espresso') . '</a>';
194
-                }
195
-                // delete price link
196
-                if (
197
-                    EE_Registry::instance()->CAP->current_user_can(
198
-                        'ee_delete_default_price_type',
199
-                        'pricing_delete_price_type',
200
-                        $item->ID()
201
-                    )
202
-                ) {
203
-                    $delete_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
204
-                        'action'   => 'delete_price_type',
205
-                        'id'       => $item->ID(),
206
-                        'noheader' => true,
207
-                    ), PRICING_ADMIN_URL);
208
-                    $actions['delete'] = '<a href="' . $delete_lnk_url . '" aria-label="'
209
-                                         . sprintf(
210
-                                             /* translators: The name of the price type */
211
-                                             esc_attr__('Delete Price Type %s Permanently', 'event_espresso'),
212
-                                             $item->name()
213
-                                         )
214
-                                         . '">'
215
-                                         . esc_html__('Delete Permanently', 'event_espresso') . '</a>';
216
-                }
217
-            }
218
-        }
219
-
220
-        // Return the name contents
221
-        return sprintf(
222
-            '%1$s <span style="color:silver">(id:%2$s)</span>%3$s',
223
-            $name_link,
224
-            $item->ID(),
225
-            $this->row_actions($actions)
226
-        );
227
-    }
228
-
229
-
230
-    public function column_base_type($item)
231
-    {
232
-        return '<div class="jst-cntr">' . $item->base_type_name() . '</div>';
233
-    }
234
-
235
-
236
-    public function column_percent($item)
237
-    {
238
-        return '<div class="jst-cntr">' . ($item->is_percent() ? '%' : EE_Registry::instance()->CFG->currency->sign) . '</div>';
239
-    }
240
-
241
-
242
-    public function column_order($item)
243
-    {
244
-        return '<div class="jst-cntr">' . $item->order() . '</div>';
245
-    }
18
+	public function __construct($admin_page)
19
+	{
20
+		parent::__construct($admin_page);
21
+		require_once(EE_MODELS . 'EEM_Price_Type.model.php');
22
+		$this->_PRT = EEM_Price_Type::instance();
23
+	}
24
+
25
+
26
+	protected function _setup_data()
27
+	{
28
+		$trashed = $this->_admin_page->get_view() == 'trashed' ? true : false;
29
+		$this->_data = $this->_admin_page->get_price_types_overview_data($this->_per_page, false, $trashed);
30
+		$this->_all_data_count = $this->_admin_page->get_price_types_overview_data($this->_per_page, true, false);
31
+		$this->_trashed_count = $this->_admin_page->get_price_types_overview_data($this->_per_page, true, true);
32
+	}
33
+
34
+
35
+	protected function _set_properties()
36
+	{
37
+		$this->_wp_list_args = array(
38
+			'singular' => esc_html__('price type', 'event_espresso'),
39
+			'plural'   => esc_html__('price types', 'event_espresso'),
40
+			'ajax'     => true,
41
+			'screen'   => $this->_admin_page->get_current_screen()->id,
42
+		);
43
+
44
+		$this->_columns = array(
45
+			'cb'        => '<input type="checkbox" />', // Render a checkbox instead of text
46
+			'name'      => esc_html__('Name', 'event_espresso'),
47
+			'base_type' => '<div class="jst-cntr">' . esc_html__('Base Type', 'event_espresso') . '</div>',
48
+			'percent'   => '<div class="jst-cntr">'
49
+						   . sprintf(
50
+							   /* translators: 1: HTML new line, 2: open span tag, 3: close span tag */
51
+							   esc_html__('Applied %1$s as %2$s%%%3$s or %2$s$%3$s', 'event_espresso'),
52
+							   '<br/>',
53
+							   '<span class="big-text">',
54
+							   '</span>'
55
+						   )
56
+						   . '</div>',
57
+			'order'     => '<div class="jst-cntr">'
58
+						   . sprintf(
59
+							   /* translators: HTML new line */
60
+							   esc_html__('Order of %s Application', 'event_espresso'),
61
+							   '<br/>'
62
+						   )
63
+						   . '</div>',
64
+		);
65
+
66
+		$this->_sortable_columns = array(
67
+			// TRUE means its already sorted
68
+			'name' => array('name' => false),
69
+		);
70
+
71
+		$this->_hidden_columns = array();
72
+	}
73
+
74
+
75
+	protected function _get_table_filters()
76
+	{
77
+	}
78
+
79
+
80
+	protected function _add_view_counts()
81
+	{
82
+		$this->_views['all']['count'] = $this->_all_data_count;
83
+		if (
84
+			EE_Registry::instance()->CAP->current_user_can(
85
+				'ee_delete_default_price_types',
86
+				'pricing_trash_price_type'
87
+			)
88
+		) {
89
+			$this->_views['trashed']['count'] = $this->_trashed_count;
90
+		}
91
+	}
92
+
93
+
94
+	public function column_cb($item)
95
+	{
96
+		if ($item->base_type() !== 1) {
97
+			return sprintf(
98
+				'<input type="checkbox" name="checkbox[%1$s]" />',
99
+				$item->ID()
100
+			);
101
+		}
102
+		return '';
103
+	}
104
+
105
+
106
+	public function column_name($item)
107
+	{
108
+
109
+		// Build row actions
110
+		$actions = array();
111
+		// edit price link
112
+		if (
113
+			EE_Registry::instance()->CAP->current_user_can(
114
+				'ee_edit_default_price_type',
115
+				'pricing_edit_price_type',
116
+				$item->ID()
117
+			)
118
+		) {
119
+			$edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
120
+				'action' => 'edit_price_type',
121
+				'id'     => $item->ID(),
122
+			), PRICING_ADMIN_URL);
123
+			$actions['edit'] = '<a href="' . $edit_lnk_url . '" aria-label="'
124
+							   . sprintf(
125
+								   /* translators: The name of the price type */
126
+								   esc_attr__('Edit Price Type (%s)', 'event_espresso'),
127
+								   $item->name()
128
+							   )
129
+							   . '">'
130
+							   . esc_html__('Edit', 'event_espresso') . '</a>';
131
+		}
132
+
133
+		$name_link = EE_Registry::instance()->CAP->current_user_can(
134
+			'ee_edit_default_price_type',
135
+			'pricing_edit_price_type',
136
+			$item->ID()
137
+		)
138
+			? '<a href="' . $edit_lnk_url . '" aria-label="'
139
+			  . sprintf(
140
+				  /* translators: The name of the price type */
141
+				  esc_attr__('Edit Price Type (%s)', 'event_espresso'),
142
+				  $item->name()
143
+			  )
144
+			  . '">'
145
+			  . stripslashes($item->name()) . '</a>'
146
+			: $item->name();
147
+
148
+		if ($item->base_type() !== 1) {
149
+			if ($this->_view == 'all') {
150
+				// trash price link
151
+				if (
152
+					EE_Registry::instance()->CAP->current_user_can(
153
+						'ee_delete_default_price_type',
154
+						'pricing_trash_price_type',
155
+						$item->ID()
156
+					)
157
+				) {
158
+					$trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
159
+						'action'   => 'trash_price_type',
160
+						'id'       => $item->ID(),
161
+						'noheader' => true,
162
+					), PRICING_ADMIN_URL);
163
+					$actions['trash'] = '<a href="' . $trash_lnk_url . '" aria-label="'
164
+										. sprintf(
165
+											/* translators: The name of the price type */
166
+											esc_attr__('Move Price Type %s to Trash', 'event_espresso'),
167
+											$item->name()
168
+										)
169
+										. '">'
170
+										. esc_html__('Move to Trash', 'event_espresso') . '</a>';
171
+				}
172
+			} else {
173
+				// restore price link
174
+				if (
175
+					EE_Registry::instance()->CAP->current_user_can(
176
+						'ee_delete_default_price_type',
177
+						'pricing_restore_price_type',
178
+						$item->ID()
179
+					)
180
+				) {
181
+					$restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
182
+						'action'   => 'restore_price_type',
183
+						'id'       => $item->ID(),
184
+						'noheader' => true,
185
+					), PRICING_ADMIN_URL);
186
+					$actions['restore'] = '<a href="' . $restore_lnk_url . '" aria-label="'
187
+										  . sprintf(
188
+											  /* translators: The name of the price type */
189
+											  esc_attr__('Restore Price Type (%s)', 'event_espresso'),
190
+											  $item->name()
191
+										  )
192
+										  . '">'
193
+										  . esc_html__('Restore', 'event_espresso') . '</a>';
194
+				}
195
+				// delete price link
196
+				if (
197
+					EE_Registry::instance()->CAP->current_user_can(
198
+						'ee_delete_default_price_type',
199
+						'pricing_delete_price_type',
200
+						$item->ID()
201
+					)
202
+				) {
203
+					$delete_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
204
+						'action'   => 'delete_price_type',
205
+						'id'       => $item->ID(),
206
+						'noheader' => true,
207
+					), PRICING_ADMIN_URL);
208
+					$actions['delete'] = '<a href="' . $delete_lnk_url . '" aria-label="'
209
+										 . sprintf(
210
+											 /* translators: The name of the price type */
211
+											 esc_attr__('Delete Price Type %s Permanently', 'event_espresso'),
212
+											 $item->name()
213
+										 )
214
+										 . '">'
215
+										 . esc_html__('Delete Permanently', 'event_espresso') . '</a>';
216
+				}
217
+			}
218
+		}
219
+
220
+		// Return the name contents
221
+		return sprintf(
222
+			'%1$s <span style="color:silver">(id:%2$s)</span>%3$s',
223
+			$name_link,
224
+			$item->ID(),
225
+			$this->row_actions($actions)
226
+		);
227
+	}
228
+
229
+
230
+	public function column_base_type($item)
231
+	{
232
+		return '<div class="jst-cntr">' . $item->base_type_name() . '</div>';
233
+	}
234
+
235
+
236
+	public function column_percent($item)
237
+	{
238
+		return '<div class="jst-cntr">' . ($item->is_percent() ? '%' : EE_Registry::instance()->CFG->currency->sign) . '</div>';
239
+	}
240
+
241
+
242
+	public function column_order($item)
243
+	{
244
+		return '<div class="jst-cntr">' . $item->order() . '</div>';
245
+	}
246 246
 }
Please login to merge, or discard this patch.