title: WooCommerce Custom Payment Gateway
body: <p>I am trying to make a Custom Gateway Plugin for my Merchant Account but I got stuck and I don't know how to continue.</p>
  
  <p>Now, here is what I done so far:</p>
  
  <pre><code>&lt;?php
   /*
    Plugin Name: Paysecure.ro Payment Gateway
    Plugin URI: http://www.Paysecure.ro
    Description: Allows you to use Paysecure.ro Payment Gateway with the WooCommerce plugin.
    Version: 0.0.1
    Author: Andrei Raileanu
   */
  
  if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
  
  add_action('plugins_loaded', 'woocommerce_Paysecure', 0);
  
  function woocommerce_Paysecure(){
      if (!class_exists('WC_Payment_Gateway'))
          return; // if the WC payment gateway class is not available, do nothing
      if(class_exists('WC_Paysecure'))
          return;
  
      class WC_Gateway_Paysecure extends WC_Payment_Gateway{
          public function __construct(){
  
              $plugin_dir = plugin_dir_url(__FILE__);
  
              global $woocommerce;
  
              $this-&gt;id = 'Paysecure';
              $this-&gt;icon = apply_filters('woocommerce_Paysecure_icon', ''.$plugin_dir.'Paysecure.png');
              $this-&gt;has_fields = true;
  
              // Load the settings
              $this-&gt;init_form_fields();
              $this-&gt;init_settings();
  
              // Define user set variables
              $this-&gt;title = "Credit/Debit Card";
               $this-&gt;description = "You will be redirected to paysecure.ro to complete your purchase.";
              $this-&gt;cui = "XXXXXXXXX";
              $this-&gt;encryption_key = "XXXXXXXXX";
              $this-&gt;currency = "USD";
  
              // Logs
              if ($this-&gt;debug == 'yes'){
                  $this-&gt;log = $woocommerce-&gt;logger();
              }
  
              // Actions
              add_action('woocommerce_receipt_' . $this-&gt;id, array($this, 'receipt_page'));
  
              // Save options
              add_action( 'woocommerce_update_options_payment_gateways_' . $this-&gt;id, array( $this, 'process_admin_options' ) );
  
              // Payment listener/API hook
              add_action('woocommerce_api_wc_' . $this-&gt;id, array($this, 'check_ipn_response'));
  
          }
  
          function init_form_fields()
              {
                  $this-&gt;form_fields = array(
                      'enabled' =&gt; array(
                          'title' =&gt; __( 'Enable/Disable', 'woocommerce' ),
                          'type' =&gt; 'checkbox',
                          'label' =&gt; __( 'Enable Paysecure', 'woocommerce' ),
                          'default' =&gt; 'yes'
                      )
                  );
          }
  
          public function admin_options() {
  
              ?&gt;
              &lt;h3&gt;&lt;?php _e( 'Paysecure', 'woocommerce' ); ?&gt;&lt;/h3&gt;
              &lt;p&gt;&lt;?php _e( 'Paysecure Payment Gateway', 'woocommerce' ); ?&gt;&lt;/p&gt;
  
              &lt;table class="form-table"&gt;
                      &lt;?php $this-&gt;generate_settings_html(); ?&gt;
                &lt;/table&gt;
  
               &lt;?php
          }
  
          function payment_fields() {
              $plugin_dir = plugin_dir_url(__FILE__);
              // Description of payment method from settings
              if ($this-&gt;description) { ?&gt;
                  &lt;p&gt;&lt;?php
                  echo $this-&gt;description; ?&gt;
                  &lt;/p&gt;&lt;?php
              } ?&gt;
  
  &lt;?php
          }
  
          function process_payment( $order_id ) {
              global $woocommerce;
  
              $order = new WC_Order($order_id);
  
              // I WILL NEED THESE FIELDS
              //$this-&gt;notify_url;
          //$order-&gt;get_total();
              //$order-&gt;get_order_number();
              //$order-&gt;billing_first_name; 
              //$order-&gt;billing_email;
  
          }
  
      }
  
      function add_Paysecure_gateway($methods){
          $methods[] = 'WC_Gateway_Paysecure';
          return $methods;
      }
  
      add_filter('woocommerce_payment_gateways', 'add_Paysecure_gateway');
  
  }
  </code></pre>
  
  <p>Here are the PHP instructions from my merchant account provider:</p>
  
  <pre><code>&lt;?php 
   require_once('./functions.php'); 
   $key = 'THIS IS THE ENCRYPTION KEY'; 
   $data = array( 'cui' =&gt; 'THIS IS THE CUI CODE',
  'AMOUNT' =&gt; '200',
  'CURRENCY' =&gt; 'USD',
  'ORDER' =&gt;  '12313',
  'DESC' =&gt; ps_clean('SHORT DESCRIPTION'),
  'PENTRU' =&gt; 'EMAIL ADDRESS',
  'TRTYPE' =&gt; 0,                              
  'BACKREF' =&gt; 'http://www.site.ro/test.php',
  'TIMESTAMP'=&gt;time()   
  </code></pre>
  
  <p>);</p>
  
  <pre><code> echo '&lt;form action="https://paysecure.ro/order/cgi-bin/" method="post" &gt;';
  
    foreach ($data as $l =&gt; $v ) echo '&lt;input size="55" readonly type="text" name="'.$l.'" value="'.$v.'" /&gt; : &lt;label for="'.$l.'"&gt;'.$l.'&lt;/label&gt;&lt;br&gt;'; 
  
    echo '&lt;input size="55" type="text" name="P_SIGN" readonly value="'.calculateSign($data,$key).'" /&gt;&lt;br&gt;' ; //se calculeaza P_SIGN - ul , encriptarea datelor
  
  ?&gt;
  &lt;input type="submit" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Can someone help me with the rest of the code?</p>