Completed
Push — master ( ab284c...4fdc7c )
by Justin
07:07
created

chronopay.php ➔ gateway_chronopay()   F

Complexity

Conditions 19
Paths 4352

Size

Total Lines 168
Code Lines 95

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 19
eloc 95
nc 4352
nop 2
dl 0
loc 168
rs 2

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
$nzshpcrt_gateways[$num]['name'] = __( 'ChronoPay', 'wp-e-commerce' );
3
$nzshpcrt_gateways[$num]['internalname'] = 'chronopay';
4
$nzshpcrt_gateways[$num]['function'] = 'gateway_chronopay';
5
$nzshpcrt_gateways[$num]['form'] = "form_chronopay";
6
$nzshpcrt_gateways[$num]['submit_function'] = "submit_chronopay";
7
$nzshpcrt_gateways[$num]['payment_type'] = "credit_card";
8
$nzshpcrt_gateways[$num]['display_name'] = __( 'Credit Card', 'wp-e-commerce' );
9
$nzshpcrt_gateways[$num]['image'] = WPSC_URL . '/images/cc.gif';
10
11
function gateway_chronopay($separator, $sessionid)
0 ignored issues
show
Unused Code introduced by
The parameter $separator is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
12
{
13
	global $wpdb;
14
	$purchase_log_sql = $wpdb->prepare( "SELECT * FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE `sessionid`= %s LIMIT 1", $sessionid );
15
	$purchase_log = $wpdb->get_results($purchase_log_sql,ARRAY_A) ;
0 ignored issues
show
Coding Style introduced by
Space after closing parenthesis of function call prohibited
Loading history...
16
17
	$cart_sql = "SELECT * FROM `".WPSC_TABLE_CART_CONTENTS."` WHERE `purchaseid`='".$purchase_log[0]['id']."'";
18
	$cart = $wpdb->get_results($cart_sql,ARRAY_A) ;
0 ignored issues
show
Coding Style introduced by
Space after closing parenthesis of function call prohibited
Loading history...
19
20
	// ChronoPay post variables
21
	$chronopay_url = get_option('chronopay_url');
22
23
	$data['product_id'] = get_option('chronopay_product_id');
0 ignored issues
show
Coding Style Comprehensibility introduced by
$data was never initialized. Although not strictly required by PHP, it is generally a good practice to add $data = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
24
	$data['product_name'] = get_option('chronopay_product_name');
25
	$data['product_price_currency'] = get_option('chronopay_curcode');
26
	$data['language'] = get_option('chronopay_language');
27
	$data['cb_url'] = add_query_arg( 'chronopay_callback', 'true', home_url( '/' ) );
28
	$data['cb_type'] = 'P';
29
	$data['decline_url'] = home_url( '/?chronopay_callback=true' );
30
	$data['cs1'] = $sessionid;
31
	$data['cs2'] = 'chronopay';
32
	$salt = get_option('chronopay_salt');
33
	$data['cs3'] = md5($salt . md5($sessionid . $salt));	// placed in here for security so that the return call can be validated as 'real'
34
35
	// User details
36
	if($_POST['collected_data'][get_option('chronopay_form_first_name')] != '')
0 ignored issues
show
introduced by
Opening brace should be on the same line as the declaration
Loading history...
37
    {
38
    	$data['f_name'] = $_POST['collected_data'][get_option('chronopay_form_first_name')];
39
    }
40
	if($_POST['collected_data'][get_option('chronopay_form_last_name')] != "")
0 ignored issues
show
introduced by
Opening brace should be on the same line as the declaration
Loading history...
41
    {
42
    	$data['s_name'] = $_POST['collected_data'][get_option('chronopay_form_last_name')];
43
    }
44
  	if($_POST['collected_data'][get_option('chronopay_form_address')] != '')
0 ignored issues
show
introduced by
Opening brace should be on the same line as the declaration
Loading history...
45
    {
46
    	$data['street'] = str_replace("\n",', ', $_POST['collected_data'][get_option('chronopay_form_address')]);
47
    }
48
   	if($_POST['collected_data'][get_option('chronopay_form_city')] != '')
0 ignored issues
show
introduced by
Opening brace should be on the same line as the declaration
Loading history...
49
    {
50
    	$data['city'] = $_POST['collected_data'][get_option('chronopay_form_city')];
51
    }
52
53
    	$data['country'] = (string) wpsc_get_customer_meta( 'billingcountry' );
54
55
  	// Change suggested by [email protected], if email to be sent is not there, dont send an email address
56
  	$email_data = $wpdb->get_results("SELECT `id`,`type` FROM `".WPSC_TABLE_CHECKOUT_FORMS."` WHERE `type` IN ('email') AND `active` = '1'",ARRAY_A);
57
  	foreach((array)$email_data as $email)
0 ignored issues
show
introduced by
Opening brace should be on the same line as the declaration
Loading history...
58
    {
59
    	$data['email'] = $_POST['collected_data'][$email['id']];
60
    }
61
  	if(($_POST['collected_data'][get_option('email_form_field')] != null) && ($data['email'] == null))
0 ignored issues
show
introduced by
Opening brace should be on the same line as the declaration
Loading history...
62
    {
63
    	$data['email'] = $_POST['collected_data'][get_option('email_form_field')];
64
    }
65
66
	// Get Currency details abd price
67
	$currency_code = WPSC_Countries::get_currency_code( get_option( 'currency_type' ) );
68
	$local_currency_code = $currency_code[0]['code'];
69
	$chronopay_currency_code = get_option('chronopay_curcode');
70
71
	// ChronoPay only processes in the set currency.  This is USD or EUR dependent on what the Chornopay account is set up with.
72
	// This must match the ChronoPay settings set up in wordpress.  Convert to the chronopay currency and calculate total.
73
	$curr=new CURRENCYCONVERTER();
74
	$decimal_places = 2;
75
	$total_price = 0;
76
77
	$i = 1;
78
79
	$all_donations = true;
80
	$all_no_shipping = true;
81
82
	foreach($cart as $item)
0 ignored issues
show
introduced by
Opening brace should be on the same line as the declaration
Loading history...
83
	{
84
		$product_data = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM `" . $wpdb->posts . "` WHERE `id`= %d LIMIT 1", $item['prodid'] ), ARRAY_A );
85
		$product_data = $product_data[0];
86
		$variation_count = count($product_variations);
0 ignored issues
show
Bug introduced by
The variable $product_variations does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
87
88
		//Does this even still work in 3.8? We're not using this table.
89
		$variation_sql = $wpdb->prepare( "SELECT * FROM `".WPSC_TABLE_CART_ITEM_VARIATIONS."` WHERE `cart_id` = %d", $item['id'] );
90
		$variation_data = $wpdb->get_results( $variation_sql, ARRAY_A );
91
		$variation_count = count($variation_data);
92
93
		if($variation_count >= 1)
0 ignored issues
show
introduced by
Opening brace should be on the same line as the declaration
Loading history...
94
      	{
95
      		$variation_list = " (";
96
      		$j = 0;
97
98
      		foreach($variation_data as $variation)
0 ignored issues
show
introduced by
Opening brace should be on the same line as the declaration
Loading history...
99
        	{
100
        		if($j > 0)
0 ignored issues
show
introduced by
Opening brace should be on the same line as the declaration
Loading history...
101
          		{
102
          			$variation_list .= ", ";
103
          		}
104
        		$value_id = $variation['venue_id'];
105
        		$value_data = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM `".WPSC_TABLE_VARIATION_VALUES."` WHERE `id`= %d LIMIT 1", $value_id ), ARRAY_A);
106
        		$variation_list .= $value_data[0]['name'];
107
        		$j++;
108
        	}
109
      		$variation_list .= ")";
110
      	}
111
      	else
112
        {
113
        	$variation_list = '';
114
        }
115
116
    	$local_currency_productprice = $item['price'];
117
118
			$local_currency_shipping = $item['pnp'];
119
0 ignored issues
show
Coding Style introduced by
Functions must not contain multiple empty lines in a row; found 2 empty lines
Loading history...
120
121
			$chronopay_currency_productprice = $local_currency_productprice;
122
			$chronopay_currency_shipping = $local_currency_shipping;
123
124
    	$data['item_name_'.$i] = $product_data['name'].$variation_list;
125
    	$data['amount_'.$i] = number_format(sprintf("%01.2f", $chronopay_currency_productprice),$decimal_places,'.','');
126
    	$data['quantity_'.$i] = $item['quantity'];
127
    	$data['item_number_'.$i] = $product_data['id'];
128
129
		if($item['donation'] !=1)
0 ignored issues
show
introduced by
Opening brace should be on the same line as the declaration
Loading history...
130
      	{
131
      		$all_donations = false;
132
      		$data['shipping_'.$i] = number_format($chronopay_currency_shipping,$decimal_places,'.','');
133
      		$data['shipping2_'.$i] = number_format($chronopay_currency_shipping,$decimal_places,'.','');
134
      	}
135
      	else
136
      	{
137
      		$data['shipping_'.$i] = number_format(0,$decimal_places,'.','');
138
      		$data['shipping2_'.$i] = number_format(0,$decimal_places,'.','');
139
      	}
140
141
    	if($product_data['no_shipping'] != 1) {
142
      		$all_no_shipping = false;
143
      	}
144
0 ignored issues
show
Coding Style introduced by
Functions must not contain multiple empty lines in a row; found 2 empty lines
Loading history...
145
146
		$total_price = $total_price + ($data['amount_'.$i] * $data['quantity_'.$i]);
147
148
		if( $all_no_shipping != false )
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like you are loosely comparing two booleans. Considering using the strict comparison !== instead.

When comparing two booleans, it is generally considered safer to use the strict comparison operator.

Loading history...
149
			$total_price = $total_price + $data['shipping_'.$i] + $data['shipping2_'.$i];
150
151
    	$i++;
152
	}
153
  	$base_shipping = $purchase_log[0]['base_shipping'];
154
  	if(($base_shipping > 0) && ($all_donations == false) && ($all_no_shipping == false))
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like you are loosely comparing two booleans. Considering using the strict comparison === instead.

When comparing two booleans, it is generally considered safer to use the strict comparison operator.

Loading history...
introduced by
Opening brace should be on the same line as the declaration
Loading history...
155
    {
156
		$data['handling_cart'] = number_format($base_shipping,$decimal_places,'.','');
157
		$total_price += number_format($base_shipping,$decimal_places,'.','');
158
    }
159
160
	$data['product_price'] = $total_price;
161
162
	// Create Form to post to ChronoPay
163
	$output = "
164
		<form id=\"chronopay_form\" name=\"chronopay_form\" method=\"post\" action=\"$chronopay_url\">\n";
165
166
	foreach($data as $n=>$v) {
167
			$output .= "			<input type=\"hidden\" name=\"$n\" value=\"$v\" />\n";
168
	}
169
170
	$output .= "			<input type=\"submit\" value=\"Continue to ChronoPay\" />
171
		</form>
172
	";
173
174
	// Output the form.
175
	echo $output;
176
	echo "<script language=\"javascript\" type=\"text/javascript\">document.getElementById('chronopay_form').submit();</script>";
177
  	exit();
178
}
179
180
function nzshpcrt_chronopay_callback()
181
{
182
	global $wpdb;
183
	// needs to execute on page start
184
	// look at page 36
185
	if(isset($_GET['chronopay_callback']) && ($_GET['chronopay_callback'] == 'true') && ($_POST['cs2'] == 'chronopay'))
0 ignored issues
show
introduced by
Opening brace should be on the same line as the declaration
Loading history...
186
	{
187
    	// This is a call from chronopay.  validate that it is from a chronopay server in the and process.
188
		// validate cs3 variable to see if it makes sense for security
189
		$salt = get_option('chronopay_salt');
190
		$gen_hash = md5($salt . md5($_POST['cs1'] . $salt));
191
192
		if($gen_hash == $_POST['cs3'])
0 ignored issues
show
introduced by
Opening brace should be on the same line as the declaration
Loading history...
193
		{
194
			// Added in to fake a TX number for testing.  ChronoPay dev accounts do not return a trans_id.
195
			//if($_POST['transaction_id'] == '')
196
			//	$_POST['transaction_id'] = 'testid123123';
197
198
			// process response.
199
		    $sessionid = trim(stripslashes($_POST['cs1']));
200
			$transaction_id = trim(stripslashes($_POST['transaction_id']));
201
			$verification_data['trans_id'] = trim(stripslashes($_POST['transaction_id']));
0 ignored issues
show
Coding Style Comprehensibility introduced by
$verification_data was never initialized. Although not strictly required by PHP, it is generally a good practice to add $verification_data = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
202
			$verification_data['trans_type'] = trim(stripslashes($_POST['transaction_type']));
203
204
			switch($verification_data['trans_type'])
0 ignored issues
show
introduced by
Opening brace should be on the same line as the declaration
Loading history...
205
			{
206
				case 'onetime': // All successful processing statuses.
207
	            case 'initial':
208
				case 'rebill':
209
					$data = array(
210
						'processed'  => 2,
211
						'transactid' => $transact_id,
0 ignored issues
show
Bug introduced by
The variable $transact_id does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
212
						'date'       => time(),
213
					);
214
					wpsc_update_purchase_log_details( $sessionid, $data, 'sessionid' );
215
					transaction_results($sessionid, false, $transaction_id);
216
	            	break;
217
218
	            case 'decline': // if it fails, delete it
219
					$log_id = $wpdb->get_var( $wpdb->prepare( "SELECT `id` FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE `sessionid`=%s LIMIT 1", $sessionid ) );
220
	            	$delete_log_form_sql = $wpdb->prepare( "SELECT * FROM `".WPSC_TABLE_CART_CONTENTS."` WHERE `purchaseid`=%d", $log_id );
221
	            	$cart_content = $wpdb->get_results($delete_log_form_sql,ARRAY_A);
222
	            	foreach((array)$cart_content as $cart_item)
0 ignored issues
show
introduced by
Opening brace should be on the same line as the declaration
Loading history...
223
	              	{
224
	              		$cart_item_variations = $wpdb->query( $wpdb->prepare( "DELETE FROM `".WPSC_TABLE_CART_ITEM_VARIATIONS."` WHERE `cart_id` = %d", $cart_item['id'] ), ARRAY_A);
225
	              	}
226
	            	$wpdb->query( $wpdb->prepare( "DELETE FROM `".WPSC_TABLE_CART_CONTENTS."` WHERE `purchaseid`=%d", $log_id ) );
227
	            	$wpdb->query( $wpdb->prepare( "DELETE FROM `".WPSC_TABLE_SUBMITTED_FORM_DATA."` WHERE `log_id` IN ( %d )", $log_id ) );
228
	            	$wpdb->query( $wpdb->prepare( "DELETE FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE `id`=%d LIMIT 1", $log_id ) );
229
	            	break;
230
231
	            case 'Pending':      // need to wait for "Completed" before processing
232
					$wpdb->update( WPSC_TABLE_PURCHASE_LOGS, array( 'transactid' => $transaction_id, 'date' => time() ), array( 'sessionid' => $sessionid ), array( '%d', '%s' ) );
233
	            	break;
234
235
	            default: // if nothing, do nothing, safest course of action here.
236
	            	break;
237
238
			}
239
		}
240
		else
241
		{
242
			// Security Hash failed!!.. notify someone..
243
			$message = "This message has been sent because a call to your ChronoPay function was made by a server that did not have the correct security key.  This could mean someone is trying to hack your payment site.  The details of the call are below.\n\r\n\r";
244
			$message .= "OUR_POST:\n\r".print_r($header . $req,true)."\n\r\n\r";
0 ignored issues
show
Bug introduced by
The variable $header does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
Bug introduced by
The variable $req does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
introduced by
The use of function print_r() is discouraged
Loading history...
245
			$message .= "THEIR_POST:\n\r".print_r($_POST,true)."\n\r\n\r";
0 ignored issues
show
introduced by
The use of function print_r() is discouraged
Loading history...
246
			$message .= "GET:\n\r".print_r($_GET,true)."\n\r\n\r";
0 ignored issues
show
introduced by
The use of function print_r() is discouraged
Loading history...
247
			$message .= "SERVER:\n\r".print_r($_SERVER,true)."\n\r\n\r";
0 ignored issues
show
introduced by
The use of function print_r() is discouraged
Loading history...
248
			mail(get_option('purch_log_email'), "ChronoPay Security Key Failed!", $message);
249
		}
250
	}
251
}
252
253
function nzshpcrt_chronopay_results()
254
{
255
	// Function used to translate the ChronoPay returned cs1=sessionid POST variable into the recognised GET variable for the transaction results page.
256
	if(isset($_POST['cs1']) && ($_POST['cs1'] !='') && ($_GET['sessionid'] == ''))
0 ignored issues
show
introduced by
Opening brace should be on the same line as the declaration
Loading history...
257
	{
258
		$_GET['sessionid'] = $_POST['cs1'];
259
	}
260
}
261
262
function submit_chronopay()
263
{
264
	if(isset($_POST['chronopay_product_id']))
0 ignored issues
show
introduced by
Opening brace should be on the same line as the declaration
Loading history...
265
    {
266
    	update_option('chronopay_product_id', sanitize_text_field( $_POST['chronopay_product_id'] ) );
267
    }
268
269
  	if(isset($_POST['chronopay_product_name']))
0 ignored issues
show
introduced by
Opening brace should be on the same line as the declaration
Loading history...
270
    {
271
    	update_option('chronopay_product_name', sanitize_text_field( $_POST['chronopay_product_name'] ) );
272
    }
273
274
  	if(isset($_POST['chronopay_curcode']))
0 ignored issues
show
introduced by
Opening brace should be on the same line as the declaration
Loading history...
275
    {
276
    	update_option('chronopay_curcode', sanitize_text_field( $_POST['chronopay_curcode'] ) );
277
    }
278
279
  	if(isset($_POST['chronopay_language']))
0 ignored issues
show
introduced by
Opening brace should be on the same line as the declaration
Loading history...
280
    {
281
    	update_option('chronopay_language', sanitize_text_field( $_POST['chronopay_language'] ) );
282
    }
283
284
  	if(isset($_POST['chronopay_url']))
0 ignored issues
show
introduced by
Opening brace should be on the same line as the declaration
Loading history...
285
    {
286
    	update_option('chronopay_url', esc_url_raw( $_POST['chronopay_url'] ) );
287
    }
288
289
 	if(isset($_POST['chronopay_salt']))
0 ignored issues
show
introduced by
Opening brace should be on the same line as the declaration
Loading history...
290
    {
291
    	update_option('chronopay_salt', sanitize_text_field( $_POST['chronopay_salt'] ) );
292
    }
293
294
    if (!isset($_POST['chronopay_form'])) $_POST['chronopay_form'] = array();
295
	foreach((array)$_POST['chronopay_form'] as $form => $value)
0 ignored issues
show
introduced by
Opening brace should be on the same line as the declaration
Loading history...
296
    {
297
    	update_option(('chronopay_form_'.sanitize_text_field( $form ) ), sanitize_text_field( $value ) );
298
    }
299
	return true;
300
}
301
302
function form_chronopay()
303
{
304
	$select_currency[get_option('chronopay_curcode')] = "selected='selected'";
0 ignored issues
show
Coding Style Comprehensibility introduced by
$select_currency was never initialized. Although not strictly required by PHP, it is generally a good practice to add $select_currency = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
305
	$select_language[get_option('chronopay_language')] = "selected='selected'";
0 ignored issues
show
Coding Style Comprehensibility introduced by
$select_language was never initialized. Although not strictly required by PHP, it is generally a good practice to add $select_language = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
306
	$chronopay_url = ( get_option('chronopay_url')=='' ? 'https://secure.chronopay.com/index_shop.cgi' : get_option('chronopay_url') );
307
	$chronopay_salt = ( get_option( 'chronopay_salt' ) == '' ? wp_generate_password( 24, true, true ) : get_option( 'chronopay_salt' ) );
308
309
	if (!isset($select_currency['USD'])) $select_currency['USD'] = '';
310
	if (!isset($select_currency['EUR'])) $select_currency['EUR'] = '';
311
	if (!isset($select_language['EN'])) $select_language['EN'] = '';
312
	if (!isset($select_language['ES'])) $select_language['ES'] = '';
313
	if (!isset($select_language['NL'])) $select_language['NL'] = '';
314
	if (!isset($select_language['RU'])) $select_language['RU'] = '';
315
316
	$output = "
317
		<tr>
318
			<td>" . __( 'Product ID', 'wp-e-commerce' ) . "</td>
319
			<td>
320
				<input type='text' size='40' value='" . get_option( 'chronopay_product_id' ) . "' name='chronopay_product_id' />
321
				<p class='description'>
322
					" . __( 'This should be set to your product ID that has been set up in the ChronoPay client interface. This is the ChronoPay product that all purchases will be processed against. The cost will be changed depending on the grand total of the users cart.', 'wp-e-commerce' ) . "
323
				</p>
324
			</td>
325
		</tr>
326
		<tr>
327
			<td>" . __( 'Product Name', 'wp-e-commerce' ) . "</td>
328
			<td>
329
				<input type='text' size='40' value='" . get_option( 'chronopay_product_name' ) . "' name='chronopay_product_name' />
330
				<p class='description'>
331
					" . __( 'This is not important and is usually set to the name of the web shop. It is displayed on the ChronoPay secure processing page.', 'wp-e-commerce' ) . "
332
				</p>
333
		</tr>
334
		<tr>
335
			<td>" . __( 'Accepted Currency', 'wp-e-commerce' ) . "</td>
336
			<td>
337
				<select name='chronopay_curcode'>
338
					<option " . $select_currency['USD'] . " value='USD'>" . __( 'USD - U.S. Dollar', 'wp-e-commerce' ) . "</option>
339
					<option " . $select_currency['EUR'] . " value='EUR'>" . __( 'EUR - Euros', 'wp-e-commerce' ) . "</option>
340
				</select>
341
				<p class='description'>
342
					" . __( 'The currency code that ChronoPay will process the payment in. All products must be set up in this currency.', 'wp-e-commerce' ) . "
343
				</p>
344
		</tr>
345
		<tr>
346
			<td>" . __( 'Language', 'wp-e-commerce' ) . "</td>
347
			<td>
348
				<select name='chronopay_language'>
349
					<option " . $select_language['EN'] . " value='EN'>Engish</option>
350
					<option " . $select_language['ES'] . " value='ES'>Spanish</option>
351
					<option " . $select_language['NL'] . " value='NL'>Dutch</option>
352
					<option " . $select_language['RU'] . " value='RU'>Russian</option>
353
				</select>
354
				<p class='description'>
355
					" . __( 'The language that the ChronoPay secure processing page will be displayed in.', 'wp-e-commerce' ) . "
356
				</p>
357
		</tr>
358
		<tr>
359
			<td>" . __( 'Processing URL', 'wp-e-commerce' ) . "</td>
360
			<td>
361
				<input type='text' size='40' value='" . $chronopay_url . "' name='chronopay_url' />
362
				<p class='description'>
363
					" . __( 'URL of the secure payment page customers are sent to for payment processing. If unsure leave at default setting.', 'wp-e-commerce' ) . "
364
				</p>
365
		</tr>
366
		<tr>
367
			<td>" . __( 'Return URL', 'wp-e-commerce' ) . "</td>
368
			<td>
369
				<input type='text' size='40' value='".get_option('transact_url')."' name='chronopay_return_url' />
370
				<p class='description'>
371
					" . __( 'Enter this URL in the ChronoPay web client against the Product ID that you have set up. This page is the transaction details page that you have configured in Shop Options.  It can not be edited on this page.', 'wp-e-commerce' ) . "
372
				</p>
373
		</tr>
374
		<tr>
375
			<td>" . __( 'Security Key', 'wp-e-commerce' ) . "</td>
376
			<td>
377
				<input type='text' size='40' value='" . $chronopay_salt . "' name='chronopay_salt' />
378
				<p class='description'>
379
					" . __( 'A bit of security... This is a keyword that is used to ensure transaction approval calls from ChronoPay to this application are real and were instigated from this server.  Enter a unique word into this field.' , 'wp-e-commerce' ) . "
380
				</p>
381
		</tr>
382
383
		<tr class='firstrowth'>
384
			<td style='border-bottom: medium none;' colspan='2'>
385
				<strong class='form_group'>" . __( 'Forms Sent to Gateway', 'wp-e-commerce' ) . "</strong>
386
			</td>
387
		</tr>
388
389
		<tr>
390
			<td>" . __( 'First Name Field', 'wp-e-commerce' ) . "</td>
391
			<td>
392
				<select name='chronopay_form[first_name]'>
393
				" . nzshpcrt_form_field_list(get_option('chronopay_form_first_name')) . "
394
				</select>
395
			</td>
396
		</tr>
397
		<tr>
398
			<td>" . __( 'Last Name Field', 'wp-e-commerce' ) . "</td>
399
			<td><select name='chronopay_form[last_name]'>
400
				" . nzshpcrt_form_field_list( get_option ( 'chronopay_form_last_name' ) ) . "
0 ignored issues
show
Coding Style introduced by
Space before opening parenthesis of function call prohibited
Loading history...
401
				</select>
402
			</td>
403
		</tr>
404
		<tr>
405
			<td>" . __( 'Address Field', 'wp-e-commerce' ) . "</td>
406
			<td><select name='chronopay_form[address]'>
407
				" . nzshpcrt_form_field_list( get_option ( 'chronopay_form_address' ) ) . "
0 ignored issues
show
Coding Style introduced by
Space before opening parenthesis of function call prohibited
Loading history...
408
				</select>
409
			</td>
410
		</tr>
411
		<tr>
412
			<td>" . __( 'City Field', 'wp-e-commerce' ) . "</td>
413
			<td><select name='chronopay_form[city]'>
414
				" . nzshpcrt_form_field_list( get_option ( 'chronopay_form_city' ) ) . "
0 ignored issues
show
Coding Style introduced by
Space before opening parenthesis of function call prohibited
Loading history...
415
				</select>
416
			</td>
417
		</tr>
418
		<tr>
419
			<td>" . __( 'State Field', 'wp-e-commerce' ) . "</td>
420
			<td><select name='chronopay_form[state]'>
421
				" . nzshpcrt_form_field_list( get_option ( 'chronopay_form_state' ) ) . "
0 ignored issues
show
Coding Style introduced by
Space before opening parenthesis of function call prohibited
Loading history...
422
				</select>
423
			</td>
424
		</tr>
425
		<tr>
426
			<td>" . __( 'Postal / ZIP Code Field', 'wp-e-commerce' ) . "</td>
427
			<td><select name='chronopay_form[post_code]'>
428
				" . nzshpcrt_form_field_list( get_option ( 'chronopay_form_post_code' ) ) . "
0 ignored issues
show
Coding Style introduced by
Space before opening parenthesis of function call prohibited
Loading history...
429
				</select>
430
			</td>
431
		</tr>
432
		<tr>
433
			<td>" . __( 'Country Field', 'wp-e-commerce' ) . "</td>
434
			<td><select name='chronopay_form[country]'>
435
				" . nzshpcrt_form_field_list( get_option ( 'chronopay_form_country' ) ) . "
0 ignored issues
show
Coding Style introduced by
Space before opening parenthesis of function call prohibited
Loading history...
436
				</select>
437
			</td>
438
		</tr>
439
		   <tr>
440
           <td colspan='2'>
441
           	" . sprintf( __( 'For more help configuring Chronopay, read our documentation <a href="%s">here</a>', 'wp-e-commerce' ), esc_url( 'https://docs.wpecommerce.org/documentation/chronopay/' ) ) . "
442
           </td>
443
       </tr>";
444
445
	return $output;
446
}
447
448
449
add_action('init', 'nzshpcrt_chronopay_callback');
450
add_action('init', 'nzshpcrt_chronopay_results');
451
452
?>
0 ignored issues
show
Best Practice introduced by
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...
453