class-wc-payment-gateway-echeck.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. /**
  3. * Class WC_Payment_Gateway_eCheck file.
  4. *
  5. * @package WooCommerce\Gateways
  6. */
  7. if ( ! defined( 'ABSPATH' ) ) {
  8. exit;
  9. }
  10. /**
  11. * Class for eCheck Payment Gateway
  12. *
  13. * @since 2.6.0
  14. * @package WooCommerce/Classes
  15. */
  16. class WC_Payment_Gateway_ECheck extends WC_Payment_Gateway {
  17. /**
  18. * Builds our payment fields area - including tokenization fields for logged
  19. * in users, and the actual payment fields.
  20. *
  21. * @since 2.6.0
  22. */
  23. public function payment_fields() {
  24. if ( $this->supports( 'tokenization' ) && is_checkout() ) {
  25. $this->tokenization_script();
  26. $this->saved_payment_methods();
  27. $this->form();
  28. $this->save_payment_method_checkbox();
  29. } else {
  30. $this->form();
  31. }
  32. }
  33. /**
  34. * Outputs fields for entering eCheck information.
  35. *
  36. * @since 2.6.0
  37. */
  38. public function form() {
  39. $fields = array();
  40. $default_fields = array(
  41. 'routing-number' => '<p class="form-row form-row-first">
  42. <label for="' . esc_attr( $this->id ) . '-routing-number">' . esc_html__( 'Routing number', 'woocommerce' ) . '&nbsp;<span class="required">*</span></label>
  43. <input id="' . esc_attr( $this->id ) . '-routing-number" class="input-text wc-echeck-form-routing-number" type="text" maxlength="9" autocomplete="off" placeholder="&bull;&bull;&bull;&bull;&bull;&bull;&bull;&bull;&bull;" name="' . esc_attr( $this->id ) . '-routing-number" />
  44. </p>',
  45. 'account-number' => '<p class="form-row form-row-wide">
  46. <label for="' . esc_attr( $this->id ) . '-account-number">' . esc_html__( 'Account number', 'woocommerce' ) . '&nbsp;<span class="required">*</span></label>
  47. <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" />
  48. </p>',
  49. );
  50. $fields = wp_parse_args( $fields, apply_filters( 'woocommerce_echeck_form_fields', $default_fields, $this->id ) );
  51. ?>
  52. <fieldset id="<?php echo esc_attr( $this->id ); ?>-cc-form" class='wc-echeck-form wc-payment-form'>
  53. <?php do_action( 'woocommerce_echeck_form_start', $this->id ); ?>
  54. <?php
  55. foreach ( $fields as $field ) {
  56. echo $field; // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
  57. }
  58. ?>
  59. <?php do_action( 'woocommerce_echeck_form_end', $this->id ); ?>
  60. <div class="clear"></div>
  61. </fieldset>
  62. <?php
  63. }
  64. }