title: woocommerce: How to install the Custom Payment Gateway
body: <p>I have created a class for new payment gateway. I just duplicated the existing payment class &amp; changed the class name, file name and also incorporated the install code.</p>
  
  <p>But I couldn't find the way to install a new payment gateway in admin panel.
  Please advice.</p>
  
  <p>Wordpress Ver: 3.5.1
  Class:</p>
  
  <pre><code>&lt;?php
  //if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
  
  /**
   * braintreedemo Payment Gateway
   *
   * Provides a braintreedemo Payment Gateway, mainly for testing purposes.
   *
   * @class       WC_Gateway_braintreedemo
   * @extends     WC_Payment_Gateway
   * @version     2.1.0
   * @package     WooCommerce/Classes/Payment
   * @author      WooThemes
   */
  
   add_action('plugins_loaded', 'woocommerce_braintree_init', 0);
  
   function woocommerce_braintree_init() {
  if(!class_exists('WC_Payment_Gateway')) return;
  
  class WC_Gateway_Braintree extends WC_Payment_Gateway {
  
      /**
       * Constructor for the gateway.
       */
      public function __construct() {
          $this-&gt;id                 = 'braintree';
          $this-&gt;icon               = apply_filters('woocommerce_cheque_icon', '');
          $this-&gt;has_fields         = false;
          $this-&gt;method_title       = __( 'Craintreedemo', 'woocommerce' );
          $this-&gt;method_description = __( 'Allows braintree payments. Why would you take braintree in this day and age? Well you probably wouldn\'t but it does allow you to make test purchases for testing order emails and the \'success\' pages etc.', 'woocommerce' );
  
          // Load the settings.
          $this-&gt;init_form_fields();
          $this-&gt;init_settings();
  
          // Define user set variables
          $this-&gt;title        = $this-&gt;get_option( 'title' );
          $this-&gt;description  = $this-&gt;get_option( 'description' );
          $this-&gt;instructions = $this-&gt;get_option( 'instructions', $this-&gt;description );
  
          // Actions
          add_action( 'woocommerce_update_options_payment_gateways_' . $this-&gt;id, array( $this, 'process_admin_options' ) );
          add_action( 'woocommerce_thankyou_braintree', array( $this, 'thankyou_page' ) );
  
          // Customer Emails
          add_action( 'woocommerce_email_before_order_table', array( $this, 'email_instructions' ), 10, 2 );
      }
  
      /**
       * Initialise Gateway Settings Form Fields
       */
      public function init_form_fields() {
  
          $this-&gt;form_fields = array(
              'enabled' =&gt; array(
                  'title'   =&gt; __( 'Enable/Disable', 'woocommerce' ),
                  'type'    =&gt; 'checkbox',
                  'label'   =&gt; __( 'Enable braintree 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; __( 'braintree Payment', 'woocommerce' ),
                  'desc_tip'    =&gt; true,
              ),
              'description' =&gt; array(
                  'title'       =&gt; __( 'Description', 'woocommerce' ),
                  'type'        =&gt; 'textarea',
                  'description' =&gt; __( 'Payment method description that the customer will see on your checkout.', 'woocommerce' ),
                  'default'     =&gt; __( 'Please send your braintree to Store Name, Store Street, Store Town, Store State / County, Store Postcode.', 'woocommerce' ),
                  'desc_tip'    =&gt; true,
              ),
              'instructions' =&gt; array(
                  'title'       =&gt; __( 'Instructions', 'woocommerce' ),
                  'type'        =&gt; 'textarea',
                  'description' =&gt; __( 'Instructions that will be added to the thank you page and emails.', 'woocommerce' ),
                  'default'     =&gt; '',
                  'desc_tip'    =&gt; true,
              ),
          );
      }
  
      /**
       * Output for the order received page.
       */
      public function thankyou_page() {
          if ( $this-&gt;instructions )
              echo wpautop( wptexturize( $this-&gt;instructions ) );
      }
  
      /**
       * Add content to the WC emails.
       *
       * @access public
       * @param WC_Order $order
       * @param bool $sent_to_admin
       */
      public function email_instructions( $order, $sent_to_admin ) {
          if ( $sent_to_admin || $order-&gt;status !== 'on-hold' || $order-&gt;payment_method !== 'braintree' )
              return;
  
          if ( $this-&gt;instructions )
              echo wpautop( wptexturize( $this-&gt;instructions ) );
      }
  
      /**
       * Process the payment and return the result
       *
       * @param int $order_id
       * @return array
       */
      public function process_payment( $order_id ) {
  
          $order = new WC_Order( $order_id );
  
          // Mark as on-hold (we're awaiting the braintree)
          $order-&gt;update_status( 'on-hold', __( 'Awaiting braintree payment', 'woocommerce' ) );
  
          // Reduce stock levels
          $order-&gt;reduce_order_stock();
  
          // Remove cart
          WC()-&gt;cart-&gt;empty_cart();
  
          // Return thankyou redirect
          return array(
              'result'    =&gt; 'success',
              'redirect'  =&gt; $this-&gt;get_return_url( $order )
          );
      }
  }
  
  /**
   * Add the Gateway to WooCommerce
   **/
  function woocommerce_add_braintree_gateway($methods) {
      $methods[] = 'WC_Braintree';
      return $methods;
  }
  add_filter('woocommerce_payment_gateways', 'woocommerce_add_braintree_gateway' );
  }
  </code></pre>