WC_Payment_Gateway_CC

Credit Card Payment Gateway.

Defined (1)

The class is defined in the following location(s).

/includes/gateways/class-wc-payment-gateway-cc.php  
  1. class WC_Payment_Gateway_CC extends WC_Payment_Gateway { 
  2.  
  3. /** 
  4. * Builds our payment fields area - including tokenization fields for logged 
  5. * in users, and the actual payment fields. 
  6. * @since 2.6.0 
  7. */ 
  8. public function payment_fields() { 
  9. if ( $this->supports( 'tokenization' ) && is_checkout() ) { 
  10. $this->tokenization_script(); 
  11. $this->saved_payment_methods(); 
  12. $this->form(); 
  13. $this->save_payment_method_checkbox(); 
  14. } else { 
  15. $this->form(); 
  16.  
  17. /** 
  18. * Output field name HTML 
  19. * Gateways which support tokenization do not require names - we don't want the data to post to the server. 
  20. * @since 2.6.0 
  21. * @param string $name 
  22. * @return string 
  23. */ 
  24. public function field_name( $name ) { 
  25. return $this->supports( 'tokenization' ) ? '' : ' name="' . esc_attr( $this->id . '-' . $name ) . '" '; 
  26.  
  27. /** 
  28. * Outputs fields for entering credit card information. 
  29. * @since 2.6.0 
  30. */ 
  31. public function form() { 
  32. wp_enqueue_script( 'wc-credit-card-form' ); 
  33.  
  34. $fields = array(); 
  35.  
  36. $cvc_field = '<p class="form-row form-row-last"> 
  37. <label for="' . esc_attr( $this->id ) . '-card-cvc">' . esc_html__( 'Card code', 'woocommerce' ) . ' <span class="required">*</span></label> 
  38. <input id="' . esc_attr( $this->id ) . '-card-cvc" class="input-text wc-credit-card-form-card-cvc" inputmode="numeric" autocomplete="off" autocorrect="no" autocapitalize="no" spellcheck="no" type="tel" maxlength="4" placeholder="' . esc_attr__( 'CVC', 'woocommerce' ) . '" ' . $this->field_name( 'card-cvc' ) . ' style="width:100px" /> 
  39. </p>'; 
  40.  
  41. $default_fields = array( 
  42. 'card-number-field' => '<p class="form-row form-row-wide"> 
  43. <label for="' . esc_attr( $this->id ) . '-card-number">' . esc_html__( 'Card number', 'woocommerce' ) . ' <span class="required">*</span></label> 
  44. <input id="' . esc_attr( $this->id ) . '-card-number" class="input-text wc-credit-card-form-card-number" inputmode="numeric" autocomplete="cc-number" autocorrect="no" autocapitalize="no" spellcheck="no" type="tel" placeholder="•••• •••• •••• ••••" ' . $this->field_name( 'card-number' ) . ' /> 
  45. </p>',  
  46. 'card-expiry-field' => '<p class="form-row form-row-first"> 
  47. <label for="' . esc_attr( $this->id ) . '-card-expiry">' . esc_html__( 'Expiry (MM/YY)', 'woocommerce' ) . ' <span class="required">*</span></label> 
  48. <input id="' . esc_attr( $this->id ) . '-card-expiry" class="input-text wc-credit-card-form-card-expiry" inputmode="numeric" autocomplete="cc-exp" autocorrect="no" autocapitalize="no" spellcheck="no" type="tel" placeholder="' . esc_attr__( 'MM / YY', 'woocommerce' ) . '" ' . $this->field_name( 'card-expiry' ) . ' /> 
  49. </p>',  
  50. ); 
  51.  
  52. if ( ! $this->supports( 'credit_card_form_cvc_on_saved_method' ) ) { 
  53. $default_fields['card-cvc-field'] = $cvc_field; 
  54.  
  55. $fields = wp_parse_args( $fields, apply_filters( 'woocommerce_credit_card_form_fields', $default_fields, $this->id ) ); 
  56. ?> 
  57.  
  58. <fieldset id="wc-<?php echo esc_attr( $this->id ); ?>-cc-form" class='wc-credit-card-form wc-payment-form'> 
  59. <?php do_action( 'woocommerce_credit_card_form_start', $this->id ); ?> 
  60. <?php 
  61. foreach ( $fields as $field ) { 
  62. echo $field; 
  63. ?> 
  64. <?php do_action( 'woocommerce_credit_card_form_end', $this->id ); ?> 
  65. <div class="clear"></div> 
  66. </fieldset> 
  67. <?php 
  68.  
  69. if ( $this->supports( 'credit_card_form_cvc_on_saved_method' ) ) { 
  70. echo '<fieldset>' . $cvc_field . '</fieldset>';