title: Payment Method in wordpress
body: <p>Hi i am going to develop a wordpress plugin for the payment method with OKpay, but when i have use it i get the following error:- Fatal error: Call to undefined method woocommerce_okpay::get_return_url() in /home/sixtydev/public_html/woo/wp-content/plugins/woocommerce-okpay/gateway-okpay.php on line 193</p>
  
  <p>here is the my code</p>
  
  <pre><code>&lt;?php
  /**
   * OKPAY Payment Gateway
   * 
   * Provides a OKPAY Standard Payment Gateway.
   *
   * @class       woocommerce_okpay
   * @package     WooCommerce
   * @category    Payment Gateways
   * @author      WooThemes
   */
  class woocommerce_okpay extends woocommerce_payment_gateway {
  
      public function __construct() { 
          global $woocommerce;
  
          $this-&gt;id           = 'okpay';
          $this-&gt;icon         = apply_filters('woocommerce_okpay_icon', $this-&gt;plugin_url() . '/okpay.png');
          $this-&gt;has_fields   = false;
          $this-&gt;liveurl      = 'https://www.okpay.com/process.html';
          $this-&gt;testurl      = 'https://www.okpay.com/process.html';
  
          // Load the form fields.
          $this-&gt;init_form_fields();
  
          // Load the settings.
          $this-&gt;init_settings();
  
          // Define user set variables
          $this-&gt;title        = $this-&gt;settings['title'];
          $this-&gt;description  = $this-&gt;settings['description'];
          $this-&gt;email        = $this-&gt;settings['email'];
          $this-&gt;testmode     = 'no';//$this-&gt;settings['testmode'];
          $this-&gt;debug        = $this-&gt;settings['debug']; 
          $this-&gt;payfee   = ($this-&gt;settings['payfee'] == 'yes') ? 0 : 1;
  
          // Logs
          if ($this-&gt;debug=='yes') $this-&gt;log = $woocommerce-&gt;logger();
  
          // Actions
          add_action( 'init', array(&amp;$this, 'check_ipn_response') );
          add_action('valid-okpay-standard-ipn-request', array(&amp;$this, 'successful_request') );
          add_action('woocommerce_receipt_okpay', array(&amp;$this, 'receipt_page'));
          add_action('woocommerce_update_options_payment_gateways', array(&amp;$this, 'process_admin_options'));
  
          if ( !$this-&gt;is_valid_for_use() ) $this-&gt;enabled = false;
      } 
  
  
       /**
       * return plugin url
       * @return string
       */
      function plugin_url() {
  
              if (is_ssl()) :
  
                  return str_replace('http://', 'https://', WP_PLUGIN_URL) . "/" . plugin_basename( dirname(dirname(__FILE__)));
  
              else :
  
                  return WP_PLUGIN_URL . "/" . plugin_basename(dirname(__FILE__));
  
              endif;
  
      }
  
       /**
       * Check if this gateway is enabled and available in the user's country
       */
      function is_valid_for_use() {
          if (!in_array(get_option('woocommerce_currency'), array('AUD', 'BRL', 'CAD', 'MXN', 'NZD', 'HKD', 'SGD', 'USD', 'EUR', 'JPY', 'TRY', 'NOK', 'CZK', 'DKK', 'HUF', 'ILS', 'MYR', 'PHP', 'PLN', 'SEK', 'CHF', 'TWD', 'THB', 'GBP'))) return false;
  
          return true;
      }
  
      /**
       * Admin Panel Options 
       * - Options for bits like 'title' and availability on a country-by-country basis
       *
       * @since 1.0.0
       */
      public function admin_options() {
  
          ?&gt;
          &lt;h3&gt;&lt;?php _e('OKPAY', 'woothemes'); ?&gt;&lt;/h3&gt;
          &lt;p&gt;&lt;?php _e('OKPAY works by sending the user to OKPAY to enter their payment information.', 'woothemes'); ?&gt;&lt;/p&gt;
          &lt;table class="form-table"&gt;
          &lt;?php
              if ( $this-&gt;is_valid_for_use() ) :
  
                  // Generate the HTML For the settings form.
                  $this-&gt;generate_settings_html();
  
              else :
  
                  ?&gt;
                      &lt;div class="inline error"&gt;&lt;p&gt;&lt;strong&gt;&lt;?php _e( 'Gateway Disabled', 'woothemes' ); ?&gt;&lt;/strong&gt;: &lt;?php _e( 'OKPAY does not support your store currency.', 'woothemes' ); ?&gt;&lt;/p&gt;&lt;/div&gt;
                  &lt;?php
  
              endif;
          ?&gt;
          &lt;/table&gt;&lt;!--/.form-table--&gt;
          &lt;?php
      } // End admin_options()
  
      /**
       * Initialise Gateway Settings Form Fields
       */
      function init_form_fields() {
  
          $this-&gt;form_fields = array(
              'enabled' =&gt; array(
                              'title' =&gt; __( 'Enable/Disable', 'woothemes' ), 
                              'type' =&gt; 'checkbox', 
                              'label' =&gt; __( 'Enable OKPAY', 'woothemes' ), 
                              'default' =&gt; 'yes'
                          ), 
              'title' =&gt; array(
                              'title' =&gt; __( 'Title', 'woothemes' ), 
                              'type' =&gt; 'text', 
                              'description' =&gt; __( 'This controls the title which the user sees during checkout.', 'woothemes' ), 
                              'default' =&gt; __( 'OKPAY', 'woothemes' )
                          ),
              'description' =&gt; array(
                              'title' =&gt; __( 'Description', 'woothemes' ), 
                              'type' =&gt; 'textarea', 
                              'description' =&gt; __( 'This controls the description which the user sees during checkout.', 'woothemes' ), 
                              'default' =&gt; __("Pay via OKPAY; you can pay with your credit card if you don't have a okpay account", 'woothemes')
                          ),
              'email' =&gt; array(
                              'title' =&gt; __( 'OKPAY Email', 'woothemes' ), 
                              'type' =&gt; 'text', 
                              'description' =&gt; __( 'Please enter your OKPAY email address; this is needed in order to take payment.', 'woothemes' ), 
                              'default' =&gt; ''
                          ),
              'payfee' =&gt; array(
                              'title' =&gt; __( 'OKPAY fee', 'woothemes' ),
                              'type' =&gt; 'checkbox',
                              'description' =&gt; __( 'Check if you pay the fee for orders or uncheck if client pay it.', 'woothemes' ),
                              'default' =&gt; 'yes'
                          ),
               /*
              'testmode' =&gt; array(
                              'title' =&gt; __( 'OKPAY sandbox', 'woothemes' ),
                              'type' =&gt; 'checkbox',
                              'label' =&gt; __( 'Enable OKPAY sandbox', 'woothemes' ),
                              'default' =&gt; 'yes'),  */
              'debug' =&gt; array(
                              'title' =&gt; __( 'Debug', 'woothemes' ), 
                              'type' =&gt; 'checkbox', 
                              'label' =&gt; __( 'Enable logging (&lt;code&gt;woocommerce/logs/okpay.txt&lt;/code&gt;)', 'woothemes' ), 
                              'default' =&gt; 'no'
                          )
              );
  
      } // End init_form_fields()
  
      /**
       * There are no payment fields for okpay, but we want to show the description if set.
       **/
      function payment_fields() {
          if ($this-&gt;description) echo wpautop(wptexturize($this-&gt;description));
      }
  
      /**
       * Generate the okpay button link
       **/
      public function generate_okpay_form( $order_id ) {
          global $woocommerce;
  
          $order = &amp;new woocommerce_order( $order_id );
  
          if ( $this-&gt;testmode == 'yes' ):
              $okpay_adr = $this-&gt;testurl . '?';
          else :
              $okpay_adr = $this-&gt;liveurl . '?';      
          endif;
  
          if ($this-&gt;debug=='yes') $this-&gt;log-&gt;add( 'okpay', 'Generating payment form for order #' . $order_id ." | ".$order-&gt;order_key. '. Notify URL: ' . $this-&gt;get_return_url( $order ));
  
  
          $okpay_args = 
              array(
                  'ok_fees'               =&gt; $this-&gt;payfee,
                  'ok_receiver'           =&gt; $this-&gt;email,
  
                  'ok_currency'           =&gt; get_option('woocommerce_currency'),
                  /*'ap_itemname'             =&gt; sprintf(__('Order #%s' , 'woothemes'), $order-&gt;id),
                  'ap_quantity'           =&gt; 1,
                  'ap_amount'             =&gt; number_format($order-&gt;order_total, 2, '.', ''),
                  'ap_description'        =&gt; "Order from curiousuniversity",  */
                  'ok_return_success'             =&gt; $this-&gt;get_return_url( $order ),
                  'ok_return_fail'            =&gt; $order-&gt;get_cancel_order_url(),
  
  
                  // IPN
                  'ok_ipn'            =&gt; trailingslashit(home_url()).'?okpayListener=okpay_standard_IPN',
  
                  // Address info
                  'ok_payer_first_name'               =&gt; $order-&gt;billing_first_name,
                  'ok_payer_last_name'                =&gt; $order-&gt;billing_last_name,
                  'ok_payer_business_name'                =&gt; $order-&gt;billing_company,
                  'ok_payer_street'       =&gt; $order-&gt;billing_address_1,
                  //'ap_addressline2'     =&gt; $order-&gt;billing_address_2,
                  'ok_payer_city'             =&gt; $order-&gt;billing_city,
                  'ok_payer_state'        =&gt; $order-&gt;billing_state,
                  'ok_payer_zip'      =&gt; $order-&gt;billing_postcode,
                  'ok_payer_country'          =&gt; $order-&gt;billing_country,
                  'ok_payer_email'        =&gt; $order-&gt;billing_email,
                  'ok_payer_phone'        =&gt; $order-&gt;billing_phone,
  
                  // Payment Info
                  'ok_invoice'            =&gt; $order-&gt;order_key."|".$order_id,
                  //'apc_2'               =&gt; $order_id,
                  //'ap_discountamount'   =&gt; $order-&gt;get_order_discount()
          );
  
  
          if ($order-&gt;get_order_discount()&gt;0) :
  
              // Don't pass items - paypal borks tax due to prices including tax. PayPal has no option for tax inclusive pricing sadly. Pass 1 item for the order items overall
              $okpay_args['ok_item_1_name']   = sprintf(__('Order #%s' , 'woothemes'), $order-&gt;id);
              $okpay_args['ok_item_1_quantity']       = 1;
              $okpay_args['ok_item_1_price']      = number_format($order-&gt;order_total - $order-&gt;order_shipping - $order-&gt;get_order_discount(), 2, '.', '');
  
              // Shipping Cost
              if ($order-&gt;order_shipping&gt;0) :
                  $okpay_args['ok_item_2_name'] = __('Shipping cost', 'woothemes');
                  $okpay_args['ok_item_2_quantity']   = 1;
                  $okpay_args['ok_item_2_price']  = number_format($order-&gt;order_shipping, 2);
              endif;
  
          else :
  
              // Tax
              //$okpay_args['ap_taxamount'] = $order-&gt;get_total_tax();
  
              // Cart Contents
              $item_loop = 0;
              if (sizeof($order-&gt;items)&gt;0) : foreach ($order-&gt;items as $item) :
                  if ($item['qty']) :
  
                      $item_loop++;
  
                      $item_name = $item['name'];
  
                      $item_meta = &amp;new order_item_meta( $item['item_meta'] );
                      if ($meta = $item_meta-&gt;display( true, true )) :
                          $item_name .= ' ('.$meta.')';
                      endif;
  
                      $okpay_args['ok_item_'.$item_loop.'_name'] = $item_name;
                      $okpay_args['ok_item_'.$item_loop.'_quantity'] = $item['qty'];
                      $okpay_args['ok_item_'.$item_loop.'_price'] = number_format($item['cost'], 2, '.', '');
  
                  endif;
              endforeach; endif;
  
              // Shipping Cost
              if ($order-&gt;order_shipping&gt;0) :
                  $item_loop++;
                  $okpay_args['ok_item_'.$item_loop.'_name'] = __('Shipping cost', 'woothemes');
                  $okpay_args['ok_item_'.$item_loop.'_quantity'] = '1';
                  $okpay_args['ok_item_'.$item_loop.'_price']  = number_format($order-&gt;order_shipping, 2);
              endif;
  
          endif;
  
          $okpay_args_array = array();
  
          foreach ($okpay_args as $key =&gt; $value) {
              $okpay_args_array[] = '&lt;input type="hidden" name="'.esc_attr( $key ).'" value="'.esc_attr( $value ).'" /&gt;';
          }
  
          $woocommerce-&gt;add_inline_js('
              jQuery("body").block({ 
                      message: "&lt;img src=\"'.esc_url( $woocommerce-&gt;plugin_url() ).'/assets/images/ajax-loader.gif\" alt=\"Redirecting...\" style=\"float:left; margin-right: 10px;\" /&gt;'.__('Thank you for your order. We are now redirecting you to OKPAY to make payment.', 'woothemes').'",
                      overlayCSS: 
                      { 
                          background: "#fff", 
                          opacity: 0.6 
                      },
                      css: { 
                          padding:        20, 
                          textAlign:      "center", 
                          color:          "#555", 
                          border:         "3px solid #aaa", 
                          backgroundColor:"#fff", 
                          cursor:         "wait",
                          lineHeight:     "32px"
                      } 
                  });
              jQuery("#submit_okpay_payment_form").click();
          ');
  
          return '&lt;form action="'.esc_url( $okpay_adr ).'" method="post" id="okpay_payment_form"&gt;
                  ' . implode('', $okpay_args_array) . '
                  &lt;input type="submit" class="button-alt" id="submit_okpay_payment_form" value="'.__('Pay via okpay', 'woothemes').'" /&gt; &lt;a class="button cancel" href="'.esc_url( $order-&gt;get_cancel_order_url() ).'"&gt;'.__('Cancel order &amp;amp; restore cart', 'woothemes').'&lt;/a&gt;
              &lt;/form&gt;';
  
      }
  
      /**
       * Process the payment and return the result
       **/
      function process_payment( $order_id ) {
  
          $order = &amp;new woocommerce_order( $order_id );
  
          return array(
              'result'    =&gt; 'success',
              'redirect'  =&gt; add_query_arg('order', $order-&gt;id, add_query_arg('key', $order-&gt;order_key, get_permalink(get_option('woocommerce_pay_page_id'))))
          );
  
      }
  
      /**
       * receipt_page
       **/
      function receipt_page( $order ) {
  
          echo '&lt;p&gt;'.__('Thank you for your order, please click the button below to pay with okpay.', 'woothemes').'&lt;/p&gt;';
  
          echo $this-&gt;generate_okpay_form( $order );
  
      }
  
      /**
       * Check okpay IPN validity
       **/
      function check_ipn_request_is_valid() {
          global $woocommerce;
  
          if ($this-&gt;debug=='yes') $this-&gt;log-&gt;add( 'okpay', 'Checking IPN response is valid...' );
          return true;
      }
  
      /**
       * Check for okpay IPN Response
       **/
      function check_ipn_response() {
  
          if (isset($_GET['okpayListener']) &amp;&amp; $_GET['okpayListener'] == 'okpay_standard_IPN'):
  
              $_POST = stripslashes_deep($_POST);
  
              if ($this-&gt;check_ipn_request_is_valid()) :
  
                  do_action("valid-okpay-standard-ipn-request", $_POST);
  
              endif;
  
          endif;
  
      }
  
      /**
       * Successful Payment!
       **/
      function successful_request( $posted ) {
          if ($this-&gt;debug=='yes') $this-&gt;log-&gt;add( 'okpay', print_r($posted, true));
  
          $order_info = explode("|", $posted['ok_invoice']);
          $invoice_id = $order_info['0'];
          $order_id = $order_info['1'];
  
  
          if ( !empty($invoice_id) &amp;&amp; !empty($order_id) ) {
  
              $order = new woocommerce_order( (int) $order_id );
              if ($this-&gt;debug=='yes') $this-&gt;log-&gt;add( 'okpay', "Check order key " . $order-&gt;order_key ." = ".$invoice_id);
              if ($order-&gt;order_key!=$invoice_id) exit;
  
              // Sandbox fix
              //if ($posted['ap_test']==1 &amp;&amp; $posted['ok_txn_status']=='Pending') $posted['ok_txn_status'] = 'completed';
  
              // We are here so lets check status and do actions
              if ($this-&gt;debug=='yes') $this-&gt;log-&gt;add( 'okpay', "Check status");
              switch (strtolower($posted['ok_txn_status'])) :
                  case 'completed' :
                      if ($this-&gt;debug=='yes') $this-&gt;log-&gt;add( 'okpay', "Success");
                      // Check order not already completed
                      if ($order-&gt;status == 'completed') exit;
  
                      // Payment completed
                      $order-&gt;add_order_note( __('IPN payment completed', 'woothemes') );
                      $order-&gt;payment_complete();
  
                      // Store PP Details
                      update_post_meta( (int) $order_id, 'Payer okpay address', $posted['ok_payer_email']);
                      update_post_meta( (int) $order_id, 'Transaction ID', $posted['ok_txn_id']);
                      update_post_meta( (int) $order_id, 'Payer first name', $posted['ok_payer_first_name']);
                      update_post_meta( (int) $order_id, 'Payer last name', $posted['ok_payer_last_name']);
                      update_post_meta( (int) $order_id, 'Payment type', $posted['ok_txn_payment_type']);
  
                  break;
                  case 'pending' :
  
                      // Mark order as refunded
                      $order-&gt;update_status('pending', sprintf(__('Payment %s via IPN.', 'woothemes'), strtolower($posted['ok_txn_status']) ) );
  
                      $message = woocommerce_mail_template(
                          __('Order refunded/reversed', 'woothemes'),
                          sprintf(__('Order #%s has been marked as pending - OKPAY reason code: %s', 'woothemes'), $order-&gt;id, $posted['ok_txn_pending_reason'] )
                      );
  
                      // Send the mail
                      woocommerce_mail( get_option('woocommerce_new_order_email_recipient'), sprintf(__('Payment for order #%s pending', 'woothemes'), $order-&gt;id), $message );
  
                  break;
                  case 'reversed' :
  
                      // Mark order as refunded
                      $order-&gt;update_status('refunded', sprintf(__('Payment %s via IPN.', 'woothemes'), strtolower($posted['ok_txn_status']) ) );
  
                      $message = woocommerce_mail_template(
                          __('Order refunded/reversed', 'woothemes'),
                          sprintf(__('Order #%s has been marked as refunded - OKPAY reason code: %s', 'woothemes'), $order-&gt;id, $posted['ok_txn_reversal_reason'] )
                      );
  
                      // Send the mail
                      woocommerce_mail( get_option('woocommerce_new_order_email_recipient'), sprintf(__('Payment for order #%s refunded/reversed', 'woothemes'), $order-&gt;id), $message );
  
                  break;
                  default:
                      // Order failed
                      $order-&gt;update_status('failed', sprintf(__('Payment %s via IPN.', 'woothemes'), strtolower($posted['ok_txn_status']) ) );
                  break;
              endswitch;
  
              exit;
  
          }
  
      }
  
  }
  
  /**
   * Add the gateway to WooCommerce
   **/
  function add_okpay_gateway( $methods ) {
      $methods[] = 'woocommerce_okpay'; return $methods;
  }
  
  add_filter('woocommerce_payment_gateways', 'add_okpay_gateway' );
  </code></pre>