Completed
Branch dependabot/npm_and_yarn/codeco... (0144b6)
by
unknown
58:24 queued 50:03
created
espresso.php 1 patch
Indentation   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -38,103 +38,103 @@
 block discarded – undo
38 38
  * @since           4.0
39 39
  */
40 40
 if (function_exists('espresso_version')) {
41
-    if (! function_exists('espresso_duplicate_plugin_error')) {
42
-        /**
43
-         *    espresso_duplicate_plugin_error
44
-         *    displays if more than one version of EE is activated at the same time
45
-         */
46
-        function espresso_duplicate_plugin_error()
47
-        {
48
-            ?>
41
+	if (! function_exists('espresso_duplicate_plugin_error')) {
42
+		/**
43
+		 *    espresso_duplicate_plugin_error
44
+		 *    displays if more than one version of EE is activated at the same time
45
+		 */
46
+		function espresso_duplicate_plugin_error()
47
+		{
48
+			?>
49 49
             <div class="error">
50 50
                 <p>
51 51
                     <?php
52
-                    echo esc_html__(
53
-                        'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
-                        'event_espresso'
55
-                    ); ?>
52
+					echo esc_html__(
53
+						'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
+						'event_espresso'
55
+					); ?>
56 56
                 </p>
57 57
             </div>
58 58
             <?php
59
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
60
-        }
61
-    }
62
-    add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
59
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
60
+		}
61
+	}
62
+	add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
63 63
 } else {
64
-    define('EE_MIN_PHP_VER_REQUIRED', '5.4.0');
65
-    if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
-        /**
67
-         * espresso_minimum_php_version_error
68
-         *
69
-         * @return void
70
-         */
71
-        function espresso_minimum_php_version_error()
72
-        {
73
-            ?>
64
+	define('EE_MIN_PHP_VER_REQUIRED', '5.4.0');
65
+	if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
+		/**
67
+		 * espresso_minimum_php_version_error
68
+		 *
69
+		 * @return void
70
+		 */
71
+		function espresso_minimum_php_version_error()
72
+		{
73
+			?>
74 74
             <div class="error">
75 75
                 <p>
76 76
                     <?php
77
-                    printf(
78
-                        esc_html__(
79
-                            'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
-                            'event_espresso'
81
-                        ),
82
-                        EE_MIN_PHP_VER_REQUIRED,
83
-                        PHP_VERSION,
84
-                        '<br/>',
85
-                        '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
-                    );
87
-                    ?>
77
+					printf(
78
+						esc_html__(
79
+							'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
+							'event_espresso'
81
+						),
82
+						EE_MIN_PHP_VER_REQUIRED,
83
+						PHP_VERSION,
84
+						'<br/>',
85
+						'<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
+					);
87
+					?>
88 88
                 </p>
89 89
             </div>
90 90
             <?php
91
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
92
-        }
91
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
92
+		}
93 93
 
94
-        add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
-    } else {
96
-        define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97
-        /**
98
-         * espresso_version
99
-         * Returns the plugin version
100
-         *
101
-         * @return string
102
-         */
103
-        function espresso_version()
104
-        {
105
-            return apply_filters('FHEE__espresso__espresso_version', '4.10.4.rc.007');
106
-        }
94
+		add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
+	} else {
96
+		define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97
+		/**
98
+		 * espresso_version
99
+		 * Returns the plugin version
100
+		 *
101
+		 * @return string
102
+		 */
103
+		function espresso_version()
104
+		{
105
+			return apply_filters('FHEE__espresso__espresso_version', '4.10.4.rc.007');
106
+		}
107 107
 
108
-        /**
109
-         * espresso_plugin_activation
110
-         * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
111
-         */
112
-        function espresso_plugin_activation()
113
-        {
114
-            update_option('ee_espresso_activation', true);
115
-        }
108
+		/**
109
+		 * espresso_plugin_activation
110
+		 * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
111
+		 */
112
+		function espresso_plugin_activation()
113
+		{
114
+			update_option('ee_espresso_activation', true);
115
+		}
116 116
 
117
-        register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
117
+		register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
118 118
 
119
-        require_once __DIR__ . '/core/bootstrap_espresso.php';
120
-        bootstrap_espresso();
121
-    }
119
+		require_once __DIR__ . '/core/bootstrap_espresso.php';
120
+		bootstrap_espresso();
121
+	}
122 122
 }
123 123
 if (! function_exists('espresso_deactivate_plugin')) {
124
-    /**
125
-     *    deactivate_plugin
126
-     * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
127
-     *
128
-     * @access public
129
-     * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
130
-     * @return    void
131
-     */
132
-    function espresso_deactivate_plugin($plugin_basename = '')
133
-    {
134
-        if (! function_exists('deactivate_plugins')) {
135
-            require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
-        }
137
-        unset($_GET['activate'], $_REQUEST['activate']);
138
-        deactivate_plugins($plugin_basename);
139
-    }
124
+	/**
125
+	 *    deactivate_plugin
126
+	 * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
127
+	 *
128
+	 * @access public
129
+	 * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
130
+	 * @return    void
131
+	 */
132
+	function espresso_deactivate_plugin($plugin_basename = '')
133
+	{
134
+		if (! function_exists('deactivate_plugins')) {
135
+			require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
+		}
137
+		unset($_GET['activate'], $_REQUEST['activate']);
138
+		deactivate_plugins($plugin_basename);
139
+	}
140 140
 }
Please login to merge, or discard this patch.
caffeinated/payment_methods/Aim/EEG_Aim.gateway.php 1 patch
Indentation   +595 added lines, -595 removed lines patch added patch discarded remove patch
@@ -26,417 +26,417 @@  discard block
 block discarded – undo
26 26
 class EEG_Aim extends EE_Onsite_Gateway
27 27
 {
28 28
 
29
-    const LIVE_URL    = 'https://secure2.authorize.net/gateway/transact.dll'; // Authnet URL
30
-
31
-    const SANDBOX_URL = 'https://test.authorize.net/gateway/transact.dll';
32
-
33
-    protected $_login_id;
34
-
35
-    protected $_transaction_key;
36
-
37
-    protected $_currencies_supported = array(
38
-        'AUD',
39
-        'USD',
40
-        'CAD',
41
-        'EUR',
42
-        'GBP',
43
-        'NZD',
44
-    );
45
-
46
-    /**
47
-     * Whether to send test transactions (even to live site)
48
-     *
49
-     * @var boolean
50
-     */
51
-    protected $_test_transactions;
52
-
53
-    private $VERIFY_PEER = false;
54
-
55
-    private $_x_post_fields = array(
56
-        "version"        => "3.1",
57
-        "delim_char"     => ",",
58
-        "delim_data"     => "TRUE",
59
-        "relay_response" => "FALSE",
60
-        "encap_char"     => "|",
61
-    );
62
-
63
-    private $_additional_line_items = array();
64
-
65
-    /**
66
-     * A list of all fields in the AIM API.
67
-     * Used to warn user if they try to set a field not offered in the API.
68
-     */
69
-    private $_all_aim_fields = array(
70
-        "address",
71
-        "allow_partial_auth",
72
-        "amount",
73
-        "auth_code",
74
-        "authentication_indicator",
75
-        "bank_aba_code",
76
-        "bank_acct_name",
77
-        "bank_acct_num",
78
-        "bank_acct_type",
79
-        "bank_check_number",
80
-        "bank_name",
81
-        "card_code",
82
-        "card_num",
83
-        "cardholder_authentication_value",
84
-        "city",
85
-        "company",
86
-        "country",
87
-        "cust_id",
88
-        "customer_ip",
89
-        "delim_char",
90
-        "delim_data",
91
-        "description",
92
-        "duplicate_window",
93
-        "duty",
94
-        "echeck_type",
95
-        "email",
96
-        "email_customer",
97
-        "encap_char",
98
-        "exp_date",
99
-        "fax",
100
-        "first_name",
101
-        "footer_email_receipt",
102
-        "freight",
103
-        "header_email_receipt",
104
-        "invoice_num",
105
-        "last_name",
106
-        "line_item",
107
-        "login",
108
-        "method",
109
-        "phone",
110
-        "po_num",
111
-        "recurring_billing",
112
-        "relay_response",
113
-        "ship_to_address",
114
-        "ship_to_city",
115
-        "ship_to_company",
116
-        "ship_to_country",
117
-        "ship_to_first_name",
118
-        "ship_to_last_name",
119
-        "ship_to_state",
120
-        "ship_to_zip",
121
-        "split_tender_id",
122
-        "state",
123
-        "tax",
124
-        "tax_exempt",
125
-        "test_request",
126
-        "tran_key",
127
-        "trans_id",
128
-        "type",
129
-        "version",
130
-        "zip",
131
-        "solution_id",
132
-        "currency_code"
133
-    );
134
-
135
-
136
-    /**
137
-     * Gets the URL where the request should go. This is filterable
138
-     *
139
-     * @return string
140
-     */
141
-    protected function _get_server_url()
142
-    {
143
-        return apply_filters(
144
-            'FHEE__EEG_Aim___get_server_url',
145
-            $this->_debug_mode ? self::SANDBOX_URL : self::LIVE_URL,
146
-            $this
147
-        );
148
-    }
149
-
150
-
151
-    /**
152
-     * Asks the gateway to do whatever it does to process the payment. Onsite gateways will
153
-     * usually send a request directly to the payment provider and update the payment's status based on that;
154
-     * whereas offsite gateways will usually just update the payment with the URL and query parameters to use
155
-     * for sending the request via http_remote_request()
156
-     *
157
-     * @param EEI_Payment $payment
158
-     * @param array $billing_info {
159
-     *  @type $credit_card string
160
-     *  @type $cvv string
161
-     *  @type $exp_month string
162
-     *  @type $exp_year string
163
-     *  @see parent::do_direct_payment
164
-     * }
165
-     * @return EEI_Payment updated
166
-     */
167
-    public function do_direct_payment($payment, $billing_info = null)
168
-    {
169
-        // Enable test mode if needed
170
-        // 4007000000027  <-- test successful visa
171
-        // 4222222222222  <-- test failure card number
172
-
173
-        $item_num = 1;
174
-        $transaction = $payment->transaction();
175
-        $gateway_formatter = $this->_get_gateway_formatter();
176
-        $order_description = $this->prepareStringForAuthnet($gateway_formatter->formatOrderDescription($payment));
177
-        $primary_registrant = $transaction->primary_registration();
178
-        // if we're are charging for the full amount, show the normal line items
179
-        // and the itemized total adds up properly
180
-        if ($this->_can_easily_itemize_transaction_for($payment)) {
181
-            $total_line_item = $transaction->total_line_item();
182
-            foreach ($total_line_item->get_items() as $line_item) {
183
-                if ($line_item->quantity() == 0) {
184
-                    continue;
185
-                }
186
-                $this->addLineItem(
187
-                    $item_num++,
188
-                    $gateway_formatter->formatLineItemName($line_item, $payment),
189
-                    $gateway_formatter->formatLineItemDesc($line_item, $payment),
190
-                    $line_item->quantity(),
191
-                    $line_item->unit_price(),
192
-                    'N'
193
-                );
194
-                $order_description .= $this->prepareStringForAuthnet($line_item->desc()) . ', ';
195
-            }
196
-            foreach ($total_line_item->tax_descendants() as $tax_line_item) {
197
-                $this->addLineItem(
198
-                    $item_num++,
199
-                    $tax_line_item->name(),
200
-                    $tax_line_item->desc(),
201
-                    1,
202
-                    $tax_line_item->total(),
203
-                    'N'
204
-                );
205
-            }
206
-        }
207
-
208
-        // start transaction
209
-        // if in debug mode, use authorize.net's sandbox id; otherwise use the Event Espresso partner id
210
-        $partner_id = $this->_debug_mode ? 'AAA100302' : 'AAA105363';
211
-        $this->setField('solution_id', $partner_id);
212
-        $this->setField('amount', $gateway_formatter->formatCurrency($payment->amount()));
213
-        $this->setField('description', substr(rtrim($order_description, ', '), 0, 255));
214
-        $this->_set_sensitive_billing_data($billing_info);
215
-        $this->setField('first_name', $billing_info['first_name']);
216
-        $this->setField('last_name', $billing_info['last_name']);
217
-        $this->setField('email', $billing_info['email']);
218
-        $this->setField('company', $billing_info['company']);
219
-        $this->setField('address', $billing_info['address'].' '.$billing_info['address2']);
220
-        $this->setField('city', $billing_info['city']);
221
-        $this->setField('state', $billing_info['state']);
222
-        $this->setField('country', $billing_info['country']);
223
-        $this->setField('zip', $billing_info['zip']);
224
-        $this->setField('fax', $billing_info['fax']);
225
-        $this->setField('cust_id', $primary_registrant->ID());
226
-        $this->setField('phone', $billing_info['phone']);
227
-        $currency_config = LoaderFactory::getLoader()->load('EE_Currency_Config');
228
-        $this->setField('currency_code', $currency_config->code);
229
-        // invoice_num would be nice to have it be unique per SPCO page-load, that way if users
230
-        // press back, they don't submit a duplicate. However, we may be keeping the user on teh same spco page
231
-        // in which case, we need to generate teh invoice num per request right here...
232
-        $this->setField('invoice_num', wp_generate_password(12, false));// $billing_info['_reg-page-billing-invoice-'.$this->_gateway_name]['value']);
233
-        // tell AIM that any duplicates sent in the next 5 minutes are to be ignored
234
-        $this->setField('duplicate_window', 5 * MINUTE_IN_SECONDS);
235
-
236
-        if ($this->_test_transactions) {
237
-            $this->test_request = "true";
238
-        }
239
-
240
-        // Capture response
241
-        $this->type = "AUTH_CAPTURE";
242
-        $response = $this->_sendRequest($payment);
243
-        if (! empty($response)) {
244
-            if ($response->error_message) {
245
-                $payment->set_status($this->_pay_model->failed_status());
246
-                $payment->set_gateway_response($response->error_message);
247
-            } else {
248
-                $payment_status = $response->approved
249
-                    ? $this->_pay_model->approved_status()
250
-                    : $this->_pay_model->declined_status();
251
-                $payment->set_status($payment_status);
252
-                // make sure we interpret the AMT as a float, not an international string (where periods are thousand separators)
253
-                $payment->set_amount((float) $response->amount);
254
-                $payment->set_gateway_response(
255
-                    sprintf(
256
-                        esc_html__('%1$s (Reason Code: %2$s)', 'event_espresso'),
257
-                        $response->response_reason_text,
258
-                        $response->response_reason_code
259
-                    )
260
-                );
261
-                if ($this->_debug_mode) {
262
-                    $txn_id = $response->invoice_number;
263
-                } else {
264
-                    $txn_id = $response->transaction_id;
265
-                }
266
-                $payment->set_txn_id_chq_nmbr($txn_id);
267
-            }
268
-            $payment->set_extra_accntng($primary_registrant->reg_code());
269
-            $payment->set_details(print_r($response, true));
270
-        } else {
271
-            $payment->set_status($this->_pay_model->failed_status());
272
-            $payment->set_gateway_response(__("There was no response from Authorize.net", 'event_espresso'));
273
-            $payment->set_details(print_r($response, true));
274
-        }
275
-        return $payment;
276
-    }
277
-
278
-
279
-    /**
280
-     * Sets billing data for the upcoming request to AIM that is considered sensitive;
281
-     * also this method can be overridden by children classes to easily change
282
-     * what billing data gets sent
283
-     *
284
-     * @param array $billing_info
285
-     */
286
-    protected function _set_sensitive_billing_data($billing_info)
287
-    {
288
-        $this->setField('card_num', $billing_info['credit_card']);
289
-        $this->setField('exp_date', $billing_info['exp_month'] . $billing_info['exp_year']);
290
-        $this->setField('card_code', $billing_info['cvv']);
291
-    }
292
-
293
-
294
-    /**
295
-     * Add a line item.
296
-     *
297
-     * @param string $item_id
298
-     * @param string $item_name
299
-     * @param string $item_description
300
-     * @param string $item_quantity
301
-     * @param string $item_unit_price
302
-     * @param string $item_taxable
303
-     */
304
-    public function addLineItem($item_id, $item_name, $item_description, $item_quantity, $item_unit_price, $item_taxable)
305
-    {
306
-        $args = array(
307
-            substr($item_id, 0, 31),
308
-            substr($this->prepareStringForAuthnet($item_name), 0, 31),
309
-            substr($this->prepareStringForAuthnet($item_description), 0, 255),
310
-            number_format(abs($item_quantity), 2, '.', ''),
311
-            number_format(abs($item_unit_price), 2, '.', ''),
312
-            $item_taxable === 'N' ? 'N' : 'Y'
313
-        );
314
-        $this->_additional_line_items[] = implode('<|>', $args);
315
-    }
316
-
317
-
318
-    /**
319
-     * Set an individual name/value pair. This will append x_ to the name
320
-     * before posting.
321
-     *
322
-     * @param string $name
323
-     * @param string $value
324
-     * @throws AuthorizeNetException
325
-     */
326
-    protected function setField($name, $value)
327
-    {
328
-        if (in_array($name, $this->_all_aim_fields)) {
329
-            $this->_x_post_fields[ $name ] = $value;
330
-        } else {
331
-            throw new AuthorizeNetException("Error: no field $name exists in the AIM API.
29
+	const LIVE_URL    = 'https://secure2.authorize.net/gateway/transact.dll'; // Authnet URL
30
+
31
+	const SANDBOX_URL = 'https://test.authorize.net/gateway/transact.dll';
32
+
33
+	protected $_login_id;
34
+
35
+	protected $_transaction_key;
36
+
37
+	protected $_currencies_supported = array(
38
+		'AUD',
39
+		'USD',
40
+		'CAD',
41
+		'EUR',
42
+		'GBP',
43
+		'NZD',
44
+	);
45
+
46
+	/**
47
+	 * Whether to send test transactions (even to live site)
48
+	 *
49
+	 * @var boolean
50
+	 */
51
+	protected $_test_transactions;
52
+
53
+	private $VERIFY_PEER = false;
54
+
55
+	private $_x_post_fields = array(
56
+		"version"        => "3.1",
57
+		"delim_char"     => ",",
58
+		"delim_data"     => "TRUE",
59
+		"relay_response" => "FALSE",
60
+		"encap_char"     => "|",
61
+	);
62
+
63
+	private $_additional_line_items = array();
64
+
65
+	/**
66
+	 * A list of all fields in the AIM API.
67
+	 * Used to warn user if they try to set a field not offered in the API.
68
+	 */
69
+	private $_all_aim_fields = array(
70
+		"address",
71
+		"allow_partial_auth",
72
+		"amount",
73
+		"auth_code",
74
+		"authentication_indicator",
75
+		"bank_aba_code",
76
+		"bank_acct_name",
77
+		"bank_acct_num",
78
+		"bank_acct_type",
79
+		"bank_check_number",
80
+		"bank_name",
81
+		"card_code",
82
+		"card_num",
83
+		"cardholder_authentication_value",
84
+		"city",
85
+		"company",
86
+		"country",
87
+		"cust_id",
88
+		"customer_ip",
89
+		"delim_char",
90
+		"delim_data",
91
+		"description",
92
+		"duplicate_window",
93
+		"duty",
94
+		"echeck_type",
95
+		"email",
96
+		"email_customer",
97
+		"encap_char",
98
+		"exp_date",
99
+		"fax",
100
+		"first_name",
101
+		"footer_email_receipt",
102
+		"freight",
103
+		"header_email_receipt",
104
+		"invoice_num",
105
+		"last_name",
106
+		"line_item",
107
+		"login",
108
+		"method",
109
+		"phone",
110
+		"po_num",
111
+		"recurring_billing",
112
+		"relay_response",
113
+		"ship_to_address",
114
+		"ship_to_city",
115
+		"ship_to_company",
116
+		"ship_to_country",
117
+		"ship_to_first_name",
118
+		"ship_to_last_name",
119
+		"ship_to_state",
120
+		"ship_to_zip",
121
+		"split_tender_id",
122
+		"state",
123
+		"tax",
124
+		"tax_exempt",
125
+		"test_request",
126
+		"tran_key",
127
+		"trans_id",
128
+		"type",
129
+		"version",
130
+		"zip",
131
+		"solution_id",
132
+		"currency_code"
133
+	);
134
+
135
+
136
+	/**
137
+	 * Gets the URL where the request should go. This is filterable
138
+	 *
139
+	 * @return string
140
+	 */
141
+	protected function _get_server_url()
142
+	{
143
+		return apply_filters(
144
+			'FHEE__EEG_Aim___get_server_url',
145
+			$this->_debug_mode ? self::SANDBOX_URL : self::LIVE_URL,
146
+			$this
147
+		);
148
+	}
149
+
150
+
151
+	/**
152
+	 * Asks the gateway to do whatever it does to process the payment. Onsite gateways will
153
+	 * usually send a request directly to the payment provider and update the payment's status based on that;
154
+	 * whereas offsite gateways will usually just update the payment with the URL and query parameters to use
155
+	 * for sending the request via http_remote_request()
156
+	 *
157
+	 * @param EEI_Payment $payment
158
+	 * @param array $billing_info {
159
+	 *  @type $credit_card string
160
+	 *  @type $cvv string
161
+	 *  @type $exp_month string
162
+	 *  @type $exp_year string
163
+	 *  @see parent::do_direct_payment
164
+	 * }
165
+	 * @return EEI_Payment updated
166
+	 */
167
+	public function do_direct_payment($payment, $billing_info = null)
168
+	{
169
+		// Enable test mode if needed
170
+		// 4007000000027  <-- test successful visa
171
+		// 4222222222222  <-- test failure card number
172
+
173
+		$item_num = 1;
174
+		$transaction = $payment->transaction();
175
+		$gateway_formatter = $this->_get_gateway_formatter();
176
+		$order_description = $this->prepareStringForAuthnet($gateway_formatter->formatOrderDescription($payment));
177
+		$primary_registrant = $transaction->primary_registration();
178
+		// if we're are charging for the full amount, show the normal line items
179
+		// and the itemized total adds up properly
180
+		if ($this->_can_easily_itemize_transaction_for($payment)) {
181
+			$total_line_item = $transaction->total_line_item();
182
+			foreach ($total_line_item->get_items() as $line_item) {
183
+				if ($line_item->quantity() == 0) {
184
+					continue;
185
+				}
186
+				$this->addLineItem(
187
+					$item_num++,
188
+					$gateway_formatter->formatLineItemName($line_item, $payment),
189
+					$gateway_formatter->formatLineItemDesc($line_item, $payment),
190
+					$line_item->quantity(),
191
+					$line_item->unit_price(),
192
+					'N'
193
+				);
194
+				$order_description .= $this->prepareStringForAuthnet($line_item->desc()) . ', ';
195
+			}
196
+			foreach ($total_line_item->tax_descendants() as $tax_line_item) {
197
+				$this->addLineItem(
198
+					$item_num++,
199
+					$tax_line_item->name(),
200
+					$tax_line_item->desc(),
201
+					1,
202
+					$tax_line_item->total(),
203
+					'N'
204
+				);
205
+			}
206
+		}
207
+
208
+		// start transaction
209
+		// if in debug mode, use authorize.net's sandbox id; otherwise use the Event Espresso partner id
210
+		$partner_id = $this->_debug_mode ? 'AAA100302' : 'AAA105363';
211
+		$this->setField('solution_id', $partner_id);
212
+		$this->setField('amount', $gateway_formatter->formatCurrency($payment->amount()));
213
+		$this->setField('description', substr(rtrim($order_description, ', '), 0, 255));
214
+		$this->_set_sensitive_billing_data($billing_info);
215
+		$this->setField('first_name', $billing_info['first_name']);
216
+		$this->setField('last_name', $billing_info['last_name']);
217
+		$this->setField('email', $billing_info['email']);
218
+		$this->setField('company', $billing_info['company']);
219
+		$this->setField('address', $billing_info['address'].' '.$billing_info['address2']);
220
+		$this->setField('city', $billing_info['city']);
221
+		$this->setField('state', $billing_info['state']);
222
+		$this->setField('country', $billing_info['country']);
223
+		$this->setField('zip', $billing_info['zip']);
224
+		$this->setField('fax', $billing_info['fax']);
225
+		$this->setField('cust_id', $primary_registrant->ID());
226
+		$this->setField('phone', $billing_info['phone']);
227
+		$currency_config = LoaderFactory::getLoader()->load('EE_Currency_Config');
228
+		$this->setField('currency_code', $currency_config->code);
229
+		// invoice_num would be nice to have it be unique per SPCO page-load, that way if users
230
+		// press back, they don't submit a duplicate. However, we may be keeping the user on teh same spco page
231
+		// in which case, we need to generate teh invoice num per request right here...
232
+		$this->setField('invoice_num', wp_generate_password(12, false));// $billing_info['_reg-page-billing-invoice-'.$this->_gateway_name]['value']);
233
+		// tell AIM that any duplicates sent in the next 5 minutes are to be ignored
234
+		$this->setField('duplicate_window', 5 * MINUTE_IN_SECONDS);
235
+
236
+		if ($this->_test_transactions) {
237
+			$this->test_request = "true";
238
+		}
239
+
240
+		// Capture response
241
+		$this->type = "AUTH_CAPTURE";
242
+		$response = $this->_sendRequest($payment);
243
+		if (! empty($response)) {
244
+			if ($response->error_message) {
245
+				$payment->set_status($this->_pay_model->failed_status());
246
+				$payment->set_gateway_response($response->error_message);
247
+			} else {
248
+				$payment_status = $response->approved
249
+					? $this->_pay_model->approved_status()
250
+					: $this->_pay_model->declined_status();
251
+				$payment->set_status($payment_status);
252
+				// make sure we interpret the AMT as a float, not an international string (where periods are thousand separators)
253
+				$payment->set_amount((float) $response->amount);
254
+				$payment->set_gateway_response(
255
+					sprintf(
256
+						esc_html__('%1$s (Reason Code: %2$s)', 'event_espresso'),
257
+						$response->response_reason_text,
258
+						$response->response_reason_code
259
+					)
260
+				);
261
+				if ($this->_debug_mode) {
262
+					$txn_id = $response->invoice_number;
263
+				} else {
264
+					$txn_id = $response->transaction_id;
265
+				}
266
+				$payment->set_txn_id_chq_nmbr($txn_id);
267
+			}
268
+			$payment->set_extra_accntng($primary_registrant->reg_code());
269
+			$payment->set_details(print_r($response, true));
270
+		} else {
271
+			$payment->set_status($this->_pay_model->failed_status());
272
+			$payment->set_gateway_response(__("There was no response from Authorize.net", 'event_espresso'));
273
+			$payment->set_details(print_r($response, true));
274
+		}
275
+		return $payment;
276
+	}
277
+
278
+
279
+	/**
280
+	 * Sets billing data for the upcoming request to AIM that is considered sensitive;
281
+	 * also this method can be overridden by children classes to easily change
282
+	 * what billing data gets sent
283
+	 *
284
+	 * @param array $billing_info
285
+	 */
286
+	protected function _set_sensitive_billing_data($billing_info)
287
+	{
288
+		$this->setField('card_num', $billing_info['credit_card']);
289
+		$this->setField('exp_date', $billing_info['exp_month'] . $billing_info['exp_year']);
290
+		$this->setField('card_code', $billing_info['cvv']);
291
+	}
292
+
293
+
294
+	/**
295
+	 * Add a line item.
296
+	 *
297
+	 * @param string $item_id
298
+	 * @param string $item_name
299
+	 * @param string $item_description
300
+	 * @param string $item_quantity
301
+	 * @param string $item_unit_price
302
+	 * @param string $item_taxable
303
+	 */
304
+	public function addLineItem($item_id, $item_name, $item_description, $item_quantity, $item_unit_price, $item_taxable)
305
+	{
306
+		$args = array(
307
+			substr($item_id, 0, 31),
308
+			substr($this->prepareStringForAuthnet($item_name), 0, 31),
309
+			substr($this->prepareStringForAuthnet($item_description), 0, 255),
310
+			number_format(abs($item_quantity), 2, '.', ''),
311
+			number_format(abs($item_unit_price), 2, '.', ''),
312
+			$item_taxable === 'N' ? 'N' : 'Y'
313
+		);
314
+		$this->_additional_line_items[] = implode('<|>', $args);
315
+	}
316
+
317
+
318
+	/**
319
+	 * Set an individual name/value pair. This will append x_ to the name
320
+	 * before posting.
321
+	 *
322
+	 * @param string $name
323
+	 * @param string $value
324
+	 * @throws AuthorizeNetException
325
+	 */
326
+	protected function setField($name, $value)
327
+	{
328
+		if (in_array($name, $this->_all_aim_fields)) {
329
+			$this->_x_post_fields[ $name ] = $value;
330
+		} else {
331
+			throw new AuthorizeNetException("Error: no field $name exists in the AIM API.
332 332
             To set a custom field use setCustomField('field','value') instead.");
333
-        }
334
-    }
335
-
336
-
337
-    /**
338
-     * Posts the request to AuthorizeNet & returns response.
339
-     *
340
-     * @param $payment
341
-     * @return \EE_AuthorizeNetAIM_Response
342
-     */
343
-    private function _sendRequest($payment)
344
-    {
345
-        $this->_x_post_fields['login'] = $this->_login_id;
346
-        $this->_x_post_fields['tran_key'] = $this->_transaction_key;
347
-        $x_keys = array();
348
-        foreach ($this->_x_post_fields as $key => $value) {
349
-            $x_keys[] = "x_$key=" . urlencode($this->_get_unsupported_character_remover()->format($value));
350
-        }
351
-        // Add line items
352
-        foreach ($this->_additional_line_items as $key => $value) {
353
-            $x_keys[] =  "x_line_item=" . urlencode($this->_get_unsupported_character_remover()->format($value));
354
-        }
355
-        $this->_log_clean_request($x_keys, $payment);
356
-        $post_url = $this->_get_server_url();
357
-        $curl_request = curl_init($post_url);
358
-        $post_body = implode("&", $x_keys);
359
-        curl_setopt($curl_request, CURLOPT_POSTFIELDS, $post_body);
360
-        curl_setopt($curl_request, CURLOPT_HEADER, 0);
361
-        curl_setopt($curl_request, CURLOPT_TIMEOUT, 45);
362
-        curl_setopt($curl_request, CURLOPT_RETURNTRANSFER, 1);
363
-        curl_setopt($curl_request, CURLOPT_SSL_VERIFYHOST, 2);
364
-        if ($this->VERIFY_PEER) {
365
-            curl_setopt($curl_request, CURLOPT_CAINFO, dirname(__DIR__) . '/ssl/cert.pem');
366
-        } else {
367
-            curl_setopt($curl_request, CURLOPT_SSL_VERIFYPEER, false);
368
-        }
369
-
370
-        if (preg_match('/xml/', $post_url)) {
371
-            curl_setopt($curl_request, CURLOPT_HTTPHEADER, array("Content-Type: text/xml"));
372
-        }
373
-
374
-        $response = curl_exec($curl_request);
375
-
376
-        curl_close($curl_request);
377
-        $response_obj =  new EE_AuthorizeNetAIM_Response($response);
378
-
379
-        return $this->_log_and_clean_response($response_obj, $payment);
380
-    }
381
-
382
-
383
-    /**
384
-     * Logs the clean data only
385
-     *
386
-     * @param array $request_array
387
-     * @param EEI_Payment $payment
388
-     */
389
-    protected function _log_clean_request($request_array, $payment)
390
-    {
391
-        $keys_to_filter_out = array('x_card_num', 'x_card_code', 'x_exp_date');
392
-        foreach ($request_array as $index => $keyvaltogether) {
393
-            foreach ($keys_to_filter_out as $key) {
394
-                if (strpos($keyvaltogether, $key) === 0) {
395
-                    // found it at the first character
396
-                    // so its one of them
397
-                    unset($request_array[ $index ]);
398
-                }
399
-            }
400
-        }
401
-        $this->log(
402
-            array(
403
-                'AIM Request sent:' => $request_array,
404
-                'Server URL'        => $this->_get_server_url()
405
-            ),
406
-            $payment
407
-        );
408
-    }
409
-
410
-
411
-
412
-    /**
413
-     * Logs the response and cleans it
414
-     *
415
-     * @param EE_AuthorizeNetAIM_Response $response_obj
416
-     * @param EE_Payment                  $payment
417
-     * @return \EE_AuthorizeNetAIM_Response
418
-     */
419
-    private function _log_and_clean_response($response_obj, $payment)
420
-    {
421
-        $response_obj->account_number = '';
422
-        $this->log(array('AIM Response received:' => (array) $response_obj), $payment);
423
-        return $response_obj;
424
-    }
425
-
426
-    /**
427
-     * Removes characters Authorize.net doesn't handle well.
428
-     * @since 4.9.82.p
429
-     * @param $text
430
-     * @return string
431
-     */
432
-    private function prepareStringForAuthnet($text)
433
-    {
434
-        return str_replace(
435
-            '\'',
436
-            '',
437
-            $text
438
-        );
439
-    }
333
+		}
334
+	}
335
+
336
+
337
+	/**
338
+	 * Posts the request to AuthorizeNet & returns response.
339
+	 *
340
+	 * @param $payment
341
+	 * @return \EE_AuthorizeNetAIM_Response
342
+	 */
343
+	private function _sendRequest($payment)
344
+	{
345
+		$this->_x_post_fields['login'] = $this->_login_id;
346
+		$this->_x_post_fields['tran_key'] = $this->_transaction_key;
347
+		$x_keys = array();
348
+		foreach ($this->_x_post_fields as $key => $value) {
349
+			$x_keys[] = "x_$key=" . urlencode($this->_get_unsupported_character_remover()->format($value));
350
+		}
351
+		// Add line items
352
+		foreach ($this->_additional_line_items as $key => $value) {
353
+			$x_keys[] =  "x_line_item=" . urlencode($this->_get_unsupported_character_remover()->format($value));
354
+		}
355
+		$this->_log_clean_request($x_keys, $payment);
356
+		$post_url = $this->_get_server_url();
357
+		$curl_request = curl_init($post_url);
358
+		$post_body = implode("&", $x_keys);
359
+		curl_setopt($curl_request, CURLOPT_POSTFIELDS, $post_body);
360
+		curl_setopt($curl_request, CURLOPT_HEADER, 0);
361
+		curl_setopt($curl_request, CURLOPT_TIMEOUT, 45);
362
+		curl_setopt($curl_request, CURLOPT_RETURNTRANSFER, 1);
363
+		curl_setopt($curl_request, CURLOPT_SSL_VERIFYHOST, 2);
364
+		if ($this->VERIFY_PEER) {
365
+			curl_setopt($curl_request, CURLOPT_CAINFO, dirname(__DIR__) . '/ssl/cert.pem');
366
+		} else {
367
+			curl_setopt($curl_request, CURLOPT_SSL_VERIFYPEER, false);
368
+		}
369
+
370
+		if (preg_match('/xml/', $post_url)) {
371
+			curl_setopt($curl_request, CURLOPT_HTTPHEADER, array("Content-Type: text/xml"));
372
+		}
373
+
374
+		$response = curl_exec($curl_request);
375
+
376
+		curl_close($curl_request);
377
+		$response_obj =  new EE_AuthorizeNetAIM_Response($response);
378
+
379
+		return $this->_log_and_clean_response($response_obj, $payment);
380
+	}
381
+
382
+
383
+	/**
384
+	 * Logs the clean data only
385
+	 *
386
+	 * @param array $request_array
387
+	 * @param EEI_Payment $payment
388
+	 */
389
+	protected function _log_clean_request($request_array, $payment)
390
+	{
391
+		$keys_to_filter_out = array('x_card_num', 'x_card_code', 'x_exp_date');
392
+		foreach ($request_array as $index => $keyvaltogether) {
393
+			foreach ($keys_to_filter_out as $key) {
394
+				if (strpos($keyvaltogether, $key) === 0) {
395
+					// found it at the first character
396
+					// so its one of them
397
+					unset($request_array[ $index ]);
398
+				}
399
+			}
400
+		}
401
+		$this->log(
402
+			array(
403
+				'AIM Request sent:' => $request_array,
404
+				'Server URL'        => $this->_get_server_url()
405
+			),
406
+			$payment
407
+		);
408
+	}
409
+
410
+
411
+
412
+	/**
413
+	 * Logs the response and cleans it
414
+	 *
415
+	 * @param EE_AuthorizeNetAIM_Response $response_obj
416
+	 * @param EE_Payment                  $payment
417
+	 * @return \EE_AuthorizeNetAIM_Response
418
+	 */
419
+	private function _log_and_clean_response($response_obj, $payment)
420
+	{
421
+		$response_obj->account_number = '';
422
+		$this->log(array('AIM Response received:' => (array) $response_obj), $payment);
423
+		return $response_obj;
424
+	}
425
+
426
+	/**
427
+	 * Removes characters Authorize.net doesn't handle well.
428
+	 * @since 4.9.82.p
429
+	 * @param $text
430
+	 * @return string
431
+	 */
432
+	private function prepareStringForAuthnet($text)
433
+	{
434
+		return str_replace(
435
+			'\'',
436
+			'',
437
+			$text
438
+		);
439
+	}
440 440
 }
441 441
 
442 442
 
@@ -452,192 +452,192 @@  discard block
 block discarded – undo
452 452
 class EE_AuthorizeNetAIM_Response
453 453
 {
454 454
 
455
-    const APPROVED = '1';
456
-    const DECLINED = '2';
457
-    const ERROR = '3';
458
-    const HELD = '4';
459
-
460
-    protected $_x_post_fields = array(
461
-        "version"        => "3.1",
462
-        "delim_char"     => ",",
463
-        "delim_data"     => "TRUE",
464
-        "relay_response" => "FALSE",
465
-        "encap_char"     => "|",
466
-    );
467
-    public $approved;
468
-    public $declined;
469
-    public $error;
470
-    public $held;
471
-    public $response_code;
472
-    public $response_subcode;
473
-    public $response_reason_code;
474
-    public $response_reason_text;
475
-    public $authorization_code;
476
-    public $avs_response;
477
-    public $transaction_id;
478
-    public $invoice_number;
479
-    public $description;
480
-    public $amount;
481
-    public $method;
482
-    public $transaction_type;
483
-    public $customer_id;
484
-    public $first_name;
485
-    public $last_name;
486
-    public $company;
487
-    public $address;
488
-    public $city;
489
-    public $state;
490
-    public $zip_code;
491
-    public $country;
492
-    public $phone;
493
-    public $fax;
494
-    public $email_address;
495
-    public $ship_to_first_name;
496
-    public $ship_to_last_name;
497
-    public $ship_to_company;
498
-    public $ship_to_address;
499
-    public $ship_to_city;
500
-    public $ship_to_state;
501
-    public $ship_to_zip_code;
502
-    public $ship_to_country;
503
-    public $tax;
504
-    public $duty;
505
-    public $freight;
506
-    public $tax_exempt;
507
-    public $purchase_order_number;
508
-    public $md5_hash;
509
-    public $card_code_response;
510
-    public $cavv_response; // cardholder_authentication_verification_response
511
-    public $account_number;
512
-    public $card_type;
513
-    public $split_tender_id;
514
-    public $requested_amount;
515
-    public $balance_on_card;
516
-    public $response; // The response string from AuthorizeNet.
517
-    public $error_message;
518
-    private $_response_array = array(); // An array with the split response.
519
-
520
-
521
-    /**
522
-     * Constructor. Parses the AuthorizeNet response string
523
-     *
524
-     * @param string $response The response from the AuthNet server.
525
-     * @var string   $delimiter The delimiter used (default is ",")
526
-     * @var string   $encap_char The encap_char used (default is "|")
527
-     * @var array    $custom_fields Any custom fields set in the request.
528
-     */
529
-
530
-    public function __construct($response)
531
-    {
532
-        $encap_char = $this->_x_post_fields['encap_char'];
533
-        $delimiter = $this->_x_post_fields['delim_char'];
534
-        if ($response) {
535
-            // Split Array
536
-            $this->response = $response;
537
-            if ($encap_char) {
538
-                $this->_response_array = explode($encap_char . $delimiter . $encap_char, substr($response, 1, -1));
539
-            } else {
540
-                $this->_response_array = explode($delimiter, $response);
541
-            }
542
-
543
-            /**
544
-             * If AuthorizeNet doesn't return a delimited response.
545
-             */
546
-            if (count($this->_response_array) < 10) {
547
-                $this->approved = false;
548
-                $this->error = true;
549
-                $this->error_message = sprintf(
550
-                    esc_html__('Unrecognized response from Authorize.net: %1$s', 'event_espresso'),
551
-                    esc_html($response)
552
-                );
553
-                return;
554
-            }
555
-
556
-
557
-
558
-            // Set all fields
559
-            $this->response_code = $this->_response_array[0];
560
-            $this->response_subcode = $this->_response_array[1];
561
-            $this->response_reason_code = $this->_response_array[2];
562
-            $this->response_reason_text = $this->_response_array[3];
563
-            $this->authorization_code = $this->_response_array[4];
564
-            $this->avs_response = $this->_response_array[5];
565
-            $this->transaction_id = $this->_response_array[6];
566
-            $this->invoice_number = $this->_response_array[7];
567
-            $this->description = $this->_response_array[8];
568
-            $this->amount = $this->_response_array[9];
569
-            $this->method = $this->_response_array[10];
570
-            $this->transaction_type = $this->_response_array[11];
571
-            $this->customer_id = $this->_response_array[12];
572
-            $this->first_name = $this->_response_array[13];
573
-            $this->last_name = $this->_response_array[14];
574
-            $this->company = $this->_response_array[15];
575
-            $this->address = $this->_response_array[16];
576
-            $this->city = $this->_response_array[17];
577
-            $this->state = $this->_response_array[18];
578
-            $this->zip_code = $this->_response_array[19];
579
-            $this->country = $this->_response_array[20];
580
-            $this->phone = $this->_response_array[21];
581
-            $this->fax = $this->_response_array[22];
582
-            $this->email_address = $this->_response_array[23];
583
-            $this->ship_to_first_name = $this->_response_array[24];
584
-            $this->ship_to_last_name = $this->_response_array[25];
585
-            $this->ship_to_company = $this->_response_array[26];
586
-            $this->ship_to_address = $this->_response_array[27];
587
-            $this->ship_to_city = $this->_response_array[28];
588
-            $this->ship_to_state = $this->_response_array[29];
589
-            $this->ship_to_zip_code = $this->_response_array[30];
590
-            $this->ship_to_country = $this->_response_array[31];
591
-            $this->tax = $this->_response_array[32];
592
-            $this->duty = $this->_response_array[33];
593
-            $this->freight = $this->_response_array[34];
594
-            $this->tax_exempt = $this->_response_array[35];
595
-            $this->purchase_order_number = $this->_response_array[36];
596
-            $this->md5_hash = $this->_response_array[37];
597
-            $this->card_code_response = $this->_response_array[38];
598
-            $this->cavv_response = $this->_response_array[39];
599
-            $this->account_number = $this->_response_array[50];
600
-            $this->card_type = $this->_response_array[51];
601
-            $this->split_tender_id = $this->_response_array[52];
602
-            $this->requested_amount = $this->_response_array[53];
603
-            $this->balance_on_card = $this->_response_array[54];
604
-
605
-            $this->approved = ($this->response_code === self::APPROVED);
606
-            $this->declined = ($this->response_code === self::DECLINED);
607
-            $this->error = ($this->response_code === self::ERROR);
608
-            $this->held = ($this->response_code === self::HELD);
609
-        } else {
610
-            $this->approved = false;
611
-            $this->error = true;
612
-            $this->error_message = esc_html__(
613
-                'Error connecting to Authorize.net',
614
-                'event_espresso'
615
-            );
616
-        }
617
-    }
455
+	const APPROVED = '1';
456
+	const DECLINED = '2';
457
+	const ERROR = '3';
458
+	const HELD = '4';
459
+
460
+	protected $_x_post_fields = array(
461
+		"version"        => "3.1",
462
+		"delim_char"     => ",",
463
+		"delim_data"     => "TRUE",
464
+		"relay_response" => "FALSE",
465
+		"encap_char"     => "|",
466
+	);
467
+	public $approved;
468
+	public $declined;
469
+	public $error;
470
+	public $held;
471
+	public $response_code;
472
+	public $response_subcode;
473
+	public $response_reason_code;
474
+	public $response_reason_text;
475
+	public $authorization_code;
476
+	public $avs_response;
477
+	public $transaction_id;
478
+	public $invoice_number;
479
+	public $description;
480
+	public $amount;
481
+	public $method;
482
+	public $transaction_type;
483
+	public $customer_id;
484
+	public $first_name;
485
+	public $last_name;
486
+	public $company;
487
+	public $address;
488
+	public $city;
489
+	public $state;
490
+	public $zip_code;
491
+	public $country;
492
+	public $phone;
493
+	public $fax;
494
+	public $email_address;
495
+	public $ship_to_first_name;
496
+	public $ship_to_last_name;
497
+	public $ship_to_company;
498
+	public $ship_to_address;
499
+	public $ship_to_city;
500
+	public $ship_to_state;
501
+	public $ship_to_zip_code;
502
+	public $ship_to_country;
503
+	public $tax;
504
+	public $duty;
505
+	public $freight;
506
+	public $tax_exempt;
507
+	public $purchase_order_number;
508
+	public $md5_hash;
509
+	public $card_code_response;
510
+	public $cavv_response; // cardholder_authentication_verification_response
511
+	public $account_number;
512
+	public $card_type;
513
+	public $split_tender_id;
514
+	public $requested_amount;
515
+	public $balance_on_card;
516
+	public $response; // The response string from AuthorizeNet.
517
+	public $error_message;
518
+	private $_response_array = array(); // An array with the split response.
519
+
520
+
521
+	/**
522
+	 * Constructor. Parses the AuthorizeNet response string
523
+	 *
524
+	 * @param string $response The response from the AuthNet server.
525
+	 * @var string   $delimiter The delimiter used (default is ",")
526
+	 * @var string   $encap_char The encap_char used (default is "|")
527
+	 * @var array    $custom_fields Any custom fields set in the request.
528
+	 */
529
+
530
+	public function __construct($response)
531
+	{
532
+		$encap_char = $this->_x_post_fields['encap_char'];
533
+		$delimiter = $this->_x_post_fields['delim_char'];
534
+		if ($response) {
535
+			// Split Array
536
+			$this->response = $response;
537
+			if ($encap_char) {
538
+				$this->_response_array = explode($encap_char . $delimiter . $encap_char, substr($response, 1, -1));
539
+			} else {
540
+				$this->_response_array = explode($delimiter, $response);
541
+			}
542
+
543
+			/**
544
+			 * If AuthorizeNet doesn't return a delimited response.
545
+			 */
546
+			if (count($this->_response_array) < 10) {
547
+				$this->approved = false;
548
+				$this->error = true;
549
+				$this->error_message = sprintf(
550
+					esc_html__('Unrecognized response from Authorize.net: %1$s', 'event_espresso'),
551
+					esc_html($response)
552
+				);
553
+				return;
554
+			}
555
+
556
+
557
+
558
+			// Set all fields
559
+			$this->response_code = $this->_response_array[0];
560
+			$this->response_subcode = $this->_response_array[1];
561
+			$this->response_reason_code = $this->_response_array[2];
562
+			$this->response_reason_text = $this->_response_array[3];
563
+			$this->authorization_code = $this->_response_array[4];
564
+			$this->avs_response = $this->_response_array[5];
565
+			$this->transaction_id = $this->_response_array[6];
566
+			$this->invoice_number = $this->_response_array[7];
567
+			$this->description = $this->_response_array[8];
568
+			$this->amount = $this->_response_array[9];
569
+			$this->method = $this->_response_array[10];
570
+			$this->transaction_type = $this->_response_array[11];
571
+			$this->customer_id = $this->_response_array[12];
572
+			$this->first_name = $this->_response_array[13];
573
+			$this->last_name = $this->_response_array[14];
574
+			$this->company = $this->_response_array[15];
575
+			$this->address = $this->_response_array[16];
576
+			$this->city = $this->_response_array[17];
577
+			$this->state = $this->_response_array[18];
578
+			$this->zip_code = $this->_response_array[19];
579
+			$this->country = $this->_response_array[20];
580
+			$this->phone = $this->_response_array[21];
581
+			$this->fax = $this->_response_array[22];
582
+			$this->email_address = $this->_response_array[23];
583
+			$this->ship_to_first_name = $this->_response_array[24];
584
+			$this->ship_to_last_name = $this->_response_array[25];
585
+			$this->ship_to_company = $this->_response_array[26];
586
+			$this->ship_to_address = $this->_response_array[27];
587
+			$this->ship_to_city = $this->_response_array[28];
588
+			$this->ship_to_state = $this->_response_array[29];
589
+			$this->ship_to_zip_code = $this->_response_array[30];
590
+			$this->ship_to_country = $this->_response_array[31];
591
+			$this->tax = $this->_response_array[32];
592
+			$this->duty = $this->_response_array[33];
593
+			$this->freight = $this->_response_array[34];
594
+			$this->tax_exempt = $this->_response_array[35];
595
+			$this->purchase_order_number = $this->_response_array[36];
596
+			$this->md5_hash = $this->_response_array[37];
597
+			$this->card_code_response = $this->_response_array[38];
598
+			$this->cavv_response = $this->_response_array[39];
599
+			$this->account_number = $this->_response_array[50];
600
+			$this->card_type = $this->_response_array[51];
601
+			$this->split_tender_id = $this->_response_array[52];
602
+			$this->requested_amount = $this->_response_array[53];
603
+			$this->balance_on_card = $this->_response_array[54];
604
+
605
+			$this->approved = ($this->response_code === self::APPROVED);
606
+			$this->declined = ($this->response_code === self::DECLINED);
607
+			$this->error = ($this->response_code === self::ERROR);
608
+			$this->held = ($this->response_code === self::HELD);
609
+		} else {
610
+			$this->approved = false;
611
+			$this->error = true;
612
+			$this->error_message = esc_html__(
613
+				'Error connecting to Authorize.net',
614
+				'event_espresso'
615
+			);
616
+		}
617
+	}
618 618
 }
619 619
 
620 620
 if (! class_exists('AuthorizeNetException')) {
621
-    /**
622
-     * Class AuthorizeNetException
623
-     *
624
-     * @package    AuthorizeNet
625
-     */
626
-    class AuthorizeNetException extends Exception
627
-    {
628
-
629
-        /**
630
-         * Construct the exception. Note: The message is NOT binary safe.
631
-         *
632
-         * @link http://php.net/manual/en/exception.construct.php
633
-         * @param string $message [optional] The Exception message to throw.
634
-         * @param int $code [optional] The Exception code.
635
-         * @param Exception $previous [optional] The previous exception used for the exception chaining. Since 5.3.0
636
-         * @since 5.1.0
637
-         */
638
-        public function __construct($message = "", $code = 0, Exception $previous = null)
639
-        {
640
-            parent::__construct($message, $code, $previous);
641
-        }
642
-    }
621
+	/**
622
+	 * Class AuthorizeNetException
623
+	 *
624
+	 * @package    AuthorizeNet
625
+	 */
626
+	class AuthorizeNetException extends Exception
627
+	{
628
+
629
+		/**
630
+		 * Construct the exception. Note: The message is NOT binary safe.
631
+		 *
632
+		 * @link http://php.net/manual/en/exception.construct.php
633
+		 * @param string $message [optional] The Exception message to throw.
634
+		 * @param int $code [optional] The Exception code.
635
+		 * @param Exception $previous [optional] The previous exception used for the exception chaining. Since 5.3.0
636
+		 * @since 5.1.0
637
+		 */
638
+		public function __construct($message = "", $code = 0, Exception $previous = null)
639
+		{
640
+			parent::__construct($message, $code, $previous);
641
+		}
642
+	}
643 643
 }
Please login to merge, or discard this patch.
payment_methods/Aim/help_tabs/payment_methods_overview_aim.help_tab.php 1 patch
Indentation   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -4,75 +4,75 @@
 block discarded – undo
4 4
 </p>
5 5
 <p>
6 6
     <?php printf(
7
-        esc_html__(
8
-            'See %1$shere%2$s for list of currencies supported by Authorize.net AIM.',
9
-            'event_espresso'
10
-        ),
11
-        "<a href='https://support.authorize.net/s/article/Which-Currencies-Does-Authorize-Net-Support/' target='_blank' rel='noopener noreferrer'>",
12
-        "</a>"
13
-    ); ?>
7
+		esc_html__(
8
+			'See %1$shere%2$s for list of currencies supported by Authorize.net AIM.',
9
+			'event_espresso'
10
+		),
11
+		"<a href='https://support.authorize.net/s/article/Which-Currencies-Does-Authorize-Net-Support/' target='_blank' rel='noopener noreferrer'>",
12
+		"</a>"
13
+	); ?>
14 14
 </p>
15 15
 <p><strong><?php esc_html_e('Authorize.net AIM Settings', 'event_espresso'); ?></strong></p>
16 16
 <ul>
17 17
     <li>
18 18
         <strong><?php esc_html_e('Authorize.net API Login ID', 'event_espresso'); ?></strong><br/>
19 19
         <?php printf(
20
-            esc_html__(
21
-                'Enter your API Login ID for Authorize.net. Learn how to find your %1$sAPI Login%2$s ID.',
22
-                'event_espresso'
23
-            ),
24
-            '<a href="https://support.authorize.net/authkb/index?page=content&id=A405" target="_blank" rel="noopener noreferrer">',
25
-            '</a>'
26
-        ); ?>
20
+			esc_html__(
21
+				'Enter your API Login ID for Authorize.net. Learn how to find your %1$sAPI Login%2$s ID.',
22
+				'event_espresso'
23
+			),
24
+			'<a href="https://support.authorize.net/authkb/index?page=content&id=A405" target="_blank" rel="noopener noreferrer">',
25
+			'</a>'
26
+		); ?>
27 27
     </li>
