title: WordPress Plugin WooCommerce, Custom Payment Gateway Settings Not Saving
body: <p>I'm working on a custom payment gateway for the WordPress plugin WooCommerce. I cannot seem to save the settings for the payment gateway. When I enter information into the fields and then click save, the page refreshes with all of the fields blank. What am I doing wrong?</p>
  
  <p>Here is my code.</p>
  
  <pre><code>&lt;?php
  /**
   * Plugin Name: Bitcoin WooCommerce Integration Made Easy
   * Description: A Bitcoin processing plugin that integrates into WooCommerce made specifically for Bitcoin Publish.
   * Version: 0.01
   * Author: Cammy_the_block
   */
  
  add_action( 'plugins_loaded', 'init_your_gateway_class' );
  
  function init_your_gateway_class() {
      class WC_Gateway_Your_Gateway extends WC_Payment_Gateway {
          function __construct() {
              $this-&gt;id = "Bitcoin WooCommerce Integration Gateway";
              $this-&gt;method_title = "Bitcoin with BWCIME";
              $this-&gt;method_description = "More later";
  
              $this-&gt;init_form_fields();
              $this-&gt;init_settings();
  
              if ( version_compare( WOOCOMMERCE_VERSION, '2.0.0', '&gt;=' ) ) {
                      add_action( 'woocommerce_update_options_payment_gateways_' . $this-&gt;id, array( &amp;$this, 'process_admin_options' ) );
              } 
              else {
                      add_action( 'woocommerce_update_options_payment_gateways', array( &amp;$this, 'process_admin_options' ) );
              }
          }
          function init_form_fields(){
              $this-&gt;form_fields = array(
                      'enabled' =&gt; array(
                              'title' =&gt; __( 'Enable/Disable', 'woocommerce' ),
                              'type' =&gt; 'checkbox',
                              'label' =&gt; __( 'Enable Cheque Payment', 'woocommerce' ),
                              'default' =&gt; 'yes'
                      ),
                      'title' =&gt; array(
                              'title' =&gt; __( 'Title', 'woocommerce' ),
                              'type' =&gt; 'text',
                              'description' =&gt; __( 'This controls the title which the user sees during checkout.', 'woocommerce' ),
                              'default' =&gt; __( 'Cheque Payment', 'woocommerce' ),
                              'desc_tip' =&gt; true,
                      ),
                      'description' =&gt; array(
                              'title' =&gt; __( 'Customer Message', 'woocommerce' ),
                              'type' =&gt; 'textarea',
                              'default' =&gt; ''
                      )
              );
          }
      }
      function process_payment( $order_id ) {
          global $woocommerce;
          $order = new WC_Order( $order_id );
          $productArray = array();
          $x = 0;
          foreach( $order-&gt;get_items() as $item_id =&gt; $item ) {
              $productArray[x] = $order-&gt;get_product_from_item( $item );
              $x++;
          }
  
          // Mark as on-hold (we're awaiting the cheque)
          $order-&gt;update_status('on-hold', 
          __( 'Awaiting cheque payment. there are ' + $productArray.length + 'items', 'woocommerce' )
          );
  
  
          // Remove cart
          $woocommerce-&gt;cart-&gt;empty_cart();
  
          // Return thankyou redirect
          return array(
              'result' =&gt; 'success',
              'redirect' =&gt; $this-&gt;get_return_url( $order )
          );
      }
  }
  function add_your_gateway_class ($methods ) {
      $methods[] = 'WC_Gateway_Your_Gateway'; 
      return $methods;
  }
  
  add_filter( 'woocommerce_payment_gateways', 'add_your_gateway_class' );
   ?&gt;
  </code></pre>
  
  <p><strong>EDIT:</strong></p>
  
  <p>The add filter code runs add_your_gateway_class, which in turn causes it to run WC_Gateway_Your_Gateway.</p>