Completed
Branch FET-9795-new-interfaces (793e2e)
by
unknown
121:05 queued 108:17
created
acceptance_tests/Page/Checkout.php 1 patch
Indentation   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -13,48 +13,48 @@
 block discarded – undo
13 13
 class Checkout
14 14
 {
15 15
 
16
-    /**
17
-     * The class selector for the next step button in the checkout.
18
-     * @var string
19
-     */
20
-    const NEXT_STEP_BUTTON_SELECTOR = '.spco-next-step-btn';
21
-
22
-    /**
23
-     * @param int $attendee_number
24
-     * @return string
25
-     */
26
-    public static function firstNameFieldSelectorForAttendeeNumber($attendee_number = 1)
27
-    {
28
-        return self::fieldSelectorForAttendeeNumber('fname', $attendee_number);
29
-    }
30
-
31
-
32
-    /**
33
-     * @param int $attendee_number
34
-     * @return string
35
-     */
36
-    public static function lastNameFieldSelectorForAttendeeNumber($attendee_number = 1)
37
-    {
38
-        return self::fieldSelectorForAttendeeNumber('lname', $attendee_number);
39
-    }
40
-
41
-
42
-    /**
43
-     * @param int $attendee_number
44
-     * @return string
45
-     */
46
-    public static function emailFieldSelectorForAttendeeNumber($attendee_number = 1)
47
-    {
48
-        return self::fieldSelectorForAttendeeNumber('email', $attendee_number);
49
-    }
50
-
51
-    /**
52
-     * @param     $field_name
53
-     * @param int $attendee_number
54
-     * @return string
55
-     */
56
-    public static function fieldSelectorForAttendeeNumber($field_name, $attendee_number = 1)
57
-    {
58
-        return "//div[starts-with(@id, 'spco-attendee-panel-dv-$attendee_number')]//input[contains(@class, 'ee-reg-qstn-$field_name')]";
59
-    }
16
+	/**
17
+	 * The class selector for the next step button in the checkout.
18
+	 * @var string
19
+	 */
20
+	const NEXT_STEP_BUTTON_SELECTOR = '.spco-next-step-btn';
21
+
22
+	/**
23
+	 * @param int $attendee_number
24
+	 * @return string
25
+	 */
26
+	public static function firstNameFieldSelectorForAttendeeNumber($attendee_number = 1)
27
+	{
28
+		return self::fieldSelectorForAttendeeNumber('fname', $attendee_number);
29
+	}
30
+
31
+
32
+	/**
33
+	 * @param int $attendee_number
34
+	 * @return string
35
+	 */
36
+	public static function lastNameFieldSelectorForAttendeeNumber($attendee_number = 1)
37
+	{
38
+		return self::fieldSelectorForAttendeeNumber('lname', $attendee_number);
39
+	}
40
+
41
+
42
+	/**
43
+	 * @param int $attendee_number
44
+	 * @return string
45
+	 */
46
+	public static function emailFieldSelectorForAttendeeNumber($attendee_number = 1)
47
+	{
48
+		return self::fieldSelectorForAttendeeNumber('email', $attendee_number);
49
+	}
50
+
51
+	/**
52
+	 * @param     $field_name
53
+	 * @param int $attendee_number
54
+	 * @return string
55
+	 */
56
+	public static function fieldSelectorForAttendeeNumber($field_name, $attendee_number = 1)
57
+	{
58
+		return "//div[starts-with(@id, 'spco-attendee-panel-dv-$attendee_number')]//input[contains(@class, 'ee-reg-qstn-$field_name')]";
59
+	}
60 60
 }
Please login to merge, or discard this patch.
acceptance_tests/Page/MessagesAdmin.php 2 patches
Indentation   +125 added lines, -125 removed lines patch added patch discarded remove patch
@@ -12,130 +12,130 @@
 block discarded – undo
12 12
 class MessagesAdmin extends CoreAdmin
13 13
 {
14 14
 
15
-    /**
16
-     * Context slug for the admin messages context.
17
-     * @var string
18
-     */
19
-    const ADMIN_CONTEXT_SLUG = 'admin';
20
-
21
-    /**
22
-     * Context slug for the primary attendee messages context
23
-     * @var string
24
-     */
25
-    const PRIMARY_ATTENDEE_CONTEXT_SLUG = 'primary_attendee';
26
-
27
-
28
-    /**
29
-     * Status reference for the EEM_Message::status_sent status.
30
-     * @var string
31
-     */
32
-    const MESSAGE_STATUS_SENT = 'MSN';
33
-
34
-
35
-    /**
36
-     * Message type slug for the Payment Failed message type
37
-     */
38
-    const PAYMENT_FAILED_MESSAGE_TYPE_SLUG = 'payment_failed';
39
-
40
-
41
-    /**
42
-     * Selector for the Global Messages "Send on same request" field in the Messages Settings tab.
43
-     * @var string
44
-     */
45
-    const GLOBAL_MESSAGES_SETTINGS_ON_REQUEST_SELECTION_SELECTOR = '#global_messages_settings-do-messages-on-same-request';
46
-
47
-
48
-    /**
49
-     * Selector for the Global Messages Settings submit button in the Messages Settings tab.
50
-     * @var string
51
-     */
52
-    const GLOBAL_MESSAGES_SETTINGS_SUBMIT_SELECTOR = '#global_messages_settings-update-settings-submit';
53
-
54
-
55
-
56
-    /**
57
-     * @param string $additional_params Any additional request parameters for the generated url should be included as
58
-     *                                  a string.
59
-     * @return string
60
-     */
61
-    public static function messageActivityListTableUrl($additional_params = '')
62
-    {
63
-        return self::adminUrl('espresso_messages', 'default', $additional_params);
64
-    }
65
-
66
-
67
-    /**
68
-     * @param string $additional_params Any additional request parameters for the generated url should be included as
69
-     *                                  a string.
70
-     * @return string
71
-     */
72
-    public static function defaultMessageTemplateListTableUrl($additional_params = '')
73
-    {
74
-        return self::adminUrl('espresso_messages', 'global_mtps', $additional_params);
75
-    }
76
-
77
-
78
-    /**
79
-     * @param string $additional_params Any additional request parameters for the generated url should be included as
80
-     *                                  a string.
81
-     * @return string
82
-     */
83
-    public static function customMessageTemplateListTableUrl($additional_params = '')
84
-    {
85
-        return self::adminUrl('espresso_messages', 'custom_mtps', $additional_params);
86
-    }
87
-
88
-
89
-    /**
90
-     * @return string
91
-     */
92
-    public static function messageSettingsUrl()
93
-    {
94
-        return self::adminUrl('espresso_messages', 'settings');
95
-    }
96
-
97
-
98
-    /**
99
-     * @param string $message_type_slug
100
-     * @param string $context
101
-     * @return string
102
-     */
103
-    public static function editMessageTemplateClassByMessageType($message_type_slug, $context = '')
104
-    {
105
-        return $context
106
-            ? '.' . $message_type_slug . '-' . $context . '-edit-link'
107
-            : '.' . $message_type_slug . '-edit-link';
108
-    }
109
-
110
-
111
-    /**
112
-     * Selector for (a) specific table cell(s) in the Messages Activity list table for the given parameters.
113
-     * @param        $field
114
-     * @param        $message_type_label
115
-     * @param string $message_status
116
-     * @param string $messenger
117
-     * @param string $context
118
-     * @param string $table_cell_content_for_field
119
-     * @return string
120
-     */
121
-    public static function messagesActivityListTableCellSelectorFor(
122
-        $field,
123
-        $message_type_label,
124
-        $message_status = self::MESSAGE_STATUS_SENT,
125
-        $messenger = 'Email',
126
-        $context = 'Event Admin',
127
-        $table_cell_content_for_field = ''
128
-    ) {
129
-        $selector = "//tr[contains(@class, 'msg-status-$message_status')]"
130
-                . "//td[contains(@class, 'message_type') and text()='$message_type_label']";
131
-        if ($messenger) {
132
-            $selector .= "/ancestor::tr/td[contains(@class, 'messenger') and text()='$messenger']";
133
-        }
134
-        $selector .= "/ancestor::tr/td[contains(@class, 'column-context') and text()='$context']";
135
-        $selector .= $table_cell_content_for_field
136
-            ? "/ancestor::tr/td[contains(@class, 'column-$field') and text()='$table_cell_content_for_field']"
137
-            : "/ancestor::tr/td[contains(@class, 'column-$field')]";
138
-        return $selector;
139
-    }
15
+	/**
16
+	 * Context slug for the admin messages context.
17
+	 * @var string
18
+	 */
19
+	const ADMIN_CONTEXT_SLUG = 'admin';
20
+
21
+	/**
22
+	 * Context slug for the primary attendee messages context
23
+	 * @var string
24
+	 */
25
+	const PRIMARY_ATTENDEE_CONTEXT_SLUG = 'primary_attendee';
26
+
27
+
28
+	/**
29
+	 * Status reference for the EEM_Message::status_sent status.
30
+	 * @var string
31
+	 */
32
+	const MESSAGE_STATUS_SENT = 'MSN';
33
+
34
+
35
+	/**
36
+	 * Message type slug for the Payment Failed message type
37
+	 */
38
+	const PAYMENT_FAILED_MESSAGE_TYPE_SLUG = 'payment_failed';
39
+
40
+
41
+	/**
42
+	 * Selector for the Global Messages "Send on same request" field in the Messages Settings tab.
43
+	 * @var string
44
+	 */
45
+	const GLOBAL_MESSAGES_SETTINGS_ON_REQUEST_SELECTION_SELECTOR = '#global_messages_settings-do-messages-on-same-request';
46
+
47
+
48
+	/**
49
+	 * Selector for the Global Messages Settings submit button in the Messages Settings tab.
50
+	 * @var string
51
+	 */
52
+	const GLOBAL_MESSAGES_SETTINGS_SUBMIT_SELECTOR = '#global_messages_settings-update-settings-submit';
53
+
54
+
55
+
56
+	/**
57
+	 * @param string $additional_params Any additional request parameters for the generated url should be included as
58
+	 *                                  a string.
59
+	 * @return string
60
+	 */
61
+	public static function messageActivityListTableUrl($additional_params = '')
62
+	{
63
+		return self::adminUrl('espresso_messages', 'default', $additional_params);
64
+	}
65
+
66
+
67
+	/**
68
+	 * @param string $additional_params Any additional request parameters for the generated url should be included as
69
+	 *                                  a string.
70
+	 * @return string
71
+	 */
72
+	public static function defaultMessageTemplateListTableUrl($additional_params = '')
73
+	{
74
+		return self::adminUrl('espresso_messages', 'global_mtps', $additional_params);
75
+	}
76
+
77
+
78
+	/**
79
+	 * @param string $additional_params Any additional request parameters for the generated url should be included as
80
+	 *                                  a string.
81
+	 * @return string
82
+	 */
83
+	public static function customMessageTemplateListTableUrl($additional_params = '')
84
+	{
85
+		return self::adminUrl('espresso_messages', 'custom_mtps', $additional_params);
86
+	}
87
+
88
+
89
+	/**
90
+	 * @return string
91
+	 */
92
+	public static function messageSettingsUrl()
93
+	{
94
+		return self::adminUrl('espresso_messages', 'settings');
95
+	}
96
+
97
+
98
+	/**
99
+	 * @param string $message_type_slug
100
+	 * @param string $context
101
+	 * @return string
102
+	 */
103
+	public static function editMessageTemplateClassByMessageType($message_type_slug, $context = '')
104
+	{
105
+		return $context
106
+			? '.' . $message_type_slug . '-' . $context . '-edit-link'
107
+			: '.' . $message_type_slug . '-edit-link';
108
+	}
109
+
110
+
111
+	/**
112
+	 * Selector for (a) specific table cell(s) in the Messages Activity list table for the given parameters.
113
+	 * @param        $field
114
+	 * @param        $message_type_label
115
+	 * @param string $message_status
116
+	 * @param string $messenger
117
+	 * @param string $context
118
+	 * @param string $table_cell_content_for_field
119
+	 * @return string
120
+	 */
121
+	public static function messagesActivityListTableCellSelectorFor(
122
+		$field,
123
+		$message_type_label,
124
+		$message_status = self::MESSAGE_STATUS_SENT,
125
+		$messenger = 'Email',
126
+		$context = 'Event Admin',
127
+		$table_cell_content_for_field = ''
128
+	) {
129
+		$selector = "//tr[contains(@class, 'msg-status-$message_status')]"
130
+				. "//td[contains(@class, 'message_type') and text()='$message_type_label']";
131
+		if ($messenger) {
132
+			$selector .= "/ancestor::tr/td[contains(@class, 'messenger') and text()='$messenger']";
133
+		}
134
+		$selector .= "/ancestor::tr/td[contains(@class, 'column-context') and text()='$context']";
135
+		$selector .= $table_cell_content_for_field
136
+			? "/ancestor::tr/td[contains(@class, 'column-$field') and text()='$table_cell_content_for_field']"
137
+			: "/ancestor::tr/td[contains(@class, 'column-$field')]";
138
+		return $selector;
139
+	}
140 140
 
141 141
 }
142 142
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -103,8 +103,8 @@
 block discarded – undo
103 103
     public static function editMessageTemplateClassByMessageType($message_type_slug, $context = '')
104 104
     {
105 105
         return $context
106
-            ? '.' . $message_type_slug . '-' . $context . '-edit-link'
107
-            : '.' . $message_type_slug . '-edit-link';
106
+            ? '.'.$message_type_slug.'-'.$context.'-edit-link'
107
+            : '.'.$message_type_slug.'-edit-link';
108 108
     }
109 109
 
110 110
 
Please login to merge, or discard this patch.
acceptance_tests/Page/TicketSelector.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -12,24 +12,24 @@
 block discarded – undo
12 12
 class TicketSelector
13 13
 {
14 14
 
15
-    /**
16
-     * Return the selector for the ticket option select input for the given event id.
17
-     * @param int|string $event_id
18
-     * @return string
19
-     */
20
-    public static function ticketOptionByEventIdSelector($event_id)
21
-    {
22
-        return "//select[@id='ticket-selector-tbl-qty-slct-$event_id-1']";
23
-    }
15
+	/**
16
+	 * Return the selector for the ticket option select input for the given event id.
17
+	 * @param int|string $event_id
18
+	 * @return string
19
+	 */
20
+	public static function ticketOptionByEventIdSelector($event_id)
21
+	{
22
+		return "//select[@id='ticket-selector-tbl-qty-slct-$event_id-1']";
23
+	}
24 24
 
25 25
 
26
-    /**
27
-     * Return the selector for the submit button for the ticket selector for the given event id.
28
-     * @param int|string $event_id
29
-     * @return string
30
-     */
31
-    public static function ticketSelectionSubmitSelectorByEventId($event_id)
32
-    {
33
-        return "#ticket-selector-submit-$event_id-btn";
34
-    }
26
+	/**
27
+	 * Return the selector for the submit button for the ticket selector for the given event id.
28
+	 * @param int|string $event_id
29
+	 * @return string
30
+	 */
31
+	public static function ticketSelectionSubmitSelectorByEventId($event_id)
32
+	{
33
+		return "#ticket-selector-submit-$event_id-btn";
34
+	}
35 35
 }
36 36
\ No newline at end of file
Please login to merge, or discard this patch.
caffeinated/payment_methods/Paypal_Pro/EEG_Paypal_Pro.gateway.php 2 patches
Indentation   +587 added lines, -587 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if (! defined('EVENT_ESPRESSO_VERSION')) {
3
-    exit('No direct script access allowed');
3
+	exit('No direct script access allowed');
4 4
 }
5 5
 
6 6
 
@@ -25,591 +25,591 @@  discard block
 block discarded – undo
25 25
 class EEG_Paypal_Pro extends EE_Onsite_Gateway
26 26
 {
27 27
 
28
-    /**
29
-     * @var $_paypal_api_username string
30
-     */
31
-    protected $_username = null;
32
-
33
-    /**
34
-     * @var $_password string
35
-     */
36
-    protected $_password = null;
37
-
38
-    /**
39
-     * @var $_signature string
40
-     */
41
-    protected $_signature = null;
42
-
43
-    /**
44
-     * @var $_credit_card_types array with the keys for credit card types accepted on this account
45
-     */
46
-    protected $_credit_card_types    = null;
47
-
48
-    protected $_currencies_supported = array(
49
-        'USD',
50
-        'GBP',
51
-        'CAD',
52
-        'AUD',
53
-        'BRL',
54
-        'CHF',
55
-        'CZK',
56
-        'DKK',
57
-        'EUR',
58
-        'HKD',
59
-        'HUF',
60
-        'ILS',
61
-        'JPY',
62
-        'MXN',
63
-        'MYR',
64
-        'NOK',
65
-        'NZD',
66
-        'PHP',
67
-        'PLN',
68
-        'SEK',
69
-        'SGD',
70
-        'THB',
71
-        'TRY',
72
-        'TWD',
73
-        'RUB',
74
-    );
75
-
76
-
77
-
78
-    /**
79
-     * @param EEI_Payment $payment
80
-     * @param array       $billing_info {
81
-     * @type string $credit_card
82
-     * @type string $credit_card_type
83
-     * @type string $exp_month always 2 characters
84
-     * @type string $exp_year always 4 characters
85
-     * @type string $cvv
86
-     * }
87
-     * @see      parent::do_direct_payment for more info
88
-     * @return EE_Payment|EEI_Payment
89
-     * @throws EE_Error
90
-     */
91
-    public function do_direct_payment($payment, $billing_info = null)
92
-    {
93
-        $transaction = $payment->transaction();
94
-        if (! $transaction instanceof EEI_Transaction) {
95
-            throw new EE_Error(
96
-                esc_html__('No transaction for payment while paying with PayPal Pro.', 'event_espresso')
97
-            );
98
-        }
99
-        $primary_registrant = $transaction->primary_registration();
100
-        if (! $primary_registrant instanceof EEI_Registration) {
101
-            throw new EE_Error(
102
-                esc_html__(
103
-                    'No primary registration on transaction while paying with PayPal Pro.',
104
-                    'event_espresso'
105
-                )
106
-            );
107
-        }
108
-        $attendee = $primary_registrant->attendee();
109
-        if (! $attendee instanceof EEI_Attendee) {
110
-            throw new EE_Error(
111
-                esc_html__(
112
-                    'No attendee on primary registration while paying with PayPal Pro.',
113
-                    'event_espresso'
114
-                )
115
-            );
116
-        }
117
-        $order_description = substr($this->_format_order_description($payment), 0, 127);
118
-        //charge for the full amount. Show itemized list
119
-        if ($this->_can_easily_itemize_transaction_for($payment)) {
120
-            $item_num = 1;
121
-            $total_line_item = $transaction->total_line_item();
122
-            $order_items = array();
123
-            foreach ($total_line_item->get_items() as $line_item) {
124
-                //ignore line items with a quantity of 0
125
-                if ($line_item->quantity() == 0) {
126
-                    continue;
127
-                }
128
-                $item = array(
129
-                    // Item Name.  127 char max.
130
-                    'l_name'                 => substr(
131
-                        $this->_format_line_item_name($line_item, $payment),
132
-                        0,
133
-                        127
134
-                    ),
135
-                    // Item description.  127 char max.
136
-                    'l_desc'                 => substr(
137
-                        $this->_format_line_item_desc($line_item, $payment),
138
-                        0,
139
-                        127
140
-                    ),
141
-                    // Cost of individual item.
142
-                    'l_amt'                  => $line_item->unit_price(),
143
-                    // Item Number.  127 char max.
144
-                    'l_number'               => $item_num++,
145
-                    // Item quantity.  Must be any positive integer.
146
-                    'l_qty'                  => $line_item->quantity(),
147
-                    // Item's sales tax amount.
148
-                    'l_taxamt'               => '',
149
-                    // eBay auction number of item.
150
-                    'l_ebayitemnumber'       => '',
151
-                    // eBay transaction ID of purchased item.
152
-                    'l_ebayitemauctiontxnid' => '',
153
-                    // eBay order ID for the item.
154
-                    'l_ebayitemorderid'      => '',
155
-                );
156
-                // add to array of all items
157
-                array_push($order_items, $item);
158
-            }
159
-            $item_amount = $total_line_item->get_items_total();
160
-            $tax_amount = $total_line_item->get_total_tax();
161
-        } else {
162
-            $order_items = array();
163
-            $item_amount = $payment->amount();
164
-            $tax_amount = 0;
165
-            array_push($order_items, array(
166
-                // Item Name.  127 char max.
167
-                'l_name'   => substr(
168
-                    $this->_format_partial_payment_line_item_name($payment),
169
-                    0,
170
-                    127
171
-                ),
172
-                // Item description.  127 char max.
173
-                'l_desc'   => substr(
174
-                    $this->_format_partial_payment_line_item_desc($payment),
175
-                    0,
176
-                    127
177
-                ),
178
-                // Cost of individual item.
179
-                'l_amt'    => $payment->amount(),
180
-                // Item Number.  127 char max.
181
-                'l_number' => 1,
182
-                // Item quantity.  Must be any positive integer.
183
-                'l_qty'    => 1,
184
-            ));
185
-        }
186
-        // Populate data arrays with order data.
187
-        $DPFields = array(
188
-            // How you want to obtain payment ?
189
-            // Authorization indicates the payment is a basic auth subject to settlement with Auth & Capture.
190
-            // Sale indicates that this is a final sale for which you are requesting payment.  Default is Sale.
191
-            'paymentaction'    => 'Sale',
192
-            // Required.  IP address of the payer's browser.
193
-            'ipaddress'        => $_SERVER['REMOTE_ADDR'],
194
-            // Flag to determine whether you want the results returned by FMF.  1 or 0.  Default is 0.
195
-            'returnfmfdetails' => '1',
196
-        );
197
-        $CCDetails = array(
198
-            // Required. Type of credit card.  Visa, MasterCard, Discover, Amex, Maestro, Solo.
199
-            // If Maestro or Solo, the currency code must be GBP.
200
-            //  In addition, either start date or issue number must be specified.
201
-            'creditcardtype' => $billing_info['credit_card_type'],
202
-            // Required.  Credit card number.  No spaces or punctuation.
203
-            'acct'           => $billing_info['credit_card'],
204
-            // Required.  Credit card expiration date.  Format is MMYYYY
205
-            'expdate'        => $billing_info['exp_month'] . $billing_info['exp_year'],
206
-            // Requirements determined by your PayPal account settings.  Security digits for credit card.
207
-            'cvv2'           => $billing_info['cvv'],
208
-        );
209
-        $PayerInfo = array(
210
-            // Email address of payer.
211
-            'email'       => $billing_info['email'],
212
-            // Unique PayPal customer ID for payer.
213
-            'payerid'     => '',
214
-            // Status of payer.  Values are verified or unverified
215
-            'payerstatus' => '',
216
-            // Payer's business name.
217
-            'business'    => '',
218
-        );
219
-        $PayerName = array(
220
-            // Payer's salutation.  20 char max.
221
-            'salutation' => '',
222
-            // Payer's first name.  25 char max.
223
-            'firstname'  => substr($billing_info['first_name'], 0, 25),
224
-            // Payer's middle name.  25 char max.
225
-            'middlename' => '',
226
-            // Payer's last name.  25 char max.
227
-            'lastname'   => substr($billing_info['last_name'], 0, 25),
228
-            // Payer's suffix.  12 char max.
229
-            'suffix'     => '',
230
-        );
231
-        $BillingAddress = array(
232
-            // Required.  First street address.
233
-            'street'      => $billing_info['address'],
234
-            // Second street address.
235
-            'street2'     => $billing_info['address2'],
236
-            // Required.  Name of City.
237
-            'city'        => $billing_info['city'],
238
-            // Required. Name of State or Province.
239
-            'state'       => substr($billing_info['state'], 0, 40),
240
-            // Required.  Country code.
241
-            'countrycode' => $billing_info['country'],
242
-            // Required.  Postal code of payer.
243
-            'zip'         => $billing_info['zip'],
244
-        );
245
-        //check if the registration info contains the needed fields for paypal pro
246
-        //(see https://developer.paypal.com/docs/classic/api/merchant/DoDirectPayment_API_Operation_NVP/)
247
-        if ($attendee->address() && $attendee->city() && $attendee->country_ID()) {
248
-            $use_registration_address_info = true;
249
-        } else {
250
-            $use_registration_address_info = false;
251
-        }
252
-        //so if the attendee has enough data to fill out PayPal Pro's shipping info, use it.
253
-        // If not, use the billing info again
254
-        $ShippingAddress = array(
255
-            'shiptoname'     => substr($use_registration_address_info
256
-                ? $attendee->full_name()
257
-                : $billing_info['first_name'] . ' ' . $billing_info['last_name'], 0, 32),
258
-            'shiptostreet'   => substr($use_registration_address_info
259
-                ? $attendee->address()
260
-                : $billing_info['address'], 0, 100),
261
-            'shiptostreet2'  => substr($use_registration_address_info
262
-                ? $attendee->address2() : $billing_info['address2'], 0, 100),
263
-            'shiptocity'     => substr($use_registration_address_info
264
-                ? $attendee->city()
265
-                : $billing_info['city'], 0, 40),
266
-            'state'          => substr($use_registration_address_info
267
-                ? $attendee->state_name()
268
-                : $billing_info['state'], 0, 40),
269
-            'shiptocountry'  => $use_registration_address_info
270
-                ? $attendee->country_ID()
271
-                : $billing_info['country'],
272
-            'shiptozip'      => substr($use_registration_address_info
273
-                ? $attendee->zip()
274
-                : $billing_info['zip'], 0, 20),
275
-            'shiptophonenum' => substr($use_registration_address_info
276
-                ? $attendee->phone()
277
-                : $billing_info['phone'], 0, 20),
278
-        );
279
-        $PaymentDetails = array(
280
-            // Required.  Total amount of order, including shipping, handling, and tax.
281
-            'amt'          => $this->format_currency($payment->amount()),
282
-            // Required.  Three-letter currency code.  Default is USD.
283
-            'currencycode' => $payment->currency_code(),
284
-            // Required if you include itemized cart details. (L_AMTn, etc.)
285
-            //Subtotal of items not including S&H, or tax.
286
-            'itemamt'      => $this->format_currency($item_amount),//
287
-            // Total shipping costs for the order.  If you specify shippingamt, you must also specify itemamt.
288
-            'shippingamt'  => '',
289
-            // Total handling costs for the order.  If you specify handlingamt, you must also specify itemamt.
290
-            'handlingamt'  => '',
291
-            // Required if you specify itemized cart tax details.
292
-            // Sum of tax for all items on the order.  Total sales tax.
293
-            'taxamt'       => $this->format_currency($tax_amount),
294
-            // Description of the order the customer is purchasing.  127 char max.
295
-            'desc'         => $order_description,
296
-            // Free-form field for your own use.  256 char max.
297
-            'custom'       => $primary_registrant ? $primary_registrant->ID() : '',
298
-            // Your own invoice or tracking number
299
-            'invnum'       => wp_generate_password(12, false),//$transaction->ID(),
300
-            // URL for receiving Instant Payment Notifications.  This overrides what your profile is set to use.
301
-            'notifyurl'    => '',
302
-            'buttonsource' => 'EventEspresso_SP',//EE will blow up if you change this
303
-        );
304
-        // Wrap all data arrays into a single, "master" array which will be passed into the class function.
305
-        $PayPalRequestData = array(
306
-            'DPFields'        => $DPFields,
307
-            'CCDetails'       => $CCDetails,
308
-            'PayerInfo'       => $PayerInfo,
309
-            'PayerName'       => $PayerName,
310
-            'BillingAddress'  => $BillingAddress,
311
-            'ShippingAddress' => $ShippingAddress,
312
-            'PaymentDetails'  => $PaymentDetails,
313
-            'OrderItems'      => $order_items,
314
-        );
315
-        $this->_log_clean_request($PayPalRequestData, $payment);
316
-        try {
317
-            $PayPalResult = $this->prep_and_curl_request($PayPalRequestData);
318
-            //remove PCI-sensitive data so it doesn't get stored
319
-            $PayPalResult = $this->_log_clean_response($PayPalResult, $payment);
320
-            $message = isset($PayPalResult['L_LONGMESSAGE0']) ? $PayPalResult['L_LONGMESSAGE0'] : $PayPalResult['ACK'];
321
-            if (empty($PayPalResult['RAWRESPONSE'])) {
322
-                $payment->set_status($this->_pay_model->failed_status());
323
-                $payment->set_gateway_response(__('No response received from Paypal Pro', 'event_espresso'));
324
-                $payment->set_details($PayPalResult);
325
-            } else {
326
-                if ($this->_APICallSuccessful($PayPalResult)) {
327
-                    $payment->set_status($this->_pay_model->approved_status());
328
-                } else {
329
-                    $payment->set_status($this->_pay_model->declined_status());
330
-                }
331
-                //make sure we interpret the AMT as a float, not an international string
332
-                // (where periods are thousand separators)
333
-                $payment->set_amount(isset($PayPalResult['AMT']) ? floatval($PayPalResult['AMT']) : 0);
334
-                $payment->set_gateway_response($message);
335
-                $payment->set_txn_id_chq_nmbr(isset($PayPalResult['TRANSACTIONID'])
336
-                    ? $PayPalResult['TRANSACTIONID']
337
-                    : null);
338
-                $primary_registration_code = $primary_registrant instanceof EE_Registration
339
-                    ? $primary_registrant->reg_code()
340
-                    : '';
341
-                $payment->set_extra_accntng($primary_registration_code);
342
-                $payment->set_details($PayPalResult);
343
-            }
344
-        } catch (Exception $e) {
345
-            $payment->set_status($this->_pay_model->failed_status());
346
-            $payment->set_gateway_response($e->getMessage());
347
-        }
348
-        //$payment->set_status( $this->_pay_model->declined_status() );
349
-        //$payment->set_gateway_response( '' );
350
-        return $payment;
351
-    }
352
-
353
-
354
-
355
-    /**
356
-     * CLeans out sensitive CC data and then logs it, and returns the cleaned request
357
-     *
358
-     * @param array       $request
359
-     * @param EEI_Payment $payment
360
-     * @return void
361
-     */
362
-    private function _log_clean_request($request, $payment)
363
-    {
364
-        $cleaned_request_data = $request;
365
-        unset($cleaned_request_data['CCDetails']['acct']);
366
-        unset($cleaned_request_data['CCDetails']['cvv2']);
367
-        unset($cleaned_request_data['CCDetails']['expdate']);
368
-        $this->log(array('Paypal Request' => $cleaned_request_data), $payment);
369
-    }
370
-
371
-
372
-
373
-    /**
374
-     * Cleans the response, logs it, and returns it
375
-     *
376
-     * @param array       $response
377
-     * @param EEI_Payment $payment
378
-     * @return array cleaned
379
-     */
380
-    private function _log_clean_response($response, $payment)
381
-    {
382
-        unset($response['REQUESTDATA']['CREDITCARDTYPE']);
383
-        unset($response['REQUESTDATA']['ACCT']);
384
-        unset($response['REQUESTDATA']['EXPDATE']);
385
-        unset($response['REQUESTDATA']['CVV2']);
386
-        unset($response['RAWREQUEST']);
387
-        $this->log(array('Paypal Response' => $response), $payment);
388
-        return $response;
389
-    }
390
-
391
-
392
-
393
-    /**
394
-     * @param $DataArray
395
-     * @return array
396
-     */
397
-    private function prep_and_curl_request($DataArray)
398
-    {
399
-        // Create empty holders for each portion of the NVP string
400
-        $DPFieldsNVP = '&METHOD=DoDirectPayment&BUTTONSOURCE=AngellEYE_PHP_Class_DDP';
401
-        $CCDetailsNVP = '';
402
-        $PayerInfoNVP = '';
403
-        $PayerNameNVP = '';
404
-        $BillingAddressNVP = '';
405
-        $ShippingAddressNVP = '';
406
-        $PaymentDetailsNVP = '';
407
-        $OrderItemsNVP = '';
408
-        $Secure3DNVP = '';
409
-        // DP Fields
410
-        $DPFields = isset($DataArray['DPFields']) ? $DataArray['DPFields'] : array();
411
-        foreach ($DPFields as $DPFieldsVar => $DPFieldsVal) {
412
-            $DPFieldsNVP .= '&' . strtoupper($DPFieldsVar) . '=' . urlencode($DPFieldsVal);
413
-        }
414
-        // CC Details Fields
415
-        $CCDetails = isset($DataArray['CCDetails']) ? $DataArray['CCDetails'] : array();
416
-        foreach ($CCDetails as $CCDetailsVar => $CCDetailsVal) {
417
-            $CCDetailsNVP .= '&' . strtoupper($CCDetailsVar) . '=' . urlencode($CCDetailsVal);
418
-        }
419
-        // PayerInfo Type Fields
420
-        $PayerInfo = isset($DataArray['PayerInfo']) ? $DataArray['PayerInfo'] : array();
421
-        foreach ($PayerInfo as $PayerInfoVar => $PayerInfoVal) {
422
-            $PayerInfoNVP .= '&' . strtoupper($PayerInfoVar) . '=' . urlencode($PayerInfoVal);
423
-        }
424
-        // Payer Name Fields
425
-        $PayerName = isset($DataArray['PayerName']) ? $DataArray['PayerName'] : array();
426
-        foreach ($PayerName as $PayerNameVar => $PayerNameVal) {
427
-            $PayerNameNVP .= '&' . strtoupper($PayerNameVar) . '=' . urlencode($PayerNameVal);
428
-        }
429
-        // Address Fields (Billing)
430
-        $BillingAddress = isset($DataArray['BillingAddress']) ? $DataArray['BillingAddress'] : array();
431
-        foreach ($BillingAddress as $BillingAddressVar => $BillingAddressVal) {
432
-            $BillingAddressNVP .= '&' . strtoupper($BillingAddressVar) . '=' . urlencode($BillingAddressVal);
433
-        }
434
-        // Payment Details Type Fields
435
-        $PaymentDetails = isset($DataArray['PaymentDetails']) ? $DataArray['PaymentDetails'] : array();
436
-        foreach ($PaymentDetails as $PaymentDetailsVar => $PaymentDetailsVal) {
437
-            $PaymentDetailsNVP .= '&' . strtoupper($PaymentDetailsVar) . '=' . urlencode($PaymentDetailsVal);
438
-        }
439
-        // Payment Details Item Type Fields
440
-        $OrderItems = isset($DataArray['OrderItems']) ? $DataArray['OrderItems'] : array();
441
-        $n = 0;
442
-        foreach ($OrderItems as $OrderItemsVar => $OrderItemsVal) {
443
-            $CurrentItem = $OrderItems[$OrderItemsVar];
444
-            foreach ($CurrentItem as $CurrentItemVar => $CurrentItemVal) {
445
-                $OrderItemsNVP .= '&' . strtoupper($CurrentItemVar) . $n . '=' . urlencode($CurrentItemVal);
446
-            }
447
-            $n++;
448
-        }
449
-        // Ship To Address Fields
450
-        $ShippingAddress = isset($DataArray['ShippingAddress']) ? $DataArray['ShippingAddress'] : array();
451
-        foreach ($ShippingAddress as $ShippingAddressVar => $ShippingAddressVal) {
452
-            $ShippingAddressNVP .= '&' . strtoupper($ShippingAddressVar) . '=' . urlencode($ShippingAddressVal);
453
-        }
454
-        // 3D Secure Fields
455
-        $Secure3D = isset($DataArray['Secure3D']) ? $DataArray['Secure3D'] : array();
456
-        foreach ($Secure3D as $Secure3DVar => $Secure3DVal) {
457
-            $Secure3DNVP .= '&' . strtoupper($Secure3DVar) . '=' . urlencode($Secure3DVal);
458
-        }
459
-        // Now that we have each chunk we need to go ahead and append them all together for our entire NVP string
460
-        $NVPRequest = 'USER='
461
-                      . $this->_username
462
-                      . '&PWD='
463
-                      . $this->_password
464
-                      . '&VERSION=64.0'
465
-                      . '&SIGNATURE='
466
-                      . $this->_signature
467
-                      . $DPFieldsNVP
468
-                      . $CCDetailsNVP
469
-                      . $PayerInfoNVP
470
-                      . $PayerNameNVP
471
-                      . $BillingAddressNVP
472
-                      . $PaymentDetailsNVP
473
-                      . $OrderItemsNVP
474
-                      . $ShippingAddressNVP
475
-                      . $Secure3DNVP;
476
-        $NVPResponse = $this->_CURLRequest($NVPRequest);
477
-        $NVPRequestArray = $this->_NVPToArray($NVPRequest);
478
-        $NVPResponseArray = $this->_NVPToArray($NVPResponse);
479
-        $Errors = $this->_GetErrors($NVPResponseArray);
480
-        $NVPResponseArray['ERRORS'] = $Errors;
481
-        $NVPResponseArray['REQUESTDATA'] = $NVPRequestArray;
482
-        $NVPResponseArray['RAWREQUEST'] = $NVPRequest;
483
-        $NVPResponseArray['RAWRESPONSE'] = $NVPResponse;
484
-        return $NVPResponseArray;
485
-    }
486
-
487
-
488
-
489
-    /**
490
-     * @param $Request
491
-     * @return mixed
492
-     */
493
-    private function _CURLRequest($Request)
494
-    {
495
-        $EndPointURL = $this->_debug_mode ? 'https://api-3t.sandbox.paypal.com/nvp' : 'https://api-3t.paypal.com/nvp';
496
-        $curl = curl_init();
497
-        curl_setopt($curl, CURLOPT_VERBOSE, apply_filters('FHEE__EEG_Paypal_Pro__CurlRequest__CURLOPT_VERBOSE', true));
498
-        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
499
-        curl_setopt($curl, CURLOPT_TIMEOUT, 60);
500
-        curl_setopt($curl, CURLOPT_URL, $EndPointURL);
501
-        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
502
-        curl_setopt($curl, CURLOPT_POSTFIELDS, $Request);
503
-        curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
504
-        //execute the curl POST
505
-        $Response = curl_exec($curl);
506
-        curl_close($curl);
507
-        return $Response;
508
-    }
509
-
510
-
511
-
512
-    /**
513
-     * @param $NVPString
514
-     * @return array
515
-     */
516
-    private function _NVPToArray($NVPString)
517
-    {
518
-        // prepare responses into array
519
-        $proArray = array();
520
-        while (strlen($NVPString)) {
521
-            // name
522
-            $keypos = strpos($NVPString, '=');
523
-            $keyval = substr($NVPString, 0, $keypos);
524
-            // value
525
-            $valuepos = strpos($NVPString, '&') ? strpos($NVPString, '&') : strlen($NVPString);
526
-            $valval = substr($NVPString, $keypos + 1, $valuepos - $keypos - 1);
527
-            // decoding the response
528
-            $proArray[$keyval] = urldecode($valval);
529
-            $NVPString = substr($NVPString, $valuepos + 1, strlen($NVPString));
530
-        }
531
-        return $proArray;
532
-    }
533
-
534
-
535
-
536
-    /**
537
-     * @param array $PayPalResult
538
-     * @return bool
539
-     */
540
-    private function _APICallSuccessful($PayPalResult)
541
-    {
542
-        $approved = false;
543
-        // check main response message from PayPal
544
-        if (isset($PayPalResult['ACK']) && ! empty($PayPalResult['ACK'])) {
545
-            $ack = strtoupper($PayPalResult['ACK']);
546
-            $approved = ($ack == 'SUCCESS' || $ack == 'SUCCESSWITHWARNING' || $ack == 'PARTIALSUCCESS') ? true : false;
547
-        }
548
-        return $approved;
549
-    }
550
-
551
-
552
-
553
-    /**
554
-     * @param $DataArray
555
-     * @return array
556
-     */
557
-    private function _GetErrors($DataArray)
558
-    {
559
-        $Errors = array();
560
-        $n = 0;
561
-        while (isset($DataArray['L_ERRORCODE' . $n . ''])) {
562
-            $LErrorCode = isset($DataArray['L_ERRORCODE' . $n . '']) ? $DataArray['L_ERRORCODE' . $n . ''] : '';
563
-            $LShortMessage = isset($DataArray['L_SHORTMESSAGE' . $n . ''])
564
-                ? $DataArray['L_SHORTMESSAGE' . $n . '']
565
-                : '';
566
-            $LLongMessage = isset($DataArray['L_LONGMESSAGE' . $n . ''])
567
-                ? $DataArray['L_LONGMESSAGE' . $n . '']
568
-                : '';
569
-            $LSeverityCode = isset($DataArray['L_SEVERITYCODE' . $n . ''])
570
-                ? $DataArray['L_SEVERITYCODE' . $n . '']
571
-                : '';
572
-            $CurrentItem = array(
573
-                'L_ERRORCODE'    => $LErrorCode,
574
-                'L_SHORTMESSAGE' => $LShortMessage,
575
-                'L_LONGMESSAGE'  => $LLongMessage,
576
-                'L_SEVERITYCODE' => $LSeverityCode,
577
-            );
578
-            array_push($Errors, $CurrentItem);
579
-            $n++;
580
-        }
581
-        return $Errors;
582
-    }
583
-
584
-
585
-
586
-    /**
587
-     *        nothing to see here...  move along....
588
-     *
589
-     * @access protected
590
-     * @param $Errors
591
-     * @return string
592
-     */
593
-    private function _DisplayErrors($Errors)
594
-    {
595
-        $error = '';
596
-        foreach ($Errors as $ErrorVar => $ErrorVal) {
597
-            $CurrentError = $Errors[$ErrorVar];
598
-            foreach ($CurrentError as $CurrentErrorVar => $CurrentErrorVal) {
599
-                $CurrentVarName = '';
600
-                if ($CurrentErrorVar == 'L_ERRORCODE') {
601
-                    $CurrentVarName = 'Error Code';
602
-                } elseif ($CurrentErrorVar == 'L_SHORTMESSAGE') {
603
-                    $CurrentVarName = 'Short Message';
604
-                } elseif ($CurrentErrorVar == 'L_LONGMESSAGE') {
605
-                    $CurrentVarName = 'Long Message';
606
-                } elseif ($CurrentErrorVar == 'L_SEVERITYCODE') {
607
-                    $CurrentVarName = 'Severity Code';
608
-                }
609
-                $error .= '<br />' . $CurrentVarName . ': ' . $CurrentErrorVal;
610
-            }
611
-        }
612
-        return $error;
613
-    }
28
+	/**
29
+	 * @var $_paypal_api_username string
30
+	 */
31
+	protected $_username = null;
32
+
33
+	/**
34
+	 * @var $_password string
35
+	 */
36
+	protected $_password = null;
37
+
38
+	/**
39
+	 * @var $_signature string
40
+	 */
41
+	protected $_signature = null;
42
+
43
+	/**
44
+	 * @var $_credit_card_types array with the keys for credit card types accepted on this account
45
+	 */
46
+	protected $_credit_card_types    = null;
47
+
48
+	protected $_currencies_supported = array(
49
+		'USD',
50
+		'GBP',
51
+		'CAD',
52
+		'AUD',
53
+		'BRL',
54
+		'CHF',
55
+		'CZK',
56
+		'DKK',
57
+		'EUR',
58
+		'HKD',
59
+		'HUF',
60
+		'ILS',
61
+		'JPY',
62
+		'MXN',
63
+		'MYR',
64
+		'NOK',
65
+		'NZD',
66
+		'PHP',
67
+		'PLN',
68
+		'SEK',
69
+		'SGD',
70
+		'THB',
71
+		'TRY',
72
+		'TWD',
73
+		'RUB',
74
+	);
75
+
76
+
77
+
78
+	/**
79
+	 * @param EEI_Payment $payment
80
+	 * @param array       $billing_info {
81
+	 * @type string $credit_card
82
+	 * @type string $credit_card_type
83
+	 * @type string $exp_month always 2 characters
84
+	 * @type string $exp_year always 4 characters
85
+	 * @type string $cvv
86
+	 * }
87
+	 * @see      parent::do_direct_payment for more info
88
+	 * @return EE_Payment|EEI_Payment
89
+	 * @throws EE_Error
90
+	 */
91
+	public function do_direct_payment($payment, $billing_info = null)
92
+	{
93
+		$transaction = $payment->transaction();
94
+		if (! $transaction instanceof EEI_Transaction) {
95
+			throw new EE_Error(
96
+				esc_html__('No transaction for payment while paying with PayPal Pro.', 'event_espresso')
97
+			);
98
+		}
99
+		$primary_registrant = $transaction->primary_registration();
100
+		if (! $primary_registrant instanceof EEI_Registration) {
101
+			throw new EE_Error(
102
+				esc_html__(
103
+					'No primary registration on transaction while paying with PayPal Pro.',
104
+					'event_espresso'
105
+				)
106
+			);
107
+		}
108
+		$attendee = $primary_registrant->attendee();
109
+		if (! $attendee instanceof EEI_Attendee) {
110
+			throw new EE_Error(
111
+				esc_html__(
112
+					'No attendee on primary registration while paying with PayPal Pro.',
113
+					'event_espresso'
114
+				)
115
+			);
116
+		}
117
+		$order_description = substr($this->_format_order_description($payment), 0, 127);
118
+		//charge for the full amount. Show itemized list
119
+		if ($this->_can_easily_itemize_transaction_for($payment)) {
120
+			$item_num = 1;
121
+			$total_line_item = $transaction->total_line_item();
122
+			$order_items = array();
123
+			foreach ($total_line_item->get_items() as $line_item) {
124
+				//ignore line items with a quantity of 0
125
+				if ($line_item->quantity() == 0) {
126
+					continue;
127
+				}
128
+				$item = array(
129
+					// Item Name.  127 char max.
130
+					'l_name'                 => substr(
131
+						$this->_format_line_item_name($line_item, $payment),
132
+						0,
133
+						127
134
+					),
135
+					// Item description.  127 char max.
136
+					'l_desc'                 => substr(
137
+						$this->_format_line_item_desc($line_item, $payment),
138
+						0,
139
+						127
140
+					),
141
+					// Cost of individual item.
142
+					'l_amt'                  => $line_item->unit_price(),
143
+					// Item Number.  127 char max.
144
+					'l_number'               => $item_num++,
145
+					// Item quantity.  Must be any positive integer.
146
+					'l_qty'                  => $line_item->quantity(),
147
+					// Item's sales tax amount.
148
+					'l_taxamt'               => '',
149
+					// eBay auction number of item.
150
+					'l_ebayitemnumber'       => '',
151
+					// eBay transaction ID of purchased item.
152
+					'l_ebayitemauctiontxnid' => '',
153
+					// eBay order ID for the item.
154
+					'l_ebayitemorderid'      => '',
155
+				);
156
+				// add to array of all items
157
+				array_push($order_items, $item);
158
+			}
159
+			$item_amount = $total_line_item->get_items_total();
160
+			$tax_amount = $total_line_item->get_total_tax();
161
+		} else {
162
+			$order_items = array();
163
+			$item_amount = $payment->amount();
164
+			$tax_amount = 0;
165
+			array_push($order_items, array(
166
+				// Item Name.  127 char max.
167
+				'l_name'   => substr(
168
+					$this->_format_partial_payment_line_item_name($payment),
169
+					0,
170
+					127
171
+				),
172
+				// Item description.  127 char max.
173
+				'l_desc'   => substr(
174
+					$this->_format_partial_payment_line_item_desc($payment),
175
+					0,
176
+					127
177
+				),
178
+				// Cost of individual item.
179
+				'l_amt'    => $payment->amount(),
180
+				// Item Number.  127 char max.
181
+				'l_number' => 1,
182
+				// Item quantity.  Must be any positive integer.
183
+				'l_qty'    => 1,
184
+			));
185
+		}
186
+		// Populate data arrays with order data.
187
+		$DPFields = array(
188
+			// How you want to obtain payment ?
189
+			// Authorization indicates the payment is a basic auth subject to settlement with Auth & Capture.
190
+			// Sale indicates that this is a final sale for which you are requesting payment.  Default is Sale.
191
+			'paymentaction'    => 'Sale',
192
+			// Required.  IP address of the payer's browser.
193
+			'ipaddress'        => $_SERVER['REMOTE_ADDR'],
194
+			// Flag to determine whether you want the results returned by FMF.  1 or 0.  Default is 0.
195
+			'returnfmfdetails' => '1',
196
+		);
197
+		$CCDetails = array(
198
+			// Required. Type of credit card.  Visa, MasterCard, Discover, Amex, Maestro, Solo.
199
+			// If Maestro or Solo, the currency code must be GBP.
200
+			//  In addition, either start date or issue number must be specified.
201
+			'creditcardtype' => $billing_info['credit_card_type'],
202
+			// Required.  Credit card number.  No spaces or punctuation.
203
+			'acct'           => $billing_info['credit_card'],
204
+			// Required.  Credit card expiration date.  Format is MMYYYY
205
+			'expdate'        => $billing_info['exp_month'] . $billing_info['exp_year'],
206
+			// Requirements determined by your PayPal account settings.  Security digits for credit card.
207
+			'cvv2'           => $billing_info['cvv'],
208
+		);
209
+		$PayerInfo = array(
210
+			// Email address of payer.
211
+			'email'       => $billing_info['email'],
212
+			// Unique PayPal customer ID for payer.
213
+			'payerid'     => '',
214
+			// Status of payer.  Values are verified or unverified
215
+			'payerstatus' => '',
216
+			// Payer's business name.
217
+			'business'    => '',
218
+		);
219
+		$PayerName = array(
220
+			// Payer's salutation.  20 char max.
221
+			'salutation' => '',
222
+			// Payer's first name.  25 char max.
223
+			'firstname'  => substr($billing_info['first_name'], 0, 25),
224
+			// Payer's middle name.  25 char max.
225
+			'middlename' => '',
226
+			// Payer's last name.  25 char max.
227
+			'lastname'   => substr($billing_info['last_name'], 0, 25),
228
+			// Payer's suffix.  12 char max.
229
+			'suffix'     => '',
230
+		);
231
+		$BillingAddress = array(
232
+			// Required.  First street address.
233
+			'street'      => $billing_info['address'],
234
+			// Second street address.
235
+			'street2'     => $billing_info['address2'],
236
+			// Required.  Name of City.
237
+			'city'        => $billing_info['city'],
238
+			// Required. Name of State or Province.
239
+			'state'       => substr($billing_info['state'], 0, 40),
240
+			// Required.  Country code.
241
+			'countrycode' => $billing_info['country'],
242
+			// Required.  Postal code of payer.
243
+			'zip'         => $billing_info['zip'],
244
+		);
245
+		//check if the registration info contains the needed fields for paypal pro
246
+		//(see https://developer.paypal.com/docs/classic/api/merchant/DoDirectPayment_API_Operation_NVP/)
247
+		if ($attendee->address() && $attendee->city() && $attendee->country_ID()) {
248
+			$use_registration_address_info = true;
249
+		} else {
250
+			$use_registration_address_info = false;
251
+		}
252
+		//so if the attendee has enough data to fill out PayPal Pro's shipping info, use it.
253
+		// If not, use the billing info again
254
+		$ShippingAddress = array(
255
+			'shiptoname'     => substr($use_registration_address_info
256
+				? $attendee->full_name()
257
+				: $billing_info['first_name'] . ' ' . $billing_info['last_name'], 0, 32),
258
+			'shiptostreet'   => substr($use_registration_address_info
259
+				? $attendee->address()
260
+				: $billing_info['address'], 0, 100),
261
+			'shiptostreet2'  => substr($use_registration_address_info
262
+				? $attendee->address2() : $billing_info['address2'], 0, 100),
263
+			'shiptocity'     => substr($use_registration_address_info
264
+				? $attendee->city()
265
+				: $billing_info['city'], 0, 40),
266
+			'state'          => substr($use_registration_address_info
267
+				? $attendee->state_name()
268
+				: $billing_info['state'], 0, 40),
269
+			'shiptocountry'  => $use_registration_address_info
270
+				? $attendee->country_ID()
271
+				: $billing_info['country'],
272
+			'shiptozip'      => substr($use_registration_address_info
273
+				? $attendee->zip()
274
+				: $billing_info['zip'], 0, 20),
275
+			'shiptophonenum' => substr($use_registration_address_info
276
+				? $attendee->phone()
277
+				: $billing_info['phone'], 0, 20),
278
+		);
279
+		$PaymentDetails = array(
280
+			// Required.  Total amount of order, including shipping, handling, and tax.
281
+			'amt'          => $this->format_currency($payment->amount()),
282
+			// Required.  Three-letter currency code.  Default is USD.
283
+			'currencycode' => $payment->currency_code(),
284
+			// Required if you include itemized cart details. (L_AMTn, etc.)
285
+			//Subtotal of items not including S&H, or tax.
286
+			'itemamt'      => $this->format_currency($item_amount),//
287
+			// Total shipping costs for the order.  If you specify shippingamt, you must also specify itemamt.
288
+			'shippingamt'  => '',
289
+			// Total handling costs for the order.  If you specify handlingamt, you must also specify itemamt.
290
+			'handlingamt'  => '',
291
+			// Required if you specify itemized cart tax details.
292
+			// Sum of tax for all items on the order.  Total sales tax.
293
+			'taxamt'       => $this->format_currency($tax_amount),
294
+			// Description of the order the customer is purchasing.  127 char max.
295
+			'desc'         => $order_description,
296
+			// Free-form field for your own use.  256 char max.
297
+			'custom'       => $primary_registrant ? $primary_registrant->ID() : '',
298
+			// Your own invoice or tracking number
299
+			'invnum'       => wp_generate_password(12, false),//$transaction->ID(),
300
+			// URL for receiving Instant Payment Notifications.  This overrides what your profile is set to use.
301
+			'notifyurl'    => '',
302
+			'buttonsource' => 'EventEspresso_SP',//EE will blow up if you change this
303
+		);
304
+		// Wrap all data arrays into a single, "master" array which will be passed into the class function.
305
+		$PayPalRequestData = array(
306
+			'DPFields'        => $DPFields,
307
+			'CCDetails'       => $CCDetails,
308
+			'PayerInfo'       => $PayerInfo,
309
+			'PayerName'       => $PayerName,
310
+			'BillingAddress'  => $BillingAddress,
311
+			'ShippingAddress' => $ShippingAddress,
312
+			'PaymentDetails'  => $PaymentDetails,
313
+			'OrderItems'      => $order_items,
314
+		);
315
+		$this->_log_clean_request($PayPalRequestData, $payment);
316
+		try {
317
+			$PayPalResult = $this->prep_and_curl_request($PayPalRequestData);
318
+			//remove PCI-sensitive data so it doesn't get stored
319
+			$PayPalResult = $this->_log_clean_response($PayPalResult, $payment);
320
+			$message = isset($PayPalResult['L_LONGMESSAGE0']) ? $PayPalResult['L_LONGMESSAGE0'] : $PayPalResult['ACK'];
321
+			if (empty($PayPalResult['RAWRESPONSE'])) {
322
+				$payment->set_status($this->_pay_model->failed_status());
323
+				$payment->set_gateway_response(__('No response received from Paypal Pro', 'event_espresso'));
324
+				$payment->set_details($PayPalResult);
325
+			} else {
326
+				if ($this->_APICallSuccessful($PayPalResult)) {
327
+					$payment->set_status($this->_pay_model->approved_status());
328
+				} else {
329
+					$payment->set_status($this->_pay_model->declined_status());
330
+				}
331
+				//make sure we interpret the AMT as a float, not an international string
332
+				// (where periods are thousand separators)
333
+				$payment->set_amount(isset($PayPalResult['AMT']) ? floatval($PayPalResult['AMT']) : 0);
334
+				$payment->set_gateway_response($message);
335
+				$payment->set_txn_id_chq_nmbr(isset($PayPalResult['TRANSACTIONID'])
336
+					? $PayPalResult['TRANSACTIONID']
337
+					: null);
338
+				$primary_registration_code = $primary_registrant instanceof EE_Registration
339
+					? $primary_registrant->reg_code()
340
+					: '';
341
+				$payment->set_extra_accntng($primary_registration_code);
342
+				$payment->set_details($PayPalResult);
343
+			}
344
+		} catch (Exception $e) {
345
+			$payment->set_status($this->_pay_model->failed_status());
346
+			$payment->set_gateway_response($e->getMessage());
347
+		}
348
+		//$payment->set_status( $this->_pay_model->declined_status() );
349
+		//$payment->set_gateway_response( '' );
350
+		return $payment;
351
+	}
352
+
353
+
354
+
355
+	/**
356
+	 * CLeans out sensitive CC data and then logs it, and returns the cleaned request
357
+	 *
358
+	 * @param array       $request
359
+	 * @param EEI_Payment $payment
360
+	 * @return void
361
+	 */
362
+	private function _log_clean_request($request, $payment)
363
+	{
364
+		$cleaned_request_data = $request;
365
+		unset($cleaned_request_data['CCDetails']['acct']);
366
+		unset($cleaned_request_data['CCDetails']['cvv2']);
367
+		unset($cleaned_request_data['CCDetails']['expdate']);
368
+		$this->log(array('Paypal Request' => $cleaned_request_data), $payment);
369
+	}
370
+
371
+
372
+
373
+	/**
374
+	 * Cleans the response, logs it, and returns it
375
+	 *
376
+	 * @param array       $response
377
+	 * @param EEI_Payment $payment
378
+	 * @return array cleaned
379
+	 */
380
+	private function _log_clean_response($response, $payment)
381
+	{
382
+		unset($response['REQUESTDATA']['CREDITCARDTYPE']);
383
+		unset($response['REQUESTDATA']['ACCT']);
384
+		unset($response['REQUESTDATA']['EXPDATE']);
385
+		unset($response['REQUESTDATA']['CVV2']);
386
+		unset($response['RAWREQUEST']);
387
+		$this->log(array('Paypal Response' => $response), $payment);
388
+		return $response;
389
+	}
390
+
391
+
392
+
393
+	/**
394
+	 * @param $DataArray
395
+	 * @return array
396
+	 */
397
+	private function prep_and_curl_request($DataArray)
398
+	{
399
+		// Create empty holders for each portion of the NVP string
400
+		$DPFieldsNVP = '&METHOD=DoDirectPayment&BUTTONSOURCE=AngellEYE_PHP_Class_DDP';
401
+		$CCDetailsNVP = '';
402
+		$PayerInfoNVP = '';
403
+		$PayerNameNVP = '';
404
+		$BillingAddressNVP = '';
405
+		$ShippingAddressNVP = '';
406
+		$PaymentDetailsNVP = '';
407
+		$OrderItemsNVP = '';
408
+		$Secure3DNVP = '';
409
+		// DP Fields
410
+		$DPFields = isset($DataArray['DPFields']) ? $DataArray['DPFields'] : array();
411
+		foreach ($DPFields as $DPFieldsVar => $DPFieldsVal) {
412
+			$DPFieldsNVP .= '&' . strtoupper($DPFieldsVar) . '=' . urlencode($DPFieldsVal);
413
+		}
414
+		// CC Details Fields
415
+		$CCDetails = isset($DataArray['CCDetails']) ? $DataArray['CCDetails'] : array();
416
+		foreach ($CCDetails as $CCDetailsVar => $CCDetailsVal) {
417
+			$CCDetailsNVP .= '&' . strtoupper($CCDetailsVar) . '=' . urlencode($CCDetailsVal);
418
+		}
419
+		// PayerInfo Type Fields
420
+		$PayerInfo = isset($DataArray['PayerInfo']) ? $DataArray['PayerInfo'] : array();
421
+		foreach ($PayerInfo as $PayerInfoVar => $PayerInfoVal) {
422
+			$PayerInfoNVP .= '&' . strtoupper($PayerInfoVar) . '=' . urlencode($PayerInfoVal);
423
+		}
424
+		// Payer Name Fields
425
+		$PayerName = isset($DataArray['PayerName']) ? $DataArray['PayerName'] : array();
426
+		foreach ($PayerName as $PayerNameVar => $PayerNameVal) {
427
+			$PayerNameNVP .= '&' . strtoupper($PayerNameVar) . '=' . urlencode($PayerNameVal);
428
+		}
429
+		// Address Fields (Billing)
430
+		$BillingAddress = isset($DataArray['BillingAddress']) ? $DataArray['BillingAddress'] : array();
431
+		foreach ($BillingAddress as $BillingAddressVar => $BillingAddressVal) {
432
+			$BillingAddressNVP .= '&' . strtoupper($BillingAddressVar) . '=' . urlencode($BillingAddressVal);
433
+		}
434
+		// Payment Details Type Fields
435
+		$PaymentDetails = isset($DataArray['PaymentDetails']) ? $DataArray['PaymentDetails'] : array();
436
+		foreach ($PaymentDetails as $PaymentDetailsVar => $PaymentDetailsVal) {
437
+			$PaymentDetailsNVP .= '&' . strtoupper($PaymentDetailsVar) . '=' . urlencode($PaymentDetailsVal);
438
+		}
439
+		// Payment Details Item Type Fields
440
+		$OrderItems = isset($DataArray['OrderItems']) ? $DataArray['OrderItems'] : array();
441
+		$n = 0;
442
+		foreach ($OrderItems as $OrderItemsVar => $OrderItemsVal) {
443
+			$CurrentItem = $OrderItems[$OrderItemsVar];
444
+			foreach ($CurrentItem as $CurrentItemVar => $CurrentItemVal) {
445
+				$OrderItemsNVP .= '&' . strtoupper($CurrentItemVar) . $n . '=' . urlencode($CurrentItemVal);
446
+			}
447
+			$n++;
448
+		}
449
+		// Ship To Address Fields
450
+		$ShippingAddress = isset($DataArray['ShippingAddress']) ? $DataArray['ShippingAddress'] : array();
451
+		foreach ($ShippingAddress as $ShippingAddressVar => $ShippingAddressVal) {
452
+			$ShippingAddressNVP .= '&' . strtoupper($ShippingAddressVar) . '=' . urlencode($ShippingAddressVal);
453
+		}
454
+		// 3D Secure Fields
455
+		$Secure3D = isset($DataArray['Secure3D']) ? $DataArray['Secure3D'] : array();
456
+		foreach ($Secure3D as $Secure3DVar => $Secure3DVal) {
457
+			$Secure3DNVP .= '&' . strtoupper($Secure3DVar) . '=' . urlencode($Secure3DVal);
458
+		}
459
+		// Now that we have each chunk we need to go ahead and append them all together for our entire NVP string
460
+		$NVPRequest = 'USER='
461
+					  . $this->_username
462
+					  . '&PWD='
463
+					  . $this->_password
464
+					  . '&VERSION=64.0'
465
+					  . '&SIGNATURE='
466
+					  . $this->_signature
467
+					  . $DPFieldsNVP
468
+					  . $CCDetailsNVP
469
+					  . $PayerInfoNVP
470
+					  . $PayerNameNVP
471
+					  . $BillingAddressNVP
472
+					  . $PaymentDetailsNVP
473
+					  . $OrderItemsNVP
474
+					  . $ShippingAddressNVP
475
+					  . $Secure3DNVP;
476
+		$NVPResponse = $this->_CURLRequest($NVPRequest);
477
+		$NVPRequestArray = $this->_NVPToArray($NVPRequest);
478
+		$NVPResponseArray = $this->_NVPToArray($NVPResponse);
479
+		$Errors = $this->_GetErrors($NVPResponseArray);
480
+		$NVPResponseArray['ERRORS'] = $Errors;
481
+		$NVPResponseArray['REQUESTDATA'] = $NVPRequestArray;
482
+		$NVPResponseArray['RAWREQUEST'] = $NVPRequest;
483
+		$NVPResponseArray['RAWRESPONSE'] = $NVPResponse;
484
+		return $NVPResponseArray;
485
+	}
486
+
487
+
488
+
489
+	/**
490
+	 * @param $Request
491
+	 * @return mixed
492
+	 */
493
+	private function _CURLRequest($Request)
494
+	{
495
+		$EndPointURL = $this->_debug_mode ? 'https://api-3t.sandbox.paypal.com/nvp' : 'https://api-3t.paypal.com/nvp';
496
+		$curl = curl_init();
497
+		curl_setopt($curl, CURLOPT_VERBOSE, apply_filters('FHEE__EEG_Paypal_Pro__CurlRequest__CURLOPT_VERBOSE', true));
498
+		curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
499
+		curl_setopt($curl, CURLOPT_TIMEOUT, 60);
500
+		curl_setopt($curl, CURLOPT_URL, $EndPointURL);
501
+		curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
502
+		curl_setopt($curl, CURLOPT_POSTFIELDS, $Request);
503
+		curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
504
+		//execute the curl POST
505
+		$Response = curl_exec($curl);
506
+		curl_close($curl);
507
+		return $Response;
508
+	}
509
+
510
+
511
+
512
+	/**
513
+	 * @param $NVPString
514
+	 * @return array
515
+	 */
516
+	private function _NVPToArray($NVPString)
517
+	{
518
+		// prepare responses into array
519
+		$proArray = array();
520
+		while (strlen($NVPString)) {
521
+			// name
522
+			$keypos = strpos($NVPString, '=');
523
+			$keyval = substr($NVPString, 0, $keypos);
524
+			// value
525
+			$valuepos = strpos($NVPString, '&') ? strpos($NVPString, '&') : strlen($NVPString);
526
+			$valval = substr($NVPString, $keypos + 1, $valuepos - $keypos - 1);
527
+			// decoding the response
528
+			$proArray[$keyval] = urldecode($valval);
529
+			$NVPString = substr($NVPString, $valuepos + 1, strlen($NVPString));
530
+		}
531
+		return $proArray;
532
+	}
533
+
534
+
535
+
536
+	/**
537
+	 * @param array $PayPalResult
538
+	 * @return bool
539
+	 */
540
+	private function _APICallSuccessful($PayPalResult)
541
+	{
542
+		$approved = false;
543
+		// check main response message from PayPal
544
+		if (isset($PayPalResult['ACK']) && ! empty($PayPalResult['ACK'])) {
545
+			$ack = strtoupper($PayPalResult['ACK']);
546
+			$approved = ($ack == 'SUCCESS' || $ack == 'SUCCESSWITHWARNING' || $ack == 'PARTIALSUCCESS') ? true : false;
547
+		}
548
+		return $approved;
549
+	}
550
+
551
+
552
+
553
+	/**
554
+	 * @param $DataArray
555
+	 * @return array
556
+	 */
557
+	private function _GetErrors($DataArray)
558
+	{
559
+		$Errors = array();
560
+		$n = 0;
561
+		while (isset($DataArray['L_ERRORCODE' . $n . ''])) {
562
+			$LErrorCode = isset($DataArray['L_ERRORCODE' . $n . '']) ? $DataArray['L_ERRORCODE' . $n . ''] : '';
563
+			$LShortMessage = isset($DataArray['L_SHORTMESSAGE' . $n . ''])
564
+				? $DataArray['L_SHORTMESSAGE' . $n . '']
565
+				: '';
566
+			$LLongMessage = isset($DataArray['L_LONGMESSAGE' . $n . ''])
567
+				? $DataArray['L_LONGMESSAGE' . $n . '']
568
+				: '';
569
+			$LSeverityCode = isset($DataArray['L_SEVERITYCODE' . $n . ''])
570
+				? $DataArray['L_SEVERITYCODE' . $n . '']
571
+				: '';
572
+			$CurrentItem = array(
573
+				'L_ERRORCODE'    => $LErrorCode,
574
+				'L_SHORTMESSAGE' => $LShortMessage,
575
+				'L_LONGMESSAGE'  => $LLongMessage,
576
+				'L_SEVERITYCODE' => $LSeverityCode,
577
+			);
578
+			array_push($Errors, $CurrentItem);
579
+			$n++;
580
+		}
581
+		return $Errors;
582
+	}
583
+
584
+
585
+
586
+	/**
587
+	 *        nothing to see here...  move along....
588
+	 *
589
+	 * @access protected
590
+	 * @param $Errors
591
+	 * @return string
592
+	 */
593
+	private function _DisplayErrors($Errors)
594
+	{
595
+		$error = '';
596
+		foreach ($Errors as $ErrorVar => $ErrorVal) {
597
+			$CurrentError = $Errors[$ErrorVar];
598
+			foreach ($CurrentError as $CurrentErrorVar => $CurrentErrorVal) {
599
+				$CurrentVarName = '';
600
+				if ($CurrentErrorVar == 'L_ERRORCODE') {
601
+					$CurrentVarName = 'Error Code';
602
+				} elseif ($CurrentErrorVar == 'L_SHORTMESSAGE') {
603
+					$CurrentVarName = 'Short Message';
604
+				} elseif ($CurrentErrorVar == 'L_LONGMESSAGE') {
605
+					$CurrentVarName = 'Long Message';
606
+				} elseif ($CurrentErrorVar == 'L_SEVERITYCODE') {
607
+					$CurrentVarName = 'Severity Code';
608
+				}
609
+				$error .= '<br />' . $CurrentVarName . ': ' . $CurrentErrorVal;
610
+			}
611
+		}
612
+		return $error;
613
+	}
614 614
 }
615 615
 // End of file EEG_Paypal_Pro.gateway.php
Please login to merge, or discard this patch.
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (! defined('EVENT_ESPRESSO_VERSION')) {
2
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3 3
     exit('No direct script access allowed');
4 4
 }
5 5
 
@@ -91,13 +91,13 @@  discard block
 block discarded – undo
91 91
     public function do_direct_payment($payment, $billing_info = null)
92 92
     {
93 93
         $transaction = $payment->transaction();
94
-        if (! $transaction instanceof EEI_Transaction) {
94
+        if ( ! $transaction instanceof EEI_Transaction) {
95 95
             throw new EE_Error(
96 96
                 esc_html__('No transaction for payment while paying with PayPal Pro.', 'event_espresso')
97 97
             );
98 98
         }
99 99
         $primary_registrant = $transaction->primary_registration();
100
-        if (! $primary_registrant instanceof EEI_Registration) {
100
+        if ( ! $primary_registrant instanceof EEI_Registration) {
101 101
             throw new EE_Error(
102 102
                 esc_html__(
103 103
                     'No primary registration on transaction while paying with PayPal Pro.',
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
             );
107 107
         }
108 108
         $attendee = $primary_registrant->attendee();
109
-        if (! $attendee instanceof EEI_Attendee) {
109
+        if ( ! $attendee instanceof EEI_Attendee) {
110 110
             throw new EE_Error(
111 111
                 esc_html__(
112 112
                     'No attendee on primary registration while paying with PayPal Pro.',
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
             // Required.  Credit card number.  No spaces or punctuation.
203 203
             'acct'           => $billing_info['credit_card'],
204 204
             // Required.  Credit card expiration date.  Format is MMYYYY
205
-            'expdate'        => $billing_info['exp_month'] . $billing_info['exp_year'],
205
+            'expdate'        => $billing_info['exp_month'].$billing_info['exp_year'],
206 206
             // Requirements determined by your PayPal account settings.  Security digits for credit card.
207 207
             'cvv2'           => $billing_info['cvv'],
208 208
         );
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
         $ShippingAddress = array(
255 255
             'shiptoname'     => substr($use_registration_address_info
256 256
                 ? $attendee->full_name()
257
-                : $billing_info['first_name'] . ' ' . $billing_info['last_name'], 0, 32),
257
+                : $billing_info['first_name'].' '.$billing_info['last_name'], 0, 32),
258 258
             'shiptostreet'   => substr($use_registration_address_info
259 259
                 ? $attendee->address()
260 260
                 : $billing_info['address'], 0, 100),
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
             'currencycode' => $payment->currency_code(),
284 284
             // Required if you include itemized cart details. (L_AMTn, etc.)
285 285
             //Subtotal of items not including S&H, or tax.
286
-            'itemamt'      => $this->format_currency($item_amount),//
286
+            'itemamt'      => $this->format_currency($item_amount), //
287 287
             // Total shipping costs for the order.  If you specify shippingamt, you must also specify itemamt.
288 288
             'shippingamt'  => '',
289 289
             // Total handling costs for the order.  If you specify handlingamt, you must also specify itemamt.
@@ -296,10 +296,10 @@  discard block
 block discarded – undo
296 296
             // Free-form field for your own use.  256 char max.
297 297
             'custom'       => $primary_registrant ? $primary_registrant->ID() : '',
298 298
             // Your own invoice or tracking number
299
-            'invnum'       => wp_generate_password(12, false),//$transaction->ID(),
299
+            'invnum'       => wp_generate_password(12, false), //$transaction->ID(),
300 300
             // URL for receiving Instant Payment Notifications.  This overrides what your profile is set to use.
301 301
             'notifyurl'    => '',
302
-            'buttonsource' => 'EventEspresso_SP',//EE will blow up if you change this
302
+            'buttonsource' => 'EventEspresso_SP', //EE will blow up if you change this
303 303
         );
304 304
         // Wrap all data arrays into a single, "master" array which will be passed into the class function.
305 305
         $PayPalRequestData = array(
@@ -409,32 +409,32 @@  discard block
 block discarded – undo
409 409
         // DP Fields
410 410
         $DPFields = isset($DataArray['DPFields']) ? $DataArray['DPFields'] : array();
411 411
         foreach ($DPFields as $DPFieldsVar => $DPFieldsVal) {
412
-            $DPFieldsNVP .= '&' . strtoupper($DPFieldsVar) . '=' . urlencode($DPFieldsVal);
412
+            $DPFieldsNVP .= '&'.strtoupper($DPFieldsVar).'='.urlencode($DPFieldsVal);
413 413
         }
414 414
         // CC Details Fields
415 415
         $CCDetails = isset($DataArray['CCDetails']) ? $DataArray['CCDetails'] : array();
416 416
         foreach ($CCDetails as $CCDetailsVar => $CCDetailsVal) {
417
-            $CCDetailsNVP .= '&' . strtoupper($CCDetailsVar) . '=' . urlencode($CCDetailsVal);
417
+            $CCDetailsNVP .= '&'.strtoupper($CCDetailsVar).'='.urlencode($CCDetailsVal);
418 418
         }
419 419
         // PayerInfo Type Fields
420 420
         $PayerInfo = isset($DataArray['PayerInfo']) ? $DataArray['PayerInfo'] : array();
421 421
         foreach ($PayerInfo as $PayerInfoVar => $PayerInfoVal) {
422
-            $PayerInfoNVP .= '&' . strtoupper($PayerInfoVar) . '=' . urlencode($PayerInfoVal);
422
+            $PayerInfoNVP .= '&'.strtoupper($PayerInfoVar).'='.urlencode($PayerInfoVal);
423 423
         }
424 424
         // Payer Name Fields
425 425
         $PayerName = isset($DataArray['PayerName']) ? $DataArray['PayerName'] : array();
426 426
         foreach ($PayerName as $PayerNameVar => $PayerNameVal) {
427
-            $PayerNameNVP .= '&' . strtoupper($PayerNameVar) . '=' . urlencode($PayerNameVal);
427
+            $PayerNameNVP .= '&'.strtoupper($PayerNameVar).'='.urlencode($PayerNameVal);
428 428
         }
429 429
         // Address Fields (Billing)
430 430
         $BillingAddress = isset($DataArray['BillingAddress']) ? $DataArray['BillingAddress'] : array();
431 431
         foreach ($BillingAddress as $BillingAddressVar => $BillingAddressVal) {
432
-            $BillingAddressNVP .= '&' . strtoupper($BillingAddressVar) . '=' . urlencode($BillingAddressVal);
432
+            $BillingAddressNVP .= '&'.strtoupper($BillingAddressVar).'='.urlencode($BillingAddressVal);
433 433
         }
434 434
         // Payment Details Type Fields
435 435
         $PaymentDetails = isset($DataArray['PaymentDetails']) ? $DataArray['PaymentDetails'] : array();
436 436
         foreach ($PaymentDetails as $PaymentDetailsVar => $PaymentDetailsVal) {
437
-            $PaymentDetailsNVP .= '&' . strtoupper($PaymentDetailsVar) . '=' . urlencode($PaymentDetailsVal);
437
+            $PaymentDetailsNVP .= '&'.strtoupper($PaymentDetailsVar).'='.urlencode($PaymentDetailsVal);
438 438
         }
439 439
         // Payment Details Item Type Fields
440 440
         $OrderItems = isset($DataArray['OrderItems']) ? $DataArray['OrderItems'] : array();
@@ -442,19 +442,19 @@  discard block
 block discarded – undo
442 442
         foreach ($OrderItems as $OrderItemsVar => $OrderItemsVal) {
443 443
             $CurrentItem = $OrderItems[$OrderItemsVar];
444 444
             foreach ($CurrentItem as $CurrentItemVar => $CurrentItemVal) {
445
-                $OrderItemsNVP .= '&' . strtoupper($CurrentItemVar) . $n . '=' . urlencode($CurrentItemVal);
445
+                $OrderItemsNVP .= '&'.strtoupper($CurrentItemVar).$n.'='.urlencode($CurrentItemVal);
446 446
             }
447 447
             $n++;
448 448
         }
449 449
         // Ship To Address Fields
450 450
         $ShippingAddress = isset($DataArray['ShippingAddress']) ? $DataArray['ShippingAddress'] : array();
451 451
         foreach ($ShippingAddress as $ShippingAddressVar => $ShippingAddressVal) {
452
-            $ShippingAddressNVP .= '&' . strtoupper($ShippingAddressVar) . '=' . urlencode($ShippingAddressVal);
452
+            $ShippingAddressNVP .= '&'.strtoupper($ShippingAddressVar).'='.urlencode($ShippingAddressVal);
453 453
         }
454 454
         // 3D Secure Fields
455 455
         $Secure3D = isset($DataArray['Secure3D']) ? $DataArray['Secure3D'] : array();
456 456
         foreach ($Secure3D as $Secure3DVar => $Secure3DVal) {
457
-            $Secure3DNVP .= '&' . strtoupper($Secure3DVar) . '=' . urlencode($Secure3DVal);
457
+            $Secure3DNVP .= '&'.strtoupper($Secure3DVar).'='.urlencode($Secure3DVal);
458 458
         }
459 459
         // Now that we have each chunk we need to go ahead and append them all together for our entire NVP string
460 460
         $NVPRequest = 'USER='
@@ -558,16 +558,16 @@  discard block
 block discarded – undo
558 558
     {
559 559
         $Errors = array();
560 560
         $n = 0;
561
-        while (isset($DataArray['L_ERRORCODE' . $n . ''])) {
562
-            $LErrorCode = isset($DataArray['L_ERRORCODE' . $n . '']) ? $DataArray['L_ERRORCODE' . $n . ''] : '';
563
-            $LShortMessage = isset($DataArray['L_SHORTMESSAGE' . $n . ''])
564
-                ? $DataArray['L_SHORTMESSAGE' . $n . '']
561
+        while (isset($DataArray['L_ERRORCODE'.$n.''])) {
562
+            $LErrorCode = isset($DataArray['L_ERRORCODE'.$n.'']) ? $DataArray['L_ERRORCODE'.$n.''] : '';
563
+            $LShortMessage = isset($DataArray['L_SHORTMESSAGE'.$n.''])
564
+                ? $DataArray['L_SHORTMESSAGE'.$n.'']
565 565
                 : '';
566
-            $LLongMessage = isset($DataArray['L_LONGMESSAGE' . $n . ''])
567
-                ? $DataArray['L_LONGMESSAGE' . $n . '']
566
+            $LLongMessage = isset($DataArray['L_LONGMESSAGE'.$n.''])
567
+                ? $DataArray['L_LONGMESSAGE'.$n.'']
568 568
                 : '';
569
-            $LSeverityCode = isset($DataArray['L_SEVERITYCODE' . $n . ''])
570
-                ? $DataArray['L_SEVERITYCODE' . $n . '']
569
+            $LSeverityCode = isset($DataArray['L_SEVERITYCODE'.$n.''])
570
+                ? $DataArray['L_SEVERITYCODE'.$n.'']
571 571
                 : '';
572 572
             $CurrentItem = array(
573 573
                 'L_ERRORCODE'    => $LErrorCode,
@@ -606,7 +606,7 @@  discard block
 block discarded – undo
606 606
                 } elseif ($CurrentErrorVar == 'L_SEVERITYCODE') {
607 607
                     $CurrentVarName = 'Severity Code';
608 608
                 }
609
-                $error .= '<br />' . $CurrentVarName . ': ' . $CurrentErrorVal;
609
+                $error .= '<br />'.$CurrentVarName.': '.$CurrentErrorVal;
610 610
             }
611 611
         }
612 612
         return $error;
Please login to merge, or discard this patch.
payment_methods/Invoice/EE_PMT_Invoice.pm.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (!defined('EVENT_ESPRESSO_VERSION'))
3
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
4 4
 	exit('No direct script access allowed');
5 5
 
6 6
 /**
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
  *
26 26
  * ------------------------------------------------------------------------
27 27
  */
28
-class EE_PMT_Invoice extends EE_PMT_Base{
28
+class EE_PMT_Invoice extends EE_PMT_Base {
29 29
 
30 30
 
31 31
 
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	public function __construct($pm_instance = NULL) {
38 38
 		$this->_pretty_name = esc_html__("Invoice", 'event_espresso');
39 39
 		$this->_default_description = sprintf(
40
-			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' ),
40
+			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'),
41 41
 			'<br />'
42 42
 		);
43 43
 		parent::__construct($pm_instance);
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 	 * @param \EE_Transaction $transaction
52 52
 	 * @return NULL
53 53
 	 */
54
-	public function generate_new_billing_form( EE_Transaction $transaction = NULL ) {
54
+	public function generate_new_billing_form(EE_Transaction $transaction = NULL) {
55 55
 		return NULL;
56 56
 	}
57 57
 
@@ -64,53 +64,53 @@  discard block
 block discarded – undo
64 64
 	public function generate_new_settings_form() {
65 65
 		$pdf_payee_input_name = 'pdf_payee_name';
66 66
 		$confirmation_text_input_name = 'page_confirmation_text';
67
-		$form =  new EE_Payment_Method_Form(array(
67
+		$form = new EE_Payment_Method_Form(array(
68 68
 //				'payment_method_type' => $this,
69 69
 				'extra_meta_inputs'=>array(
70 70
 					$pdf_payee_input_name => new EE_Text_Input(array(
71
-						'html_label_text' => sprintf( esc_html__( 'Payee Name %s', 'event_espresso' ), $this->get_help_tab_link())
71
+						'html_label_text' => sprintf(esc_html__('Payee Name %s', 'event_espresso'), $this->get_help_tab_link())
72 72
 					)),
73 73
 					'pdf_payee_email' => new EE_Email_Input(array(
74
-						'html_label_text' => sprintf( esc_html__( 'Payee Email %s', 'event_espresso' ), $this->get_help_tab_link()),
74
+						'html_label_text' => sprintf(esc_html__('Payee Email %s', 'event_espresso'), $this->get_help_tab_link()),
75 75
 					)),
76 76
 					'pdf_payee_tax_number' => new EE_Text_Input(array(
77
-						'html_label_text' => sprintf( esc_html__( 'Payee Tax Number %s', 'event_espresso' ), $this->get_help_tab_link()),
77
+						'html_label_text' => sprintf(esc_html__('Payee Tax Number %s', 'event_espresso'), $this->get_help_tab_link()),
78 78
 						)),
79
-					'pdf_payee_address' => new EE_Text_Area_Input( array(
80
-						'html_label_text' => sprintf( esc_html__( 'Payee Address %s', 'event_espresso' ), $this->get_help_tab_link() ),
81
-						'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
79
+					'pdf_payee_address' => new EE_Text_Area_Input(array(
80
+						'html_label_text' => sprintf(esc_html__('Payee Address %s', 'event_espresso'), $this->get_help_tab_link()),
81
+						'validation_strategies' => array(new EE_Full_HTML_Validation_Strategy()),
82 82
 					)),
83 83
 					'pdf_instructions'=>new EE_Text_Area_Input(array(
84
-						'html_label_text'=>  sprintf(esc_html__("Instructions %s", "event_espresso"),  $this->get_help_tab_link()),
84
+						'html_label_text'=>  sprintf(esc_html__("Instructions %s", "event_espresso"), $this->get_help_tab_link()),
85 85
 						'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'),
86
-						'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
86
+						'validation_strategies' => array(new EE_Full_HTML_Validation_Strategy()),
87 87
 					)),
88 88
 					'pdf_logo_image'=>new EE_Admin_File_Uploader_Input(array(
89
-						'html_label_text'=>  sprintf(esc_html__("Logo Image %s", "event_espresso"),  $this->get_help_tab_link()),
89
+						'html_label_text'=>  sprintf(esc_html__("Logo Image %s", "event_espresso"), $this->get_help_tab_link()),
90 90
 						'default'=>  EE_Config::instance()->organization->logo_url,
91 91
 						'html_help_text'=>  esc_html__("(Logo for the top left of the invoice)", 'event_espresso'),
92 92
 					)),
93 93
 					$confirmation_text_input_name =>new EE_Text_Area_Input(array(
94
-						'html_label_text'=>  sprintf(esc_html__("Confirmation Text %s", "event_espresso"),  $this->get_help_tab_link()),
94
+						'html_label_text'=>  sprintf(esc_html__("Confirmation Text %s", "event_espresso"), $this->get_help_tab_link()),
95 95
 						'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'), 
96
-						'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
96
+						'validation_strategies' => array(new EE_Full_HTML_Validation_Strategy()),
97 97
 					)),
98 98
 					'page_extra_info'=>new EE_Text_Area_Input(array(
99
-						'html_label_text'=>  sprintf(esc_html__("Extra Info %s", "event_espresso"),  $this->get_help_tab_link()),
100
-						'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
99
+						'html_label_text'=>  sprintf(esc_html__("Extra Info %s", "event_espresso"), $this->get_help_tab_link()),
100
+						'validation_strategies' => array(new EE_Full_HTML_Validation_Strategy()),
101 101
 					)),
102 102
 				),
103 103
 				'include'=>array(
104
-					'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',
105
-					$pdf_payee_input_name, 'pdf_payee_email', 'pdf_payee_tax_number', 'pdf_payee_address', 'pdf_instructions','pdf_logo_image',
104
+					'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',
105
+					$pdf_payee_input_name, 'pdf_payee_email', 'pdf_payee_tax_number', 'pdf_payee_address', 'pdf_instructions', 'pdf_logo_image',
106 106
 					$confirmation_text_input_name, 'page_extra_info'),
107 107
 			));
108 108
 		$form->add_subsections(
109
-			array( 'header1' => new EE_Form_Section_HTML_From_Template( 'payment_methods/Invoice/templates/invoice_settings_header_display.template.php' )),
109
+			array('header1' => new EE_Form_Section_HTML_From_Template('payment_methods/Invoice/templates/invoice_settings_header_display.template.php')),
110 110
 			$pdf_payee_input_name
111 111
 		);
112 112
 		$form->add_subsections(
113
-			array( 'header2'=>new EE_Form_Section_HTML_From_Template( 'payment_methods/Invoice/templates/invoice_settings_header_gateway.template.php' )),
113
+			array('header2'=>new EE_Form_Section_HTML_From_Template('payment_methods/Invoice/templates/invoice_settings_header_gateway.template.php')),
114 114
 			$confirmation_text_input_name
115 115
 		);
116 116
 		return $form;
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 	 * @see EE_PMT_Base::help_tabs_config()
124 124
 	 * @return array
125 125
 	 */
126
-	public function help_tabs_config(){
126
+	public function help_tabs_config() {
127 127
 		return array(
128 128
 			$this->get_help_tab_name() => array(
129 129
 				'title' => esc_html__('Invoice Settings', 'event_espresso'),
@@ -141,16 +141,16 @@  discard block
 block discarded – undo
141 141
 	 * @param \EE_Payment $payment
142 142
 	 * @return string
143 143
 	 */
144
-	public function payment_overview_content( EE_Payment $payment ){
144
+	public function payment_overview_content(EE_Payment $payment) {
145 145
 		return EEH_Template::locate_template(
146
-			'payment_methods' . DS . 'Invoice'. DS . 'templates'.DS.'invoice_payment_details_content.template.php',
146
+			'payment_methods'.DS.'Invoice'.DS.'templates'.DS.'invoice_payment_details_content.template.php',
147 147
 			array_merge(
148 148
 				array(
149 149
 					'payment_method'			=> $this->_pm_instance,
150 150
 					'payment'						=> $payment,
151 151
 					'page_confirmation_text'					=> '',
152 152
 					'page_extra_info'	=> '',
153
-					'invoice_url' 					=> $payment->transaction()->primary_registration()->invoice_url( 'html' )
153
+					'invoice_url' 					=> $payment->transaction()->primary_registration()->invoice_url('html')
154 154
 				),
155 155
 				$this->_pm_instance->all_extra_meta_array()
156 156
 			)
Please login to merge, or discard this patch.
acceptance_tests/Helpers/MessagesAdmin.php 1 patch
Indentation   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -10,96 +10,96 @@
 block discarded – undo
10 10
  */
11 11
 trait MessagesAdmin
12 12
 {
13
-    /**
14
-     * @param string $additional_params Any additional request parameters for the generated url should be included as
15
-     *                                  a string.
16
-     */
17
-    public function amOnMessagesActivityListTablePage($additional_params = '')
18
-    {
19
-        $this->actor()->amOnAdminPage(MessagesPage::messageActivityListTableUrl($additional_params));
20
-    }
13
+	/**
14
+	 * @param string $additional_params Any additional request parameters for the generated url should be included as
15
+	 *                                  a string.
16
+	 */
17
+	public function amOnMessagesActivityListTablePage($additional_params = '')
18
+	{
19
+		$this->actor()->amOnAdminPage(MessagesPage::messageActivityListTableUrl($additional_params));
20
+	}
21 21
 
22
-    /**
23
-     * @param string $additional_params Any additional request parameters for the generated url should be included as
24
-     *                                  a string.
25
-     */
26
-    public function amOnDefaultMessageTemplateListTablePage($additional_params = '')
27
-    {
28
-        $this->actor()->amOnAdminPage(MessagesPage::defaultMessageTemplateListTableUrl($additional_params));
29
-    }
22
+	/**
23
+	 * @param string $additional_params Any additional request parameters for the generated url should be included as
24
+	 *                                  a string.
25
+	 */
26
+	public function amOnDefaultMessageTemplateListTablePage($additional_params = '')
27
+	{
28
+		$this->actor()->amOnAdminPage(MessagesPage::defaultMessageTemplateListTableUrl($additional_params));
29
+	}
30 30
 
31 31
 
32
-    /**
33
-     * @param string $additional_params Any additional request parameters for the generated url should be included as
34
-     *                                  a string.
35
-     */
36
-    public function amOnCustomMessageTemplateListTablePage($additional_params = '')
37
-    {
38
-        $this->actor()->amOnAdminPage(MessagesPage::customMessageTemplateListTableUrl($additional_params));
39
-    }
32
+	/**
33
+	 * @param string $additional_params Any additional request parameters for the generated url should be included as
34
+	 *                                  a string.
35
+	 */
36
+	public function amOnCustomMessageTemplateListTablePage($additional_params = '')
37
+	{
38
+		$this->actor()->amOnAdminPage(MessagesPage::customMessageTemplateListTableUrl($additional_params));
39
+	}
40 40
 
41 41
 
42
-    /**
43
-     * Directs to message settings page
44
-     */
45
-    public function amOnMessageSettingsPage()
46
-    {
47
-        $this->actor()->amOnAdminPage(MessagesPage::messageSettingsUrl());
48
-    }
42
+	/**
43
+	 * Directs to message settings page
44
+	 */
45
+	public function amOnMessageSettingsPage()
46
+	{
47
+		$this->actor()->amOnAdminPage(MessagesPage::messageSettingsUrl());
48
+	}
49 49
 
50 50
 
51
-    /**
52
-     * Assumes you are already on the list table page that has the ui for editing the template.
53
-     * @param string $message_type_slug
54
-     * @param string $context [optional] if you want to click directly to the given context in the editor
55
-     */
56
-    public function clickToEditMessageTemplateByMessageType($message_type_slug, $context = '')
57
-    {
58
-        $this->actor()->click(MessagesPage::editMessageTemplateClassByMessageType($message_type_slug, $context));
59
-    }
51
+	/**
52
+	 * Assumes you are already on the list table page that has the ui for editing the template.
53
+	 * @param string $message_type_slug
54
+	 * @param string $context [optional] if you want to click directly to the given context in the editor
55
+	 */
56
+	public function clickToEditMessageTemplateByMessageType($message_type_slug, $context = '')
57
+	{
58
+		$this->actor()->click(MessagesPage::editMessageTemplateClassByMessageType($message_type_slug, $context));
59
+	}
60 60
 
61 61
 
62
-    /**
63
-     * Use this action to verify that the count for the given text in the specified field is as expected.  For example
64
-     * filling the condition of, "There should only be 1 instance of `[email protected]` in all the 'to' column.
65
-     *
66
-     * @param int    $expected_occurence_count
67
-     * @param string $text_to_check_for
68
-     * @param string $field
69
-     * @param string $message_type_label
70
-     * @param string $message_status
71
-     * @param string $messenger
72
-     * @param string $context
73
-     */
74
-    public function verifyMatchingCountofTextInMessageActivityListTableFor(
75
-        $expected_occurence_count,
76
-        $text_to_check_for,
77
-        $field,
78
-        $message_type_label,
79
-        $message_status = MessagesPage::MESSAGE_STATUS_SENT,
80
-        $messenger = 'Email',
81
-        $context = 'Event Admin'
82
-    ) {
83
-        $elements = $this->actor()->grabMultiple(MessagesPage::messagesActivityListTableCellSelectorFor(
84
-            $field,
85
-            $message_type_label,
86
-            $message_status,
87
-            $messenger,
88
-            $context,
89
-            $text_to_check_for
90
-        ));
91
-        $actual_count = count($elements);
92
-        $this->actor()->assertEquals(
93
-            $expected_occurence_count,
94
-            $actual_count,
95
-            sprintf(
96
-                'Expected %s of the %s text for the %s field but there were actually %s counted.',
97
-                $expected_occurence_count,
98
-                $text_to_check_for,
99
-                $field,
100
-                $actual_count
101
-            )
102
-        );
103
-    }
62
+	/**
63
+	 * Use this action to verify that the count for the given text in the specified field is as expected.  For example
64
+	 * filling the condition of, "There should only be 1 instance of `[email protected]` in all the 'to' column.
65
+	 *
66
+	 * @param int    $expected_occurence_count
67
+	 * @param string $text_to_check_for
68
+	 * @param string $field
69
+	 * @param string $message_type_label
70
+	 * @param string $message_status
71
+	 * @param string $messenger
72
+	 * @param string $context
73
+	 */
74
+	public function verifyMatchingCountofTextInMessageActivityListTableFor(
75
+		$expected_occurence_count,
76
+		$text_to_check_for,
77
+		$field,
78
+		$message_type_label,
79
+		$message_status = MessagesPage::MESSAGE_STATUS_SENT,
80
+		$messenger = 'Email',
81
+		$context = 'Event Admin'
82
+	) {
83
+		$elements = $this->actor()->grabMultiple(MessagesPage::messagesActivityListTableCellSelectorFor(
84
+			$field,
85
+			$message_type_label,
86
+			$message_status,
87
+			$messenger,
88
+			$context,
89
+			$text_to_check_for
90
+		));
91
+		$actual_count = count($elements);
92
+		$this->actor()->assertEquals(
93
+			$expected_occurence_count,
94
+			$actual_count,
95
+			sprintf(
96
+				'Expected %s of the %s text for the %s field but there were actually %s counted.',
97
+				$expected_occurence_count,
98
+				$text_to_check_for,
99
+				$field,
100
+				$actual_count
101
+			)
102
+		);
103
+	}
104 104
 
105 105
 }
106 106
\ No newline at end of file
Please login to merge, or discard this patch.
core/services/cache/BasicCacheManager.php 1 patch
Indentation   +112 added lines, -112 removed lines patch added patch discarded remove patch
@@ -19,118 +19,118 @@
 block discarded – undo
19 19
 class BasicCacheManager implements CacheManagerInterface
20 20
 {
21 21
 
22
-    /**
23
-     * @type string
24
-     */
25
-    const CACHE_PREFIX = 'ee_cache_';
26
-
27
-    /**
28
-     * set to true to monitor when content is being served from cache or not
29
-     *
30
-     * @type boolean
31
-     */
32
-    const DEBUG = false;
33
-
34
-    /**
35
-     * @var CacheStorageInterface $cache_storage
36
-     */
37
-    private $cache_storage;
38
-
39
-
40
-
41
-    /**
42
-     * BasicCacheManager constructor.
43
-     *
44
-     * @param CacheStorageInterface $cache_storage [required]
45
-     */
46
-    public function __construct(CacheStorageInterface $cache_storage)
47
-    {
48
-        $this->cache_storage = $cache_storage;
49
-    }
50
-
51
-
52
-
53
-    /**
54
-     * returns a string that will be prepended to all cache identifiers
55
-     *
56
-     * @return string
57
-     */
58
-    public function cachePrefix()
59
-    {
60
-        return BasicCacheManager::CACHE_PREFIX;
61
-    }
62
-
63
-
64
-
65
-    /**
66
-     * @param string  $id_prefix [required] Prepended to all cache IDs. Can be helpful in finding specific cache types.
67
-     *                           May also be helpful to include an additional specific identifier,
68
-     *                           such as a post ID as part of the $id_prefix so that individual caches
69
-     *                           can be found and/or cleared. ex: "venue-28", or "shortcode-156".
70
-     *                           BasicCacheManager::CACHE_PREFIX will also be prepended to the cache id.
71
-     * @param string  $cache_id  [required] Additional identifying details that make this cache unique.
72
-     *                           It is advisable to use some of the actual data
73
-     *                           that is used to generate the content being cached,
74
-     *                           in order to guarantee that the cache id is unique for that content.
75
-     *                           The cache id will be md5'd before usage to make it more db friendly,
76
-     *                           and the entire cache id string will be truncated to 190 characters.
77
-     * @param Closure $callback  [required] since the point of caching is to avoid generating content when not
78
-     *                           necessary,
79
-     *                           we wrap our content creation in a Closure so that it is not executed until needed.
80
-     * @param int     $expiration
81
-     * @return Closure|mixed
82
-     */
83
-    public function get($id_prefix, $cache_id, Closure $callback, $expiration = HOUR_IN_SECONDS)
84
-    {
85
-        $content = '';
86
-        // how long should we cache this content for? 0 means no caching.
87
-        $expiration = ! WP_DEBUG ? $expiration : 0;
88
-        $expiration = absint(
89
-            apply_filters(
90
-                'FHEE__CacheManager__get__cache_expiration',
91
-                $expiration,
92
-                $id_prefix,
93
-                $cache_id
94
-            )
95
-        );
96
-        $cache_id = substr($this->cachePrefix() . $id_prefix . '-' . md5($cache_id), 0, 182);
97
-        // is caching enabled for this content ?
98
-        if ($expiration) {
99
-            $content = $this->cache_storage->get($cache_id);
100
-        }
101
-        // any existing content ?
102
-        if (empty($content)) {
103
-            // nope! let's generate some new stuff
104
-            $content = $callback();
105
-            // save the new content if caching is enabled
106
-            if ($expiration) {
107
-                if (BasicCacheManager::DEBUG) {
108
-                    EEH_Debug_Tools::printr($cache_id, 'REFRESH CACHE', __FILE__, __LINE__);
109
-                }
110
-                $this->cache_storage->add($cache_id, $content, $expiration);
111
-            }
112
-        } else {
113
-            if (BasicCacheManager::DEBUG) {
114
-                EEH_Debug_Tools::printr($cache_id, 'CACHED CONTENT', __FILE__, __LINE__);
115
-            }
116
-        }
117
-        return $content;
118
-    }
119
-
120
-
121
-
122
-    /**
123
-     * @param array|string $cache_id [required] Could be an ID prefix affecting many caches
124
-     *                               or a specific ID targeting a single cache item
125
-     * @return void
126
-     */
127
-    public function clear($cache_id)
128
-    {
129
-        // ensure incoming arg is in an array
130
-        $cache_id = is_array($cache_id) ? $cache_id : array($cache_id);
131
-        // delete corresponding transients for the supplied id prefix
132
-        $this->cache_storage->deleteMany($cache_id);
133
-    }
22
+	/**
23
+	 * @type string
24
+	 */
25
+	const CACHE_PREFIX = 'ee_cache_';
26
+
27
+	/**
28
+	 * set to true to monitor when content is being served from cache or not
29
+	 *
30
+	 * @type boolean
31
+	 */
32
+	const DEBUG = false;
33
+
34
+	/**
35
+	 * @var CacheStorageInterface $cache_storage
36
+	 */
37
+	private $cache_storage;
38
+
39
+
40
+
41
+	/**
42
+	 * BasicCacheManager constructor.
43
+	 *
44
+	 * @param CacheStorageInterface $cache_storage [required]
45
+	 */
46
+	public function __construct(CacheStorageInterface $cache_storage)
47
+	{
48
+		$this->cache_storage = $cache_storage;
49
+	}
50
+
51
+
52
+
53
+	/**
54
+	 * returns a string that will be prepended to all cache identifiers
55
+	 *
56
+	 * @return string
57
+	 */
58
+	public function cachePrefix()
59
+	{
60
+		return BasicCacheManager::CACHE_PREFIX;
61
+	}
62
+
63
+
64
+
65
+	/**
66
+	 * @param string  $id_prefix [required] Prepended to all cache IDs. Can be helpful in finding specific cache types.
67
+	 *                           May also be helpful to include an additional specific identifier,
68
+	 *                           such as a post ID as part of the $id_prefix so that individual caches
69
+	 *                           can be found and/or cleared. ex: "venue-28", or "shortcode-156".
70
+	 *                           BasicCacheManager::CACHE_PREFIX will also be prepended to the cache id.
71
+	 * @param string  $cache_id  [required] Additional identifying details that make this cache unique.
72
+	 *                           It is advisable to use some of the actual data
73
+	 *                           that is used to generate the content being cached,
74
+	 *                           in order to guarantee that the cache id is unique for that content.
75
+	 *                           The cache id will be md5'd before usage to make it more db friendly,
76
+	 *                           and the entire cache id string will be truncated to 190 characters.
77
+	 * @param Closure $callback  [required] since the point of caching is to avoid generating content when not
78
+	 *                           necessary,
79
+	 *                           we wrap our content creation in a Closure so that it is not executed until needed.
80
+	 * @param int     $expiration
81
+	 * @return Closure|mixed
82
+	 */
83
+	public function get($id_prefix, $cache_id, Closure $callback, $expiration = HOUR_IN_SECONDS)
84
+	{
85
+		$content = '';
86
+		// how long should we cache this content for? 0 means no caching.
87
+		$expiration = ! WP_DEBUG ? $expiration : 0;
88
+		$expiration = absint(
89
+			apply_filters(
90
+				'FHEE__CacheManager__get__cache_expiration',
91
+				$expiration,
92
+				$id_prefix,
93
+				$cache_id
94
+			)
95
+		);
96
+		$cache_id = substr($this->cachePrefix() . $id_prefix . '-' . md5($cache_id), 0, 182);
97
+		// is caching enabled for this content ?
98
+		if ($expiration) {
99
+			$content = $this->cache_storage->get($cache_id);
100
+		}
101
+		// any existing content ?
102
+		if (empty($content)) {
103
+			// nope! let's generate some new stuff
104
+			$content = $callback();
105
+			// save the new content if caching is enabled
106
+			if ($expiration) {
107
+				if (BasicCacheManager::DEBUG) {
108
+					EEH_Debug_Tools::printr($cache_id, 'REFRESH CACHE', __FILE__, __LINE__);
109
+				}
110
+				$this->cache_storage->add($cache_id, $content, $expiration);
111
+			}
112
+		} else {
113
+			if (BasicCacheManager::DEBUG) {
114
+				EEH_Debug_Tools::printr($cache_id, 'CACHED CONTENT', __FILE__, __LINE__);
115
+			}
116
+		}
117
+		return $content;
118
+	}
119
+
120
+
121
+
122
+	/**
123
+	 * @param array|string $cache_id [required] Could be an ID prefix affecting many caches
124
+	 *                               or a specific ID targeting a single cache item
125
+	 * @return void
126
+	 */
127
+	public function clear($cache_id)
128
+	{
129
+		// ensure incoming arg is in an array
130
+		$cache_id = is_array($cache_id) ? $cache_id : array($cache_id);
131
+		// delete corresponding transients for the supplied id prefix
132
+		$this->cache_storage->deleteMany($cache_id);
133
+	}
134 134
 
135 135
 
136 136
 
Please login to merge, or discard this patch.
acceptance_tests/Helpers/BaseCoreAdmin.php 1 patch
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -13,39 +13,39 @@
 block discarded – undo
13 13
 trait BaseCoreAdmin
14 14
 {
15 15
 
16
-    /**
17
-     * Core method for going to an Event Espresso Admin page.
18
-     * @param string $page
19
-     * @param string $action
20
-     * @param string $additional_params
21
-     */
22
-    public function amOnEventEspressoAdminPage($page = '', $action = '', $additional_params = '')
23
-    {
24
-        $this->actor()->amOnAdminPage(CoreAdmin::adminUrl($page, $action, $additional_params));
25
-    }
16
+	/**
17
+	 * Core method for going to an Event Espresso Admin page.
18
+	 * @param string $page
19
+	 * @param string $action
20
+	 * @param string $additional_params
21
+	 */
22
+	public function amOnEventEspressoAdminPage($page = '', $action = '', $additional_params = '')
23
+	{
24
+		$this->actor()->amOnAdminPage(CoreAdmin::adminUrl($page, $action, $additional_params));
25
+	}
26 26
 
27 27
 
28
-    /**
29
-     * Helper method for returning an instance of the Actor.  Intended to help with IDE fill out of methods.
30
-     * @return \EventEspressoAcceptanceTester;
31
-     */
32
-    protected function actor()
33
-    {
34
-        /** @var \EventEspressoAcceptanceTester $this */
35
-        return $this;
36
-    }
28
+	/**
29
+	 * Helper method for returning an instance of the Actor.  Intended to help with IDE fill out of methods.
30
+	 * @return \EventEspressoAcceptanceTester;
31
+	 */
32
+	protected function actor()
33
+	{
34
+		/** @var \EventEspressoAcceptanceTester $this */
35
+		return $this;
36
+	}
37 37
 
38 38
 
39
-    /**
40
-     * Use this to set the per page option for a list table page.
41
-     * Assumes you are on a page that has this field exposed.
42
-     * @param int|string $per_page_value
43
-     */
44
-    public function setPerPageOptionForScreen($per_page_value)
45
-    {
46
-        $this->actor()->click(CoreAdmin::WP_SCREEN_SETTINGS_LINK_SELECTOR);
47
-        $this->actor()->fillField(CoreAdmin::WP_SCREEN_SETTINGS_PER_PAGE_FIELD_SELECTOR, $per_page_value);
48
-        $this->actor()->click(CoreAdmin::WP_SCREEN_OPTIONS_APPLY_SETTINGS_BUTTON_SELECTOR);
49
-        $this->actor()->wait(8);
50
-    }
39
+	/**
40
+	 * Use this to set the per page option for a list table page.
41
+	 * Assumes you are on a page that has this field exposed.
42
+	 * @param int|string $per_page_value
43
+	 */
44
+	public function setPerPageOptionForScreen($per_page_value)
45
+	{
46
+		$this->actor()->click(CoreAdmin::WP_SCREEN_SETTINGS_LINK_SELECTOR);
47
+		$this->actor()->fillField(CoreAdmin::WP_SCREEN_SETTINGS_PER_PAGE_FIELD_SELECTOR, $per_page_value);
48
+		$this->actor()->click(CoreAdmin::WP_SCREEN_OPTIONS_APPLY_SETTINGS_BUTTON_SELECTOR);
49
+		$this->actor()->wait(8);
50
+	}
51 51
 }
52 52
\ No newline at end of file
Please login to merge, or discard this patch.
acceptance_tests/Page/CoreAdmin.php 1 patch
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -13,63 +13,63 @@
 block discarded – undo
13 13
 class CoreAdmin
14 14
 {
15 15
 
16
-    /**
17
-     * @var string
18
-     */
19
-    const URL_PREFIX = 'admin.php?page=';
16
+	/**
17
+	 * @var string
18
+	 */
19
+	const URL_PREFIX = 'admin.php?page=';
20 20
 
21 21
 
22
-    /**
23
-     * This is the selector for the next page button on list tables.
24
-     * @var string
25
-     */
26
-    const ADMIN_LIST_TABLE_NEXT_PAGE_CLASS = '.next-page';
22
+	/**
23
+	 * This is the selector for the next page button on list tables.
24
+	 * @var string
25
+	 */
26
+	const ADMIN_LIST_TABLE_NEXT_PAGE_CLASS = '.next-page';
27 27
 
28 28
 
29
-    /**
30
-     * The selector for the search input submit button on list table pages
31
-     * @var string
32
-     */
33
-    const LIST_TABLE_SEARCH_SUBMIT_SELECTOR = '#search-submit';
29
+	/**
30
+	 * The selector for the search input submit button on list table pages
31
+	 * @var string
32
+	 */
33
+	const LIST_TABLE_SEARCH_SUBMIT_SELECTOR = '#search-submit';
34 34
 
35 35
 
36
-    /**
37
-     * Selector for the screen options dropdown.
38
-     * @var string
39
-     */
40
-    const WP_SCREEN_SETTINGS_LINK_SELECTOR = '#show-settings-link';
36
+	/**
37
+	 * Selector for the screen options dropdown.
38
+	 * @var string
39
+	 */
40
+	const WP_SCREEN_SETTINGS_LINK_SELECTOR = '#show-settings-link';
41 41
 
42 42
 
43
-    /**
44
-     * Selector for the per page field setting selector (found within screen options dropdown)
45
-     * @var string
46
-     */
47
-    const WP_SCREEN_SETTINGS_PER_PAGE_FIELD_SELECTOR = '.screen-per-page';
43
+	/**
44
+	 * Selector for the per page field setting selector (found within screen options dropdown)
45
+	 * @var string
46
+	 */
47
+	const WP_SCREEN_SETTINGS_PER_PAGE_FIELD_SELECTOR = '.screen-per-page';
48 48
 
49 49
 
50
-    /**
51
-     * Selector for apply screen options settings.
52
-     * @var string
53
-     */
54
-    const WP_SCREEN_OPTIONS_APPLY_SETTINGS_BUTTON_SELECTOR = '#screen-options-apply';
50
+	/**
51
+	 * Selector for apply screen options settings.
52
+	 * @var string
53
+	 */
54
+	const WP_SCREEN_OPTIONS_APPLY_SETTINGS_BUTTON_SELECTOR = '#screen-options-apply';
55 55
 
56 56
 
57
-    /**
58
-     * Get the EE admin url for the given properties.
59
-     * Note, this is JUST the endpoint for the admin route.  It is expected that the actor/test would be calling this
60
-     * with `amOnAdminPage` action.
61
-     *
62
-     * @param string $page
63
-     * @param string $action
64
-     * @param string $additional_params
65
-     * @return string
66
-     */
67
-    public static function adminUrl($page = 'espresso_events', $action = 'default', $additional_params = '')
68
-    {
69
-        $url = self::URL_PREFIX . $page;
70
-        $url .= $action ? '&action=' . $action : '';
71
-        $url .= $additional_params ? '&' . ltrim('&', ltrim('?', $additional_params)) : '';
72
-        return $url;
73
-    }
57
+	/**
58
+	 * Get the EE admin url for the given properties.
59
+	 * Note, this is JUST the endpoint for the admin route.  It is expected that the actor/test would be calling this
60
+	 * with `amOnAdminPage` action.
61
+	 *
62
+	 * @param string $page
63
+	 * @param string $action
64
+	 * @param string $additional_params
65
+	 * @return string
66
+	 */
67
+	public static function adminUrl($page = 'espresso_events', $action = 'default', $additional_params = '')
68
+	{
69
+		$url = self::URL_PREFIX . $page;
70
+		$url .= $action ? '&action=' . $action : '';
71
+		$url .= $additional_params ? '&' . ltrim('&', ltrim('?', $additional_params)) : '';
72
+		return $url;
73
+	}
74 74
 
75 75
 }
76 76
\ No newline at end of file
Please login to merge, or discard this patch.