28 28
     <li>
29 29
         <strong><?php esc_html_e('Authorize.net Transaction Key', 'event_espresso'); ?></strong><br/>
30 30
         <?php printf(
31
-            esc_html__(
32
-                'Enter your Transaction Key for Authorize.net. Learn how to find your %1$sTransaction Key%2$s.',
33
-                'event_espresso'
34
-            ),
35
-            '<a href="https://support.authorize.net/authkb/index?page=content&id=A405" target="_blank" rel="noopener noreferrer">',
36
-            '</a>'
37
-        ); ?>
31
+			esc_html__(
32
+				'Enter your Transaction Key for Authorize.net. Learn how to find your %1$sTransaction Key%2$s.',
33
+				'event_espresso'
34
+			),
35
+			'<a href="https://support.authorize.net/authkb/index?page=content&id=A405" target="_blank" rel="noopener noreferrer">',
36
+			'</a>'
37
+		); ?>
38 38
     </li>
39 39
     <li>
40 40
         <strong>
41 41
             <?php esc_html_e(
42
-                'Is this an account on the Authorize.net development server?',
43
-                'event_espresso'
44
-            ); ?></strong><br/>
42
+				'Is this an account on the Authorize.net development server?',
43
+				'event_espresso'
44
+			); ?></strong><br/>
45 45
         <?php esc_html_e(
46
-            'Specify whether this is a live/production account or a test account on the Authorize.net development server.',
47
-            'event_espresso'
48
-        ); ?>
46
+			'Specify whether this is a live/production account or a test account on the Authorize.net development server.',
47
+			'event_espresso'
48
+		); ?>
49 49
     </li>
50 50
     <li>
51 51
         <strong><?php esc_html_e('Do you want to submit a test transaction?', 'event_espresso'); ?></strong><br/>
52 52
         <?php esc_html_e(
53
-            'Specify if you want to test the Authorize.net AIM payment gateway by submitting a test transaction. Be sure to turn this setting off when you are done testing.',
54
-            'event_espresso'
55
-        ); ?>
53
+			'Specify if you want to test the Authorize.net AIM payment gateway by submitting a test transaction. Be sure to turn this setting off when you are done testing.',
54
+			'event_espresso'
55
+		); ?>
56 56
     </li>
57 57
     <li>
58 58
         <strong><?php esc_html_e('Excluded and Required Payment Form Fields', 'event_espresso'); ?></strong><br/>
59 59
         <?php esc_html_e(
60
-            'By logging into Authorize.net, you can change which payment fields are required by Authorize.net when processing payments. These settings affect both the Advanced Integration Method (AIM, this) and the Simple Integration Method (SIM, different). The payment method settings "Excluded Payment Form Fields" and "Required Payment Form Fields" allow you to change the billing form in Event Espresso to reflect your payment form settings in Authorize.net.',
61
-            'event_espresso'
62
-        ); ?>
60
+			'By logging into Authorize.net, you can change which payment fields are required by Authorize.net when processing payments. These settings affect both the Advanced Integration Method (AIM, this) and the Simple Integration Method (SIM, different). The payment method settings "Excluded Payment Form Fields" and "Required Payment Form Fields" allow you to change the billing form in Event Espresso to reflect your payment form settings in Authorize.net.',
61
+			'event_espresso'
62
+		); ?>
63 63
         <br>
64 64
         <?php
65
-        printf(
66
-            esc_html__(
67
-                'To change your payment form settings in Authorize.net, %1$slog in to authorize.net%2$s, go to %3$sAccount then Payment Form%2$s, then %4$sForm Fields%2$s. It will look similar to %5$sthis%2$s. If you make a field required in Authorize.net, you should also make it required in Event Espresso. If it isn\'t required in Authorize.net, and you want to simplify the billing form in Event Espresso, you can exclude it from the Event Espresso Form too.',
68
-                'event_espresso'
69
-            ),
70
-            '<a href="http://authorize.net" target="_blank" rel="noopener noreferrer">',
71
-            '</a>',
72
-            '<a href="https://monosnap.com/file/nebVteOkEXcdDIos88SojStWOifP23" target="_blank" rel="noopener noreferrer">',
73
-            '<a href="https://monosnap.com/file/WyxGJtev87TcDmdGBEZ2oi1xaBIQAm" target="_blank" rel="noopener noreferrer">',
74
-            '<a href="https://monosnap.com/image/DbCJNfEesWXeSNUs1wLIpGYODFw52m" target="_blank" rel="noopener noreferrer">'
75
-        ); ?>
65
+		printf(
66
+			esc_html__(
67
+				'To change your payment form settings in Authorize.net, %1$slog in to authorize.net%2$s, go to %3$sAccount then Payment Form%2$s, then %4$sForm Fields%2$s. It will look similar to %5$sthis%2$s. If you make a field required in Authorize.net, you should also make it required in Event Espresso. If it isn\'t required in Authorize.net, and you want to simplify the billing form in Event Espresso, you can exclude it from the Event Espresso Form too.',
68
+				'event_espresso'
69
+			),
70
+			'<a href="http://authorize.net" target="_blank" rel="noopener noreferrer">',
71
+			'</a>',
72
+			'<a href="https://monosnap.com/file/nebVteOkEXcdDIos88SojStWOifP23" target="_blank" rel="noopener noreferrer">',
73
+			'<a href="https://monosnap.com/file/WyxGJtev87TcDmdGBEZ2oi1xaBIQAm" target="_blank" rel="noopener noreferrer">',
74
+			'<a href="https://monosnap.com/image/DbCJNfEesWXeSNUs1wLIpGYODFw52m" target="_blank" rel="noopener noreferrer">'
75
+		); ?>
76 76
     </li>
77 77
     <li>
78 78
         <strong><?php esc_html_e('Button Image URL', 'event_espresso'); ?></strong><br/>
Please login to merge, or discard this patch.
caffeinated/payment_methods/Aim/EE_PMT_Aim.pm.php 1 patch
Indentation   +238 added lines, -238 removed lines patch added patch discarded remove patch
@@ -12,260 +12,260 @@
 block discarded – undo
12 12
 {
13 13
 
14 14
 
15
-    /**
16
-     * @param EE_Payment_Method $pm_instance
17
-     * @return EE_PMT_Aim
18
-     * @throws \EE_Error
19
-     */
20
-    public function __construct($pm_instance = null)
21
-    {
22
-        $this->_setup_properties();
23
-        parent::__construct($pm_instance);
24
-    }
15
+	/**
16
+	 * @param EE_Payment_Method $pm_instance
17
+	 * @return EE_PMT_Aim
18
+	 * @throws \EE_Error
19
+	 */
20
+	public function __construct($pm_instance = null)
21
+	{
22
+		$this->_setup_properties();
23
+		parent::__construct($pm_instance);
24
+	}
25 25
     
26
-    /**
27
-     * Sets up payment method type properties for this gateway, which is normally
28
-     * done in the constructor, but we want this to be easy for similar gateways to override
29
-     * while still calling the parent constructor.
30
-     * So children should override this method instead of __construct
31
-     */
32
-    protected function _setup_properties()
33
-    {
34
-        require_once($this->file_folder().'EEG_Aim.gateway.php');
35
-        $this->_gateway = new EEG_Aim();
36
-        $this->_pretty_name = __("Authorize.net AIM", 'event_espresso');
37
-        $this->_default_description = __('Please provide the following billing information.', 'event_espresso');
38
-        $this->_requires_https = true;
39
-    }
26
+	/**
27
+	 * Sets up payment method type properties for this gateway, which is normally
28
+	 * done in the constructor, but we want this to be easy for similar gateways to override
29
+	 * while still calling the parent constructor.
30
+	 * So children should override this method instead of __construct
31
+	 */
32
+	protected function _setup_properties()
33
+	{
34
+		require_once($this->file_folder().'EEG_Aim.gateway.php');
35
+		$this->_gateway = new EEG_Aim();
36
+		$this->_pretty_name = __("Authorize.net AIM", 'event_espresso');
37
+		$this->_default_description = __('Please provide the following billing information.', 'event_espresso');
38
+		$this->_requires_https = true;
39
+	}
40 40
 
41 41
 
42 42
 
43
-    /**
44
-     * Creates the billing form for this payment method type
45
-     *
46
-     * @param \EE_Transaction $transaction
47
-     * @return EE_Billing_Info_Form
48
-     * @throws \EE_Error
49
-     */
50
-    public function generate_new_billing_form(EE_Transaction $transaction = null)
51
-    {
52
-        $billing_form = new EE_Billing_Attendee_Info_Form($this->_pm_instance, array(
53
-            'name'=>'AIM_Form',
54
-            'subsections'=>array(
55
-                'credit_card'=>new EE_Credit_Card_Input(array(
56
-                    'required'=>true,
57
-                    'html_label_text' => __('Card Number', 'event_espresso')
58
-                )),
59
-                'exp_month'=>new EE_Credit_Card_Month_Input(true, array(
60
-                    'required'=>true,
61
-                    'html_label_text' => __('Expiry Month', 'event_espresso')
62
-                )),
63
-                'exp_year'=>new EE_Credit_Card_Year_Input(array(
64
-                    'required'=>true,
65
-                    'html_label_text' => __('Expiry Year', 'event_espresso')
66
-                )),
67
-                'cvv'=>new EE_CVV_Input(array(
68
-                    'required'=>true,
69
-                    'html_label_text' => __('CVV', 'event_espresso') )),
70
-            )
71
-        ));
72
-        $billing_form->add_subsections(array(
73
-            'company' => new EE_Text_Input(array(
74
-                'html_label_text' => __('Company', 'event_espresso')
75
-            ))
76
-        ), 'email', false);
77
-        $billing_form->add_subsections(
78
-            array(
79
-                    'fax' => new EE_Text_Input(array(
80
-                        'html_label_text' => __('Fax', 'event_espresso')
81
-                    ))
82
-                ),
83
-            'phone',
84
-            false
85
-        );
86
-        $settings_form = $this->settings_form();
87
-        if ($settings_form->get_input('excluded_billing_inputs') instanceof EE_Checkbox_Multi_Input) {
88
-                $billing_form->exclude($settings_form->get_input('excluded_billing_inputs')->normalized_value());
89
-        }
90
-        if ($settings_form->get_input('required_billing_inputs') instanceof EE_Checkbox_Multi_Input) {
91
-            $required_inputs = $settings_form->get_input('required_billing_inputs')->normalized_value();
92
-            // only change the requirement of inputs which are allowed to be changed
93
-            /** @var EE_Form_Input_Base[] $inputs_to_evaluate */
94
-            $inputs_to_evaluate = array_intersect_key(
95
-                $billing_form->inputs(),
96
-                $this->billing_input_names()
97
-            );
98
-            foreach ($inputs_to_evaluate as $input_name => $input) {
99
-                if (in_array($input_name, $required_inputs)) {
100
-                    $input->set_required(true);
101
-                } else {
102
-                    $input->set_required(false);
103
-                }
104
-            }
105
-        }
106
-        return $this->apply_billing_form_debug_settings($billing_form);
107
-    }
43
+	/**
44
+	 * Creates the billing form for this payment method type
45
+	 *
46
+	 * @param \EE_Transaction $transaction
47
+	 * @return EE_Billing_Info_Form
48
+	 * @throws \EE_Error
49
+	 */
50
+	public function generate_new_billing_form(EE_Transaction $transaction = null)
51
+	{
52
+		$billing_form = new EE_Billing_Attendee_Info_Form($this->_pm_instance, array(
53
+			'name'=>'AIM_Form',
54
+			'subsections'=>array(
55
+				'credit_card'=>new EE_Credit_Card_Input(array(
56
+					'required'=>true,
57
+					'html_label_text' => __('Card Number', 'event_espresso')
58
+				)),
59
+				'exp_month'=>new EE_Credit_Card_Month_Input(true, array(
60
+					'required'=>true,
61
+					'html_label_text' => __('Expiry Month', 'event_espresso')
62
+				)),
63
+				'exp_year'=>new EE_Credit_Card_Year_Input(array(
64
+					'required'=>true,
65
+					'html_label_text' => __('Expiry Year', 'event_espresso')
66
+				)),
67
+				'cvv'=>new EE_CVV_Input(array(
68
+					'required'=>true,
69
+					'html_label_text' => __('CVV', 'event_espresso') )),
70
+			)
71
+		));
72
+		$billing_form->add_subsections(array(
73
+			'company' => new EE_Text_Input(array(
74
+				'html_label_text' => __('Company', 'event_espresso')
75
+			))
76
+		), 'email', false);
77
+		$billing_form->add_subsections(
78
+			array(
79
+					'fax' => new EE_Text_Input(array(
80
+						'html_label_text' => __('Fax', 'event_espresso')
81
+					))
82
+				),
83
+			'phone',
84
+			false
85
+		);
86
+		$settings_form = $this->settings_form();
87
+		if ($settings_form->get_input('excluded_billing_inputs') instanceof EE_Checkbox_Multi_Input) {
88
+				$billing_form->exclude($settings_form->get_input('excluded_billing_inputs')->normalized_value());
89
+		}
90
+		if ($settings_form->get_input('required_billing_inputs') instanceof EE_Checkbox_Multi_Input) {
91
+			$required_inputs = $settings_form->get_input('required_billing_inputs')->normalized_value();
92
+			// only change the requirement of inputs which are allowed to be changed
93
+			/** @var EE_Form_Input_Base[] $inputs_to_evaluate */
94
+			$inputs_to_evaluate = array_intersect_key(
95
+				$billing_form->inputs(),
96
+				$this->billing_input_names()
97
+			);
98
+			foreach ($inputs_to_evaluate as $input_name => $input) {
99
+				if (in_array($input_name, $required_inputs)) {
100
+					$input->set_required(true);
101
+				} else {
102
+					$input->set_required(false);
103
+				}
104
+			}
105
+		}
106
+		return $this->apply_billing_form_debug_settings($billing_form);
107
+	}
108 108
 
109 109
 
110 110
 
111
-    /**
112
-     * apply_billing_form_debug_settings
113
-     * applies debug data to the form
114
-     *
115
-     * @param \EE_Billing_Info_Form $billing_form
116
-     * @return \EE_Billing_Info_Form
117
-     * @throws \EE_Error
118
-     */
119
-    public function apply_billing_form_debug_settings(EE_Billing_Info_Form $billing_form)
120
-    {
121
-        if ($this->_pm_instance->debug_mode()
122
-            || $this->_pm_instance->get_extra_meta('test_transactions', true, false)
123
-        ) {
124
-            $billing_form->get_input('credit_card')->set_default('4007000000027');
125
-            $billing_form->get_input('exp_year')->set_default('2020');
126
-            if ($billing_form->get_subsection('cvv') instanceof EE_Form_Input_Base) {
127
-                $billing_form->get_input('cvv')->set_default('123');
128
-            }
129
-            $billing_form->add_subsections(
130
-                array( 'fyi_about_autofill' => $billing_form->payment_fields_autofilled_notice_html() ),
131
-                'credit_card'
132
-            );
133
-            $billing_form->add_subsections(
134
-                array(
135
-                    'debug_content' => new EE_Form_Section_HTML_From_Template(
136
-                        __DIR__.'/templates/authorize_net_aim_debug_info.template.php'
137
-                    )
138
-                ),
139
-                'first_name'
140
-            );
141
-        }
142
-        return $billing_form;
143
-    }
111
+	/**
112
+	 * apply_billing_form_debug_settings
113
+	 * applies debug data to the form
114
+	 *
115
+	 * @param \EE_Billing_Info_Form $billing_form
116
+	 * @return \EE_Billing_Info_Form
117
+	 * @throws \EE_Error
118
+	 */
119
+	public function apply_billing_form_debug_settings(EE_Billing_Info_Form $billing_form)
120
+	{
121
+		if ($this->_pm_instance->debug_mode()
122
+			|| $this->_pm_instance->get_extra_meta('test_transactions', true, false)
123
+		) {
124
+			$billing_form->get_input('credit_card')->set_default('4007000000027');
125
+			$billing_form->get_input('exp_year')->set_default('2020');
126
+			if ($billing_form->get_subsection('cvv') instanceof EE_Form_Input_Base) {
127
+				$billing_form->get_input('cvv')->set_default('123');
128
+			}
129
+			$billing_form->add_subsections(
130
+				array( 'fyi_about_autofill' => $billing_form->payment_fields_autofilled_notice_html() ),
131
+				'credit_card'
132
+			);
133
+			$billing_form->add_subsections(
134
+				array(
135
+					'debug_content' => new EE_Form_Section_HTML_From_Template(
136
+						__DIR__.'/templates/authorize_net_aim_debug_info.template.php'
137
+					)
138
+				),
139
+				'first_name'
140
+			);
141
+		}
142
+		return $billing_form;
143
+	}
144 144
 
145 145
 
146 146
 
147
-    /**
148
-     * Gets the form for all the settings related to this payment method type
149
-     * @return EE_Payment_Method_Form
150
-     */
151
-    public function generate_new_settings_form()
152
-    {
153
-        $billing_input_names = $this->billing_input_names();
154
-        return new EE_Payment_Method_Form(
155
-            array(
156
-                'extra_meta_inputs'=>array(
157
-                    'login_id'=>new EE_Text_Input(
158
-                        array(
159
-                            'html_label_text'=>  sprintf(__("Authorize.net API Login ID %s", "event_espresso"), $this->get_help_tab_link()),
160
-                            'required' => true )
161
-                    ),
162
-                    'transaction_key'=>new EE_Text_Input(
163
-                        array(
164
-                            'html_label_text'=> sprintf(__("Authorize.net Transaction Key %s", "event_espresso"), $this->get_help_tab_link()),
165
-                            'required' => true )
166
-                    ),
167
-                    'test_transactions'=>new EE_Yes_No_Input(
168
-                        array(
169
-                            'html_label_text'=>  sprintf(__("Send test transactions? %s", 'event_espresso'), $this->get_help_tab_link()),
170
-                            'html_help_text'=>  __("Send test transactions, even to live server", 'event_espresso'),
171
-                            'default' => false,
172
-                            'required' => true
173
-                        )
174
-                    ),
175
-                    'excluded_billing_inputs' => new EE_Checkbox_Multi_Input(
176
-                        $billing_input_names,
177
-                        array(
178
-                        'html_label_text' => sprintf(__("Excluded Payment Form Fields %s", 'event_espresso'), $this->get_help_tab_link()),
179
-                        'default' => array(
180
-                            'company',
181
-                            'fax',
182
-                        )
183
-                        )
184
-                    ),
185
-                    'required_billing_inputs' => new EE_Checkbox_Multi_Input(
186
-                        $billing_input_names,
187
-                        array(
188
-                            'html_label_text' => sprintf(__("Required Payment Form Fields %s", 'event_espresso'), $this->get_help_tab_link()),
189
-                            'default' => array_diff(
190
-                                array_keys($billing_input_names),
191
-                                array( 'address2', 'phone', 'company', 'fax' )
192
-                            ),
193
-                            'html_help_text' => __('Note: if fields are excluded they cannot be required.', 'event_espresso')
194
-                        )
195
-                    ),
196
-                )
197
-            )
198
-        );
199
-    }
147
+	/**
148
+	 * Gets the form for all the settings related to this payment method type
149
+	 * @return EE_Payment_Method_Form
150
+	 */
151
+	public function generate_new_settings_form()
152
+	{
153
+		$billing_input_names = $this->billing_input_names();
154
+		return new EE_Payment_Method_Form(
155
+			array(
156
+				'extra_meta_inputs'=>array(
157
+					'login_id'=>new EE_Text_Input(
158
+						array(
159
+							'html_label_text'=>  sprintf(__("Authorize.net API Login ID %s", "event_espresso"), $this->get_help_tab_link()),
160
+							'required' => true )
161
+					),
162
+					'transaction_key'=>new EE_Text_Input(
163
+						array(
164
+							'html_label_text'=> sprintf(__("Authorize.net Transaction Key %s", "event_espresso"), $this->get_help_tab_link()),
165
+							'required' => true )
166
+					),
167
+					'test_transactions'=>new EE_Yes_No_Input(
168
+						array(
169
+							'html_label_text'=>  sprintf(__("Send test transactions? %s", 'event_espresso'), $this->get_help_tab_link()),
170
+							'html_help_text'=>  __("Send test transactions, even to live server", 'event_espresso'),
171
+							'default' => false,
172
+							'required' => true
173
+						)
174
+					),
175
+					'excluded_billing_inputs' => new EE_Checkbox_Multi_Input(
176
+						$billing_input_names,
177
+						array(
178
+						'html_label_text' => sprintf(__("Excluded Payment Form Fields %s", 'event_espresso'), $this->get_help_tab_link()),
179
+						'default' => array(
180
+							'company',
181
+							'fax',
182
+						)
183
+						)
184
+					),
185
+					'required_billing_inputs' => new EE_Checkbox_Multi_Input(
186
+						$billing_input_names,
187
+						array(
188
+							'html_label_text' => sprintf(__("Required Payment Form Fields %s", 'event_espresso'), $this->get_help_tab_link()),
189
+							'default' => array_diff(
190
+								array_keys($billing_input_names),
191
+								array( 'address2', 'phone', 'company', 'fax' )
192
+							),
193
+							'html_help_text' => __('Note: if fields are excluded they cannot be required.', 'event_espresso')
194
+						)
195
+					),
196
+				)
197
+			)
198
+		);
199
+	}
200 200
     
201
-    /**
202
-     * Returns an array where keys are the slugs for billing inputs, and values
203
-     * are their i18n names
204
-     * @return array
205
-     */
206
-    public function billing_input_names()
207
-    {
208
-        return array(
209
-            'first_name' => __('First Name', 'event_espresso'),
210
-            'last_name' => __('Last Name', 'event_espresso'),
211
-            'email' => __('Email', 'event_espresso'),
212
-            'company' => __('Company', 'event_espresso'),
213
-            'address' => __('Address', 'event_espresso'),
214
-            'address2' => __('Address2', 'event_espresso'),
215
-            'city' => __('City', 'event_espresso'),
216
-            'state' => __('State', 'event_espresso'),
217
-            'country' => __('Country', 'event_espresso'),
218
-            'zip' =>  __('Zip', 'event_espresso'),
219
-            'phone' => __('Phone', 'event_espresso'),
220
-            'fax' => __('Fax', 'event_espresso'),
221
-            'cvv' => __('CVV', 'event_espresso')
222
-        );
223
-    }
201
+	/**
202
+	 * Returns an array where keys are the slugs for billing inputs, and values
203
+	 * are their i18n names
204
+	 * @return array
205
+	 */
206
+	public function billing_input_names()
207
+	{
208
+		return array(
209
+			'first_name' => __('First Name', 'event_espresso'),
210
+			'last_name' => __('Last Name', 'event_espresso'),
211
+			'email' => __('Email', 'event_espresso'),
212
+			'company' => __('Company', 'event_espresso'),
213
+			'address' => __('Address', 'event_espresso'),
214
+			'address2' => __('Address2', 'event_espresso'),
215
+			'city' => __('City', 'event_espresso'),
216
+			'state' => __('State', 'event_espresso'),
217
+			'country' => __('Country', 'event_espresso'),
218
+			'zip' =>  __('Zip', 'event_espresso'),
219
+			'phone' => __('Phone', 'event_espresso'),
220
+			'fax' => __('Fax', 'event_espresso'),
221
+			'cvv' => __('CVV', 'event_espresso')
222
+		);
223
+	}
224 224
     
225
-    /**
226
-     * Overrides parent so we always have all billing inputs in the returned array,
227
-     * not just the ones included at the time. This helps simplify the gateway code
228
-     *
229
-     * @param EE_Billing_Info_Form $billing_form
230
-     * @return array
231
-     */
232
-    protected function _get_billing_values_from_form($billing_form)
233
-    {
234
-        $all_billing_values_empty = array();
235
-        foreach (array_keys($this->billing_input_names()) as $input_name) {
236
-            $all_billing_values_empty[ $input_name ] = '';
237
-        }
238
-        return array_merge(
239
-            $all_billing_values_empty,
240
-            parent::_get_billing_values_from_form($billing_form)
241
-        );
242
-    }
225
+	/**
226
+	 * Overrides parent so we always have all billing inputs in the returned array,
227
+	 * not just the ones included at the time. This helps simplify the gateway code
228
+	 *
229
+	 * @param EE_Billing_Info_Form $billing_form
230
+	 * @return array
231
+	 */
232
+	protected function _get_billing_values_from_form($billing_form)
233
+	{
234
+		$all_billing_values_empty = array();
235
+		foreach (array_keys($this->billing_input_names()) as $input_name) {
236
+			$all_billing_values_empty[ $input_name ] = '';
237
+		}
238
+		return array_merge(
239
+			$all_billing_values_empty,
240
+			parent::_get_billing_values_from_form($billing_form)
241
+		);
242
+	}
243 243
 
244 244
 
245 245
 
246
-    /**
247
-     * Adds the help tab
248
-     * @see EE_PMT_Base::help_tabs_config()
249
-     * @return array
250
-     */
251
-    public function help_tabs_config()
252
-    {
253
-        return array(
254
-            $this->get_help_tab_name() => array(
255
-                'title' => __('Authorize.net AIM Settings', 'event_espresso'),
256
-                'filename' => 'payment_methods_overview_aim'
257
-            ),
258
-        );
259
-    }
246
+	/**
247
+	 * Adds the help tab
248
+	 * @see EE_PMT_Base::help_tabs_config()
249
+	 * @return array
250
+	 */
251
+	public function help_tabs_config()
252
+	{
253
+		return array(
254
+			$this->get_help_tab_name() => array(
255
+				'title' => __('Authorize.net AIM Settings', 'event_espresso'),
256
+				'filename' => 'payment_methods_overview_aim'
257
+			),
258
+		);
259
+	}
260 260
 
261 261
 
262 262
 
263
-    /**
264
-     * Gets a list of instructions and/or information regarding how the payment is to be completed
265
-     * @return string
266
-     */
267
-    public function payment_information()
268
-    {
269
-        // TODO: Implement payment_information() method.
270
-    }
263
+	/**
264
+	 * Gets a list of instructions and/or information regarding how the payment is to be completed
265
+	 * @return string
266
+	 */
267
+	public function payment_information()
268
+	{
269
+		// TODO: Implement payment_information() method.
270
+	}
271 271
 }
Please login to merge, or discard this patch.