Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2011
    Posts
    57
    Plugin Contributions
    0

    Default Moving payment fields from page 2 to page 3

    Hello, I recently hired a dev to make a payment module for the Green Money E-Check gateway. The module works great, however the fields are presented on Page 2 during the check-out process, and for aesthetics sake I would like to move these to Page 3. How would I go about changing the plugin to do this? Since we do not have a Green Money public plugin, I would also be more than happy to submit the finished module to the repository.

    includes/modules/payment/greenmoney.php

    Code:
    <?php
    
    require_once(__DIR__.'/greenmoney/lib/Green.php');
    
    
    class greenmoney extends base {
      
      var $code;
      var $moduleVersion = '1.02';
    
      var $title;
    
      var $description;
    
      var $enabled;
    
      protected $reportable_submit_data;
      var $transaction_id;
      var $order_nstatus; 
    
    
      /**
       * Constructor
       */
      function __construct() {
        global $order;
    
        $this->code = 'greenmoney';
    
        $this->title = MODULE_PAYMENT_GREENMONEY_TEXT_CATALOG_TITLE; 
        if (IS_ADMIN_FLAG === true) {
          $this->description = MODULE_PAYMENT_GREENMONEY_TEXT_DESCRIPTION;
          $this->title = MODULE_PAYMENT_GREENMONEY_TEXT_ADMIN_TITLE; 
        }
    
        $this->enabled = (defined('MODULE_PAYMENT_GREENMONEY_STATUS') && MODULE_PAYMENT_GREENMONEY_STATUS == 'True');
        $this->sort_order = defined('MODULE_PAYMENT_GREENMONEY_SORT_ORDER') ? MODULE_PAYMENT_GREENMONEY_SORT_ORDER : null;
    
    	
        if (null === $this->sort_order) return false;
    
        if (MODULE_PAYMENT_GREENMONEY_STATUS == 'True' && (MODULE_PAYMENT_GREENMONEY_APIPW == '')) {
          $this->title .=  '<span class="alert"> (Not Configured)</span>';
        } elseif (MODULE_PAYMENT_GREENMONEY_TESTMODE == 'Test') {
          $this->title .= '<span class="alert"> (in Testing mode)</span>';
        } 
    
            
        $this->gateway_currency = MODULE_PAYMENT_GREENMONEY_CURRENCY;
    
    
        if (defined('MODULE_PAYMENT_GREENMONEY_ORDER_STATUS_ID') && (int)MODULE_PAYMENT_GREENMONEY_ORDER_STATUS_ID > 0) {
          $this->order_status = MODULE_PAYMENT_GREENMONEY_ORDER_STATUS_ID;
        }
    
        
    
        if (is_object($order)) $this->update_status();
    
        
      }
    
     
      function update_status() {
        global $order, $db;
    
        if ($this->enabled && (int)MODULE_PAYMENT_GREENMONEY_ZONE > 0 && isset($order->billing['country']['id'])) {
          $check_flag = false;
          $check = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_PAYMENT_GREENMONEY_ZONE . "' and zone_country_id = '" . (int)$order->billing['country']['id'] . "' order by zone_id");
          while (!$check->EOF) {
            if ($check->fields['zone_id'] < 1) {
              $check_flag = true;
              break;
            } elseif ($check->fields['zone_id'] == $order->billing['zone_id']) {
              $check_flag = true;
              break;
            }
            $check->MoveNext();
          }
    
          if ($check_flag == false) {
            $this->enabled = false;
          }
        }
    
        // other status checks?
        if ($this->enabled) {
          // other checks here
        }
      }
    	
    
      function javascript_validation() {
    	  $js = '  if (payment_value == "' . $this->code . '") {' . "\n" .
              '    var routing_number = document.checkout_payment.greenmoney_routing_number.value;' . "\n" .
              '    var account_number = document.checkout_payment.greenmoney_account_number.value;' . "\n";
    	  
     	$js .= '    if (routing_number == "" || routing_number.length < 9) {' . "\n" .
              '      error_message = error_message + "' . MODULE_PAYMENT_GREENMONEY_TEXT_JS_RO_NO . '";' . "\n" .
              '      error = 1;' . "\n" .
              '    }' . "\n" .
              '    if (account_number == "" || account_number < 8) {' . "\n" .
              '      error_message = error_message + "' . MODULE_PAYMENT_GREENMONEY_TEXT_JS_ACC_NO . '";' . "\n" .
              '      error = 1;' . "\n" .
              '    }' . "\n";	 
         $js .= '  }' . "\n";	  
        return $js;
      }
      
      function selection() {
    	  
    	  $onFocus = ' onfocus="methodSelect(\'pmt-' . $this->code . '\')"';
    	  
          return array('id' => $this->code,
                       'module' => $this->title,
    				   'fields' => array(array('title' => MODULE_PAYMENT_GREENMONEY_TEXT_ROUTING_NO,
                                                     'field' => zen_draw_input_field('greenmoney_routing_number', '', 'id="'.$this->code.'-routing-number"' . $onFocus . ' autocomplete="off"'),
                                                     'tag' => $this->code.'-routing-number'),
                                             array('title' => MODULE_PAYMENT_GREENMONEY_TEXT_ACCOUNT_NO,
                                                   'field' => zen_draw_input_field('greenmoney_account_number', '', 'id="'.$this->code.'-account-number"' . $onFocus . ' autocomplete="off"'),
                                                   'tag' => $this->code.'-account-number'),
                                             ));
      }
      
    	
      function pre_confirmation_check() {    
        return true;
      }
      
    	
      function confirmation() {	
        return array();
      }
    	
      
    
       
      function process_button() {        
       $process_button_string = zen_draw_hidden_field('greenmoney_routing_number', $_POST['greenmoney_routing_number']) .                             
                                 zen_draw_hidden_field('greenmoney_account_number', $_POST['greenmoney_account_number']) ;
                                 
        
        $process_button_string .= zen_draw_hidden_field(zen_session_name(), zen_session_id());
    
        return $process_button_string;
      }
      /**
       * Store the CC info to the order and process any results that come back from the payment gateway
       *
       */
      function before_process() {
    	  global $response, $db, $order, $messageStack;
    	  $routing_number  = $_POST['greenmoney_routing_number'];
    	  $account_number  = $_POST['greenmoney_account_number'];	
    	  
    	  $last_order_id = $db->Execute("select orders_id from " . TABLE_ORDERS . " order by orders_id desc limit 1");
       	  $new_order_id = $last_order_id->fields['orders_id'];
          $new_order_id = ($new_order_id + 1);
    	  
    	  
    	  $gateway = new CheckGateway(MODULE_PAYMENT_GREENMONEY_CLIENTID, MODULE_PAYMENT_GREENMONEY_APIPW); 
    	  
    	  $name = $order->billing['firstname']. ' '. $order->billing['lastname'];
    	  $email = $order->customer['email_address'];
    	  $phone = $order->customer['telephone'];
    	  $phone_ext = '';
    	  $address1 = $order->billing['street_address'];
    	  $address2 = '';
    	  $city = $order->billing['city'];	  
    	  $zip = $order->billing['postcode'];
    	  $country = $order->billing['country']['iso_code_2'];
    	  $routing = $routing_number;
    	  $account = $account_number;
    	  $bank_name = '';
    	  $memo = 'Order No : '.$new_order_id;
    	  $amount = round($order->info['total'], 2);
    	  $date = date("m/d/Y");
    	  $state = zen_get_zone_code($order->billing['country']['id'], $order->billing['zone_id']);
    	  
    	  $result = $gateway->singleCheck($name, $email, $phone, $phone_ext, $address1, $address2, $city, $state, $zip, $country, $routing, $account, $bank_name, $memo, 	$amount, $date);
    	  if($result) {
    		  if($result['Result'] == '0'){
    		  }
    		  else {
    			  	$messageStack->add_session('checkout_payment', 'Payment Fail - '.$result['ResultDescription'], 'error');
          			zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL', true, false));			  
    		  }
    	  }
    	  else {
    		  $messageStack->add_session('checkout_payment', 'Payment Fail - '.$gateway->getLastError(), 'error');
          			zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL', true, false));			  
    	  }  
      }
    
      
      function after_process() {	
        return false;
      }
      /**
       * Check to see whether module is installed
       *
       * @return boolean
       */
      function check() {
        global $db;
        // install newer switches, if relevant
        
        if (!isset($this->_check)) {
          $check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_PAYMENT_GREENMONEY_STATUS'");
          $this->_check = $check_query->RecordCount();
        }
        return $this->_check;
      }
      /**
       * Install the payment module and its configuration settings
       *
       */
      function install() {
        global $db, $messageStack;
        if (defined('MODULE_PAYMENT_GREENMONEY_STATUS')) {
          $messageStack->add_session('GreenMoney Payment Pages module already installed.', 'error');
          zen_redirect(zen_href_link(FILENAME_MODULES, 'set=payment&module=firstdata'));
          return 'failed';
        }
    	  
        $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable GreenMoney Payment Module', 'MODULE_PAYMENT_GREENMONEY_STATUS', 'True', 'Do you want to accept  payments via GreenMoney?', '6', '0', 'zen_cfg_select_option(array(\'True\', \'False\'), ', now())");
    	  
        $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort order of display.', 'MODULE_PAYMENT_GREENMONEY_SORT_ORDER', '0', 'Sort order of displaying payment options to the customer. Lowest is displayed first.', '6', '0', now())");
    	  
        $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, use_function, date_added) values ('Set Order Status', 'MODULE_PAYMENT_GREENMONEY_ORDER_STATUS_ID', '1', 'Set the status of new orders ', '6', '0', 'zen_cfg_pull_down_order_statuses(', 'zen_get_order_status_name', now())");	  
        
    	  	  
        $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Payment Zone', 'MODULE_PAYMENT_GREENMONEY_ZONE', '0', 'If a zone is selected, only enable this payment method for that zone.', '6', '2', 'zen_get_zone_class_title', 'zen_cfg_pull_down_zone_classes(', now())");
    	  
        $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, use_function) values ('Client ID', 'MODULE_PAYMENT_GREENMONEY_CLIENTID', '', 'Client ID assigned in your GreenMoney', '6', '0', now(), 'zen_cfg_password_display')");
    	  
        $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, use_function) values ('API Password', 'MODULE_PAYMENT_GREENMONEY_APIPW', '', 'API Password in your GreenMoney', '6', '0', now(), 'zen_cfg_password_display')");	
    	
       	
      }
    	
      /**
       * Remove the module and all its settings
       *
       */
      function remove() {
        global $db;
        $db->Execute("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
      }
    	
      /**
       * Internal list of configuration keys used for configuration of the module
       *
       * @return array
       */
      function keys() {
        return array('MODULE_PAYMENT_GREENMONEY_STATUS',
                'MODULE_PAYMENT_GREENMONEY_SORT_ORDER',
                'MODULE_PAYMENT_GREENMONEY_ORDER_STATUS_ID',		    
                'MODULE_PAYMENT_GREENMONEY_ZONE',
                'MODULE_PAYMENT_GREENMONEY_CLIENTID',
                'MODULE_PAYMENT_GREENMONEY_APIPW'
                );
      }
    
    }


    includes/languages/english/modules/payment/greenmoney.php and includes/modules/payment/greenmoney/lib/Green.php are also included in the plugin, but I do not think either of these are responsible for the payment field location. I will upload these as well if requested for clarity.

  2. #2
    Join Date
    Jul 2012
    Posts
    15,096
    Plugin Contributions
    17

    Default Re: Moving payment fields from page 2 to page 3

    In a standard Zen Cart install, payment information is typically retrieved either on page 2 (checkout_payment) or initially selected in that page with specific payment information collected either just before checkout_confirmation or just after... there are other modules available that combine more of the information in a single page or at least fewer pages. Generally speaking one of those other modules would be used to accomplish what is desired. Otherwise, the code may need to be rewritten/moved around to support the collection of payment information later in the process. There may also be some other issues to overcome as a result of the movement, but that's without digging deeper into operations.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...
    Upgraded to Zen Cart V1.5.3 from V1.5.1 from V1.5.0 from V1.3.9h

  3. #3
    Join Date
    Feb 2006
    Location
    Tampa Bay, Florida
    Posts
    7,164
    Plugin Contributions
    269

    Default Re: Moving payment fields from page 2 to page 3

    If you want to change the look of your checkout, you might consider the One Page Checkout mod.
    https://www.zen-cart.com/downloads.php?do=file&id=2095

    Anything else will be an endless exercise in troubleshooting and debugging, and will make upgrades a nightmare.
    It's up to you (of course), but I would discourage making a change like the one you suggested.
    That Software Guy. My Store: Zen Cart Modifications
    Available for hire - See my ad in Services
    Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.

  4. #4
    Join Date
    Jan 2004
    Location
    N of San Antonio TX
    Posts
    7,500
    Plugin Contributions
    8

    Default Re: Moving payment fields from page 2 to page 3

    The big IF would be if the dev built the payment mod with the ZC standards in mind. Any deviations from the norm might render OPC at least needing many edits and, at worst, not working with the item at all.

    Caution and testing non-live advised, of course.
    Did you read the posting tips?!?
    Responsive Color Changes for 155-156c demo here.
    Zen Cart PCI Compatible Hosting

 

 

Similar Threads

  1. v150 Add more fields to payment page?
    By tillsey in forum Customization from the Admin
    Replies: 2
    Last Post: 15 Mar 2012, 04:24 PM
  2. removing unwanted fields from payment page
    By lisakoza in forum Built-in Shipping and Payment Modules
    Replies: 0
    Last Post: 26 Dec 2009, 04:49 PM
  3. Two credit card payment options fields on the payment page??
    By linda408 in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 27 Sep 2009, 11:56 PM
  4. remove address fields from payment information page?
    By spinalfrog in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 7 Oct 2008, 07:16 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR