1
|
|
|
<?php |
|
|
|
|
2
|
|
|
if ( ! defined( 'ABSPATH' ) ) { |
3
|
|
|
exit; |
4
|
|
|
} |
5
|
|
|
|
6
|
|
|
/** |
7
|
|
|
* eCheck Payment Gateway |
8
|
|
|
* |
9
|
|
|
* @since 2.6.0 |
10
|
|
|
* @package WooCommerce/Classes |
11
|
|
|
* @author WooThemes |
12
|
|
|
*/ |
13
|
|
|
class WC_Payment_Gateway_eCheck extends WC_Payment_Gateway { |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Builds our payment fields area - including tokenization fields and the actualy payment fields. |
17
|
|
|
* If tokenization is displayed, just the fields will be displayed. |
18
|
|
|
* @since 2.6.0 |
19
|
|
|
*/ |
20
|
|
|
public function payment_fields() { |
21
|
|
|
$display_tokenization = $this->supports( 'tokenization' ) && is_checkout(); |
22
|
|
|
|
23
|
|
|
if ( $display_tokenization ) { |
24
|
|
|
$this->tokenization_script(); |
25
|
|
|
$this->saved_payment_methods(); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
$this->form(); |
29
|
|
|
|
30
|
|
|
if ( $display_tokenization ) { |
31
|
|
|
$this->save_payment_method_checkbox(); |
32
|
|
|
} |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Outputs fields for entering eCheck information. |
37
|
|
|
* @since 2.6.0 |
38
|
|
|
*/ |
39
|
|
|
public function form() { |
40
|
|
|
$html = ''; |
|
|
|
|
41
|
|
|
$fields = array(); |
42
|
|
|
|
43
|
|
|
$default_fields = array( |
44
|
|
|
'routing-number' => '<p class="form-row form-row-first"> |
45
|
|
|
<label for="' . esc_attr( $this->id ) . '-routing-number">' . __( 'Routing Number', 'woocommerce' ) . ' <span class="required">*</span></label> |
46
|
|
|
<input id="' . esc_attr( $this->id ) . '-routing-number" class="input-text wc-echeck-form-routing-number" type="text" maxlength="9" autocomplete="off" placeholder="•••••••••" name="' . esc_attr( $this->id ) . '-routing-number" /> |
47
|
|
|
</p>', |
48
|
|
|
'account-number' => '<p class="form-row form-row-wide"> |
49
|
|
|
<label for="' . esc_attr( $this->id ) . '-account-number">' . __( 'Account Number', 'woocommerce' ) . ' <span class="required">*</span></label> |
50
|
|
|
<input id="' . esc_attr( $this->id ) . '-account-number" class="input-text wc-echeck-form-account-number" type="text" autocomplete="off" name="' . esc_attr( $this->id ) . '-account-number" maxlength="17" /> |
51
|
|
|
</p>', |
52
|
|
|
); |
53
|
|
|
|
54
|
|
|
$fields = wp_parse_args( $fields, apply_filters( 'woocommerce_echeck_form_fields', $default_fields, $this->id ) ); |
55
|
|
|
?> |
56
|
|
|
|
57
|
|
|
<fieldset id="<?php echo esc_attr( $this->id ); ?>-cc-form" class='wc-echeck-form'> |
58
|
|
|
<?php do_action( 'woocommerce_echeck_form_start', $this->id ); ?> |
59
|
|
|
<?php |
60
|
|
|
foreach ( $fields as $field ) { |
61
|
|
|
echo $field; |
62
|
|
|
} |
63
|
|
|
?> |
64
|
|
|
<?php do_action( 'woocommerce_echeck_form_end', $this->id ); ?> |
65
|
|
|
<div class="clear"></div> |
66
|
|
|
</fieldset><?php |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
} |
70
|
|
|
|
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.