Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2009
    Posts
    1
    Plugin Contributions
    0

    Default Problem with payment Module

    i am creating a payment module for zen cart but for some reason i cant see the payment module on the administration panel after i upload it to the server, i think is something wrong with the code, can somebody take a look at it and help me out thanks! ..


    PHP Code:
    <?php

      
    class paytech {
        var 
    $code$title$description$enabled;


        function 
    https_send($params)
        {

    $test_mode=0;
        
            
    $ch curl_init(); 
            
    curl_setopt($chCURLOPT_URL,"https://www.ezpaycenters.net/swspost.asp"); 

    // Seed cURL connection options
            
    curl_setopt($chCURLOPT_SSL_VERIFYPEER0);
            
    curl_setopt($chCURLOPT_FAILONERROR1); 
            
    curl_setopt($chCURLOPT_FOLLOWLOCATION1); 
            
    curl_setopt($chCURLOPT_TIMEOUT30); 
            
    curl_setopt($chCURLOPT_RETURNTRANSFER,1); 
            
    curl_setopt($chCURLOPT_POST1); 
    // Create iData packet from individual fields...
    $idata=implode(",",$params["iData"]);

    // Compose and send POST message
        
    curl_setopt($chCURLOPT_POSTFIELDS'Company=' $params["ptcompany"] . '&Username=' $params["ptusername"] . '&Password=' $params["password"] . '&iData=' $idata); 
            
    $result=curl_exec ($ch); 
            
    curl_close ($ch); 

            return 
    $result;
        }

    // Sets the class code, description, and status.
        
    function paytech() {
          global 
    $order;
        
          
    $this->code 'paytech';
          
    $this->title PAYTECH;
          
    $this->description MODULE_PAYMENT_PAYTECH_TEXT_DESCRIPTION;
          
    $this->enabled = ((MODULE_PAYMENT_PAYTECH_STATUS == 'True') ? true false);

          if ((int)
    MODULE_PAYMENT_PAYTECH_ORDER_STATUS_ID 0) {
            
    $this->order_status MODULE_PAYMENT_PAYTECH_ORDER_STATUS_ID;
          }

          if (
    is_object($order)) $this->update_status();

        }

    // class methods
        
    function update_status() {
          global 
    $order;

          if ( (
    $this->enabled == true) && ((int)MODULE_PAYMENT_PAYTECH_ZONE 0) ) {
            
    $check_flag false;
            
    $check_query zen_db_query("select zone_id from " TABLE_ZONES_TO_GEO_ZONES " where geo_zone_id = '" MODULE_PAYMENT_PAYTECH_ZONE "' and zone_country_id = '" $order->billing['country']['id'] . "' order by zone_id");
            while (
    $check zen_db_fetch_array($check_query)) {
              if (
    $check['zone_id'] < 1) {
                
    $check_flag true;
                break;
              } elseif (
    $check['zone_id'] == $order->billing['zone_id']) {
                
    $check_flag true;
                break;
              }
            }

            if (
    $check_flag == false) {
              
    $this->enabled false;
            }
          }
        }

    // Check the user input submited on checkout_payment.php with javascript (client-side).
        
    function javascript_validation() {
          
    $js '  if (payment_value == "' $this->code '") {' "\n" .
                
    '    var cc_owner = document.checkout_payment.paytech_cc_owner.value;' "\n" .
                
    '    var cc_number = document.checkout_payment.paytech_cc_number.value;' "\n" .
                
    '    if (cc_owner == "" || cc_owner.length < ' CC_OWNER_MIN_LENGTH ') {' "\n" .
                
    '      error_message = error_message + "' MODULE_PAYMENT_PAYTECH_TEXT_JS_CC_OWNER '";' "\n" .
                
    '      error = 1;' "\n" .
                
    '    }' "\n" .
                
    '    if (cc_number == "" || cc_number.length < ' CC_NUMBER_MIN_LENGTH ') {' "\n" .
                
    '      error_message = error_message + "' "Invalid JS CC Number" '";' "\n" .
                
    '      error = 1;' "\n" .
                
    '    }' "\n" .
                
    '  }' "\n";

          return 
    $js;
        }


        function 
    selection() {
          global 
    $order;

          
    $card_types[] = array('id' => 'VISA' 'text' => 'Visa');
          
    $card_types[] = array('id' => 'MCRD''text' => 'Mastercard');
          
    $card_types[] = array('id' => 'AMEX','text' => 'American Express');
          
    $card_types[] = array('id' => 'DSVR','text' => 'Discover');
          
    $card_types[] = array('id' => 'DINE','text' => 'Diner\'s Club');
          
          for (
    $i=1$i<13$i++) {
            
    $expires_month[] = array('id' => sprintf('%02d'$i), 'text' => strftime('%B',mktime(0,0,0,$i,1,2000)));
          }

          
    $today getdate(); 
          for (
    $i=$today['year']; $i $today['year']+10$i++) {
            
    $expires_year[] = array('id' => strftime('%y',mktime(0,0,0,1,1,$i)), 'text' => strftime('%Y',mktime(0,0,0,1,1,$i)));
          }
          
    $selection = array('id' => $this->code,
                             
    'module' => $this->title,
                             
    'fields' => array(array('title' => "Credit Card Owner",
                                                     
    'field' => zen_draw_input_field('paytech_cc_owner'$order->billing['firstname'] . ' ' $order->billing['lastname'])),
                                               array(
    'title' => "Credit Card Number",
                                                     
    'field' => zen_draw_input_field('paytech_cc_number')),
                                               array(
    'title' => "Credit Card Type",
                                                     
    'field' => zen_draw_pull_down_menu('paytech_cc_type'$card_types)),
                                               array(
    'title' => "Credit Card CVV",
                                                     
    'field' => zen_draw_input_field('paytech_cc_number_cvv','','size="4" maxlength="4"')),
                                               array(
    'title' => "Credit Card Expires",
                                                     
    'field' => zen_draw_pull_down_menu('paytech_cc_expires_month'$expires_month) . '&nbsp;' zen_draw_pull_down_menu('paytech_cc_expires_year'$expires_year))));

          return 
    $selection;
        }


        function 
    pre_confirmation_check() {
          global 
    $HTTP_POST_VARS;

          include(
    DIR_WS_CLASSES 'cc_validation.php');

          
    $cc_validation = new cc_validation();
          
    $result $cc_validation->validate($HTTP_POST_VARS['paytech_cc_number'], $HTTP_POST_VARS['paytech_cc_expires_month'], $HTTP_POST_VARS['paytech_cc_expires_year']);
          
    $error '';
          switch (
    $result) {
            case -
    1:
              
    $error sprintf(UNKNOWN_CARDsubstr($cc_validation->cc_number04));
              break;
            case -
    2:
            case -
    3:
            case -
    4:
              
    $error "Invalid Date";
              break;
            case 
    false:
              
    $error "Invalid Number";
              break;
          }

          if ( (
    $result == false) || ($result 1) ) {
            
    $payment_error_return 'payment_error=' $this->code '&error=' urlencode($error) . '&paytech_cc_owner=' urlencode($HTTP_POST_VARS['paytech_cc_owner']) . '&paytech_cc_expires_month=' $HTTP_POST_VARS['paytech_cc_expires_month'] . '&paytech_cc_expires_year=' $HTTP_POST_VARS['paytech_cc_expires_year'];

            
    zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT$payment_error_return'SSL'truefalse));
          }

          
    $this->cc_card_type $cc_validation->cc_type;
          
    $this->cc_card_number $cc_validation->cc_number;
          
    $this->cc_expiry_month $cc_validation->cc_expiry_month;
          
    $this->cc_expiry_year $cc_validation->cc_expiry_year;
          
    $this->cc_card_number_cvv $HTTP_POST_VARS['paytech_cc_number_cvv'];
          
    $this->cc_card_type $HTTP_POST_VARS['paytech_cc_type'];
        }

        function 
    confirmation() {
          global 
    $HTTP_POST_VARS;

          
    $confirmation = array('title' => $this->title ': ' $this->cc_card_type,
                                
    'fields' => array(array('title' => "Credit Card Owner",
                                                        
    'field' => $HTTP_POST_VARS['paytech_cc_owner']),
                                                  array(
    'title' => "Credit Card CVV",
                                                        
    'field' => $HTTP_POST_VARS['paytech_cc_number_cvv']),
                                                  array(
    'title' => "Credit Card Type",
                                                        
    'field' => $HTTP_POST_VARS['paytech_cc_type']),
                                                  array(
    'title' => "Credit Card Number",
                                                        
    'field' => substr($this->cc_card_number04) . str_repeat('X', (strlen($this->cc_card_number) - 8)) . substr($this->cc_card_number, -4)),
                                                  array(
    'title' => "Credit Card Expires",
                                                        
    'field' => strftime('%B, %Y'mktime(0,0,0,$HTTP_POST_VARS['paytech_cc_expires_month'], 1'20' $HTTP_POST_VARS['paytech_cc_expires_year'])))));

          return 
    $confirmation;
        }


        function 
    process_button() {
          global 
    $HTTP_SERVER_VARS$order$customer_id;

          
    $process_button_string zen_draw_hidden_field('cc'$this->cc_card_number) .
                                   
    zen_draw_hidden_field('exp'$this->cc_expiry_month "/" substr($this->cc_expiry_year, -4)) .
                                   
    zen_draw_hidden_field('cvv'$this->cc_card_number_cvv) .
                                   
    zen_draw_hidden_field('media'$this->cc_card_type) .
                                   
    zen_draw_hidden_field('amount',  sprintf("%0.2f"$order->info['total'])) .
                                   
    zen_draw_hidden_field('name'$order->customer['firstname'] . ' ' $order->customer['lastname']) .
                                   
    zen_draw_hidden_field('address1'$order->customer['street_address']) .
                                   
    zen_draw_hidden_field('city'$order->customer['city']) .
                                   
    zen_draw_hidden_field('state'$order->customer['state']) .
                                   
    zen_draw_hidden_field('zip'$order->customer['postcode']) .
                                   
    zen_draw_hidden_field('country'$order->customer['country']['title']) .
                                   
    zen_draw_hidden_field('phone'$order->customer['telephone']) .
                                   
    zen_draw_hidden_field('email'$order->customer['email_address']) .
                                   
    zen_draw_hidden_field('shipto_name'$order->delivery['firstname'] . ' ' $order->delivery['lastname']) .
                                   
    zen_draw_hidden_field('shipto_address1'$order->delivery['street_address']) .
                                   
    zen_draw_hidden_field('shipto_city'$order->delivery['city']) .
                                   
    zen_draw_hidden_field('shipto_state'$order->delivery['state']) .
                                   
    zen_draw_hidden_field('shipto_zip'$order->delivery['postcode']) .
                                   
    zen_draw_hidden_field('shipto_country'$order->delivery['country']['title']);

          
    $process_button_string .= zen_draw_hidden_field(zen_session_name(), zen_session_id());
          return 
    $process_button_string;
        }


    // !Functions to execute before processing the order
        
    function before_process() {
          global 
    $HTTP_POST_VARS;

          
    $params['ptcompany']= MODULE_PAYMENT_PAYTECH_COMPANY;
          
    $params['ptusername'] = MODULE_PAYMENT_PAYTECH_CUSTID;
          
    $params['password'] = MODULE_PAYMENT_PAYTECH_PASSWORD;
          
    $params['cc'] = $HTTP_POST_VARS['cc'];
          
    $params['exp'] = $HTTP_POST_VARS['exp'];
          
    $params['cvv'] = $HTTP_POST_VARS['cvv'];
          
    $params['media'] = $HTTP_POST_VARS['media'];
          
    $params['amount'] = $HTTP_POST_VARS['amount'];
          
    $params['action'] = MODULE_PAYMENT_PAYTECH_ACTION;
          
    $params['name'] = $HTTP_POST_VARS['name'];
          
    $params['address1'] = $HTTP_POST_VARS['address1'];
          
    $params['city'] = $HTTP_POST_VARS['city'];
          
    $params['state'] = zen_db_fetch_array(zen_db_query("select zone_code from " TABLE_ZONES " where zone_name = '" $HTTP_POST_VARS['state'] . "'"));
          
    $params['state'] = $params['state']['zone_code'];
          
    $params['zip'] = $HTTP_POST_VARS['zip'];
          
    $params['phone'] = $HTTP_POST_VARS['phone'];
          
    $params['avs'] = ((MODULE_PAYMENT_PAYTECH_AVS == 'True') ? 'y' 'n');

          
    $params['ptcompany'] = urlencode($params['ptcompany']);
          
    $params['ptusername'] = urlencode($params['ptusername']);
          
    $params['password'] = urlencode($params['password']);

          
    $params['iData'][0] = "CC";
          
    $params['iData'][1] = urlencode($params['media']);
          
    $params['iData'][2] = urlencode($params['cc']);
          
    $params['iData'][3] = urlencode($params['exp']);
          
    $params['iData'][4] = urlencode($params['amount']);
          
    $params['iData'][5] = "N";
          
    $params['iData'][6] = urlencode($params['cvv']);
          
    $params['iData'][7] = "";
          
    $params['iData'][8] = urlencode($params['name']);
          
    $params['iData'][9] = urlencode($params['address1']);
          
    $params['iData'][10] = urlencode($params['city']);
          
    $params['iData'][11] = urlencode($params['state']);
          
    $params['iData'][12] = urlencode($params['zip']);
          
    $params['iData'][13] = urlencode($params['phone']);
          
    $params['iData'][14] = "";
          
    $params['iData'][15] = "";
          
    $params['iData'][16] = "Credit";
          
    $params['iData'][17] = "";
          
    $params['iData'][18] = "1";
          
    $params['iData'][19] = "3";
          
    $params['iData'][20] = "";
          
          
    $params['avs'] = urlencode($params['avs']);

          
    // remove params with empty values
          
    foreach ($params as $key => $value) {
            if (!
    $value) {
              unset(
    $params[$key]);
            }
          }

          
    // transmit credit card parameters to PAYtech via HTTPS Post
          
    $result $this->https_send($params);

          
    // Expand response from gateway
          
    $response_full=explode("\r\n",$result);
          if(
    $response_full[0]=="0000"){
        if(
    sizeof($response_full)==3){
            
    $oData=explode(",",$response_full[2]);
            
    $approved=($oData[2]==1)?1:0;
        } else {
            
    $approved=0;
        }
          } else {
        
    $approved=0;
          }
          
          if(
    $approved == 0){
              
    zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT'error_message=' urlencode("DECLINE"), 'SSL'truefalse));
          }
       
             
          
    $result $approved?"status=approved":"status=decline";
          return 
    $result;
           }

        function 
    after_process() {
          return 
    false;
        }

        function 
    get_error() {
          global 
    $HTTP_GET_VARS;

          
    $error = array('title' => "ERROR",
                         
    'error' => stripslashes(urldecode($HTTP_GET_VARS['error'])));

          return 
    $error;
        }

    // Admin mod section ---

        
    function check() {
          if (!isset(
    $this->check)) {
            
    $check_query zen_db_query("select configuration_value from " TABLE_CONFIGURATION " where configuration_key = 'MODULE_PAYMENT_PAYTECH_STATUS'");
            
    $this->check zen_db_num_rows($check_query);
          }
          return 
    $this->check;
        }

        function 
    install() {
          
    zen_db_query("insert into " TABLE_CONFIGURATION " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Allow PAYtech', 'MODULE_PAYMENT_PAYTECH_STATUS', 'True', 'Do you want to accept PAYtech payments?', '6', '0', 'zen_cfg_select_option(array(\'True\', \'False\'), ', now())");
          
    zen_db_query("insert into " TABLE_CONFIGURATION " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('PAYtech Company', 'MODULE_PAYMENT_PAYTECH_COMPANY', '', 'Company used for PAYtech payments', '6', '0', now())");
          
    zen_db_query("insert into " TABLE_CONFIGURATION " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('PAYtech Username', 'MODULE_PAYMENT_PAYTECH_CUSTID', '', 'Username used for PAYtech payments', '6', '0', now())");
          
    zen_db_query("insert into " TABLE_CONFIGURATION " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('PAYtech Password', 'MODULE_PAYMENT_PAYTECH_PASSWORD', '', 'Password used for PAYtech payments', '6', '0', now())");
        }

        function 
    remove() {
          
    zen_db_query("delete from " TABLE_CONFIGURATION " where configuration_key in ('" implode("', '"$this->keys()) . "')");
        }

        function 
    keys() {
          return array(
    'MODULE_PAYMENT_PAYTECH_STATUS''MODULE_PAYMENT_PAYTECH_COMPANY''MODULE_PAYMENT_PAYTECH_CUSTID''MODULE_PAYMENT_PAYTECH_PASSWORD');
        }
      }
    ?>

  2. #2
    Join Date
    Jun 2009
    Location
    Europe
    Posts
    58
    Plugin Contributions
    1

    Default Re: Problem with payment Module

    Problem is probably in the admin mode section, i suggest to remove the configuration parameters one by one to pinpoint where the problem comes from, also maybe empty the check function too to see if the error comes from there. Maybe not that important but why all the sort order parameters are the same?

 

 

Similar Threads

  1. v150 Problem with 4b payment module
    By torvista in forum Addon Payment Modules
    Replies: 7
    Last Post: 15 Jan 2012, 02:24 PM
  2. Problem with Payment Module
    By artistwantab in forum Built-in Shipping and Payment Modules
    Replies: 1
    Last Post: 16 Nov 2008, 05:04 AM
  3. CC Payment Module - Problem with cc.php ?
    By bdekraker in forum Built-in Shipping and Payment Modules
    Replies: 3
    Last Post: 15 Dec 2007, 04:49 PM
  4. Problem with Sage Payment module.
    By kedar_purohit in forum Built-in Shipping and Payment Modules
    Replies: 0
    Last Post: 10 Aug 2007, 04:30 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