Page 4 of 7 FirstFirst ... 23456 ... LastLast
Results 31 to 40 of 64
  1. #31
    Join Date
    Jul 2008
    Posts
    360
    Plugin Contributions
    0

    Default Re: Create a new module for International Checkout payment module

    Quote Originally Posted by DrByte View Post
    Well, if you're not *on* the shopping cart page when you're running your particular code, then that whole array won't even be available to you, so you won't be able to use the variables at all.

    But, assuming you were on that page, if you think about it, the foreach is used to render each line in the shopping cart. So, unless you're already doing something as part of looping thru the array within the template, you'll have to loop thru it again if you want it to handle *all* products in the cart.
    Yes, I thought so, I have to loop through all the products ...

    Thanks for the tips ...

    I just made this function within the Class

    PHP Code:
    function process_button() {
          global 
    $HTTP_SERVER_VARS$product$customer_id;

    foreach (
    $productArray as $product) {
        
          
    $process_button_string zen_draw_hidden_field('ItemQuantity',$product['quantityField'] . 
                                   
    zen_draw_hidden_field('ItemImage'$product['productsImage']) . 
                                   
    zen_draw_hidden_field('ItemDescription'$product['productsName']) . 
                                   
    zen_draw_hidden_field('ItemPrice'$product['productsPrice']);

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

    Hope it works
    Last edited by icecold; 16 Mar 2010 at 09:40 PM.

  2. #32
    Join Date
    Jan 2004
    Posts
    66,446
    Plugin Contributions
    81

    Default Re: Create a new module for International Checkout payment module

    I don't know why you're referencing $HTTP_SERVER_VARS, both because you're not using them in that function, and also because they're obsolete in PHP 5.3, replaced by $_SERVER instead. But, since you're not using it, you don't need it listed. Also, you're not using $customer_id, so don't need that either.
    Also, since $productArray is never set inside that function, you'll just get a blank string for your output ... actually likely a null string since the variable never gets set.
    I've no idea why you're doing this with process_button() ... I guess you're using that to send the data someplace along with the customer, instead of doing it all via CURL as discussed before.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  3. #33
    Join Date
    Jul 2008
    Posts
    360
    Plugin Contributions
    0

    Default Re: Create a new module for International Checkout payment module

    Quote Originally Posted by DrByte View Post
    I don't know why you're referencing $HTTP_SERVER_VARS, both because you're not using them in that function, and also because they're obsolete in PHP 5.3, replaced by $_SERVER instead. But, since you're not using it, you don't need it listed. Also, you're not using $customer_id, so don't need that either.
    Also, since $productArray is never set inside that function, you'll just get a blank string for your output ... actually likely a null string since the variable never gets set.
    I've no idea why you're doing this with process_button() ... I guess you're using that to send the data someplace along with the customer, instead of doing it all via CURL as discussed before.
    I will do, and I am not really familiar with PHP5 syntax so thanks for the tip ...

    I am really trying to understand the logic behind the payment module Class, so I am just experimenting and testing different approaches.

    Most of my functions are return false; since the only thing I need to do is to pass the info ...

    Process_button uses $HTTP_SERVER because to pass the data to curl_setopt($ch, CURLOPT_POSTFIELDS, I pass a string of characters gathered in process_button(), and then
    concatened in the next function, what it does is to assign each value to an element of the array ...

    Here is my curl connection:
    PHP Code:
    class ic {
        var 
    $code$title$description$enabled;


        function 
    https_send($params)
        {

    $test_mode=0;
        
            
    $ch curl_init(); 
            
    curl_setopt($chCURLOPT_URL,"https://www.internationalcheckout.com/cart.php"); 

    // 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["iccompany"] . '&iData=' $idata); 
            
    $result=curl_exec ($ch); 
            
    curl_close ($ch); 

            return 
    $result
    and below are the 2 functions that collect data to be transmitted by POSTFIELDS:

    PHP Code:
    //Prepare the data from the cart to be transmited using curl

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

    foreach (
    $productArray as $product) {
        
          
    $process_button_string zen_draw_hidden_field('ItemQuantity',$product['quantityField'] . 
                                   
    zen_draw_hidden_field('ItemImage'$product['productsImage']) . 
                                   
    zen_draw_hidden_field('ItemDescription'$product['productsName']) . 
                                   
    zen_draw_hidden_field('ItemPrice'$product['productsPrice']);

          
    $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['iccompany']= MODULE_PAYMENT_IC_COMPANY;
          
    $params['ItemQuantity'] = $HTTP_POST_VARS['ItemQuantity'];
          
    $params['ItemImage'] = $HTTP_POST_VARS['ItemImage'];
          
    $params['ItemDescription'] = $HTTP_POST_VARS['ItemDescription'];
          
    $params['ItemPrice'] = $HTTP_POST_VARS['ItemPrice'];
          
          
    $params['iccompany'] = urlencode($params['iccompany']);
          
          
    $params['iData'][0] = urlencode($params['ItemQuantity']);
          
    $params['iData'][1] = urlencode($params['ItemImage']);  
          
    $params['iData'][2] = urlencode($params['ItemDescription']);
          
    $params['iData'][3] = urlencode($params['ItemPrice']); 
          
          
             
    // remove params with empty values
          
    foreach ($params as $key => $value) {
            if (!
    $value) {
              unset(
    $params[$key]);
            }
          } 
    What I'm trying to figure out is if how can made another loop in before_process() so it gathers all the values from process_button.

    I will make the change to $_SERVER, as you suggested, but if the array $products, gets it's content in the shopping cart, why will it pass empty fields to my class? Do I need to do another db query so ProductsArray[] has data again?

  4. #34
    Join Date
    Jan 2004
    Posts
    66,446
    Plugin Contributions
    81

    Default Re: Create a new module for International Checkout payment module

    Quote Originally Posted by icecold View Post
    I will make the change to $_SERVER, as you suggested
    You don't need it, because you're not using it ... at least, not in that function.
    Quote Originally Posted by icecold View Post
    but if the array $products, gets it's content in the shopping cart, why will it pass empty fields to my class?
    First, because payment modules are not activated on the shopping cart page, there's no way the $productsArray will have any data in it anyway.
    Second, every function starts clean, and knows nothing about any other variables outside itself. That's just how PHP has always worked. Each function is its own scope. The only way to get around that is to pass parameters to it or to global certain variables, and using global is an older convention only applicable to procedural code, whereas PHP is headed towards object-oriented code instead.
    Quote Originally Posted by icecold View Post
    Do I need to do another db query so ProductsArray[] has data again?
    Yes, as I said, unless you're ON the shopping cart page when the payment module is instantiated and called, none of the shopping cart data is available to you anyway.
    If you want to mimic similar behavior you'll have to copy and duplicate the code to do that.

    You're not merely writing another payment module here. It's more like you're re-architecting a whole new checkout.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  5. #35
    Join Date
    Jul 2008
    Posts
    360
    Plugin Contributions
    0

    Default Re: Create a new module for International Checkout payment module

    Quote Originally Posted by DrByte View Post
    You don't need it, because you're not using it ... at least, not in that function.
    First, because payment modules are not activated on the shopping cart page, there's no way the $productsArray will have any data in it anyway.
    I thought because we were in the same session some vars might had content ... (that was just in theory).


    Quote Originally Posted by DrByte View Post
    Second, every function starts clean, and knows nothing about any other variables outside itself. That's just how PHP has always worked. Each function is its own scope. The only way to get around that is to pass parameters to it or to global certain variables, and using global is an older convention only applicable to procedural code, whereas PHP is headed towards object-oriented code instead.Yes, as I said, unless you're ON the shopping cart page when the payment module is instantiated and called, none of the shopping cart data is available to you anyway.
    If you want to mimic similar behavior you'll have to copy and duplicate the code to do that.
    ok, so the cart data is stored in tables? So I can query them and retrieve it? ...

    Quote Originally Posted by DrByte View Post

    You're not merely writing another payment module here. It's more like you're re-architecting a whole new checkout.

    Yes, more like it, as this system overrides all the functions and takes only raw data from the cart. So in PHP OOP there is no way to 'store' an array and reuse its contents, not even in a SESSION(I am really not familiar with PHP OOP)?

  6. #36
    Join Date
    Jan 2004
    Posts
    66,446
    Plugin Contributions
    81

    Default Re: Create a new module for International Checkout payment module

    Quote Originally Posted by icecold View Post
    So in PHP OOP there is no way to 'store' an array and reuse its contents, not even in a SESSION(I am really not familiar with PHP OOP)?
    Well, yes there is, but Zen Cart 1.x isn't OOP structured.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  7. #37
    Join Date
    Jul 2008
    Posts
    360
    Plugin Contributions
    0

    Default Re: Create a new module for International Checkout payment module

    Quote Originally Posted by DrByte View Post
    Well, yes there is, but Zen Cart 1.x isn't OOP structured.
    ok how about the cart history? I have seen the cart contents get stored there intact, what if I try to retrieve the data from those tables?

    PHP Code:
    for ($i=0$n=sizeof($products); $i<$n$i++) {
      if ((
    $i/2) == floor($i/2)) {

    $productsImage = (IMAGE_SHOPPING_CART_STATUS == zen_image(DIR_WS_IMAGES $products[$i]['image'], $products[$i]['name'], IMAGE_SHOPPING_CART_WIDTHIMAGE_SHOPPING_CART_HEIGHT) : '');
    $quantityField zen_draw_input_field('cart_quantity[]'$products[$i]['quantity'], 'size="4"');
     
    $productsPrice $currencies->display_price($products[$i]['final_price'], zen_get_tax_rate($products[$i]['tax_class_id']), $products[$i]['quantity']) . ($products[$i]['onetime_charges'] != '<br />' $currencies->display_price($products[$i]['onetime_charges'], zen_get_tax_rate($products[$i]['tax_class_id']), 1) : '');
      
    $productsPriceEach $currencies->display_price($products[$i]['final_price'], zen_get_tax_rate($products[$i]['tax_class_id']), 1) . ($products[$i]['onetime_charges'] != '<br />' $currencies->display_price($products[$i]['onetime_charges'], zen_get_tax_rate($products[$i]['tax_class_id']), 1) : '');

    // Create a smaller Array to hold just the data above

      
    $productArray[$i] = array( 'productsImage'=>$productsImage,
                                                
    'productsName'=>$productsName,
                                                
    'quantityField'=>$quantityField,
                                                 
    'productsPrice'=>$productsPrice,
                                      
    'productsPriceEach'=>$productsPriceEach,
                                
    'rowClass'=>$rowClass,
                          
                                
    'id'=>$products[$i]['id']);
    // end FOR loop 
    I borrowed some of the code from header.php my question is will this work, in my class or will it have a conflict problem?

    Just created a new array with the same name and populated it with the same data.

    So later I can use it within my class ...

  8. #38
    Join Date
    Jul 2008
    Posts
    360
    Plugin Contributions
    0

    Default Re: Create a new module for International Checkout payment module

    Quote Originally Posted by icecold View Post
    ok how about the cart history? I have seen the cart contents get stored there intact, what if I try to retrieve the data from those tables?

    PHP Code:
    for ($i=0$n=sizeof($products); $i<$n$i++) {
      if ((
    $i/2) == floor($i/2)) {

    $productsImage = (IMAGE_SHOPPING_CART_STATUS == zen_image(DIR_WS_IMAGES $products[$i]['image'], $products[$i]['name'], IMAGE_SHOPPING_CART_WIDTHIMAGE_SHOPPING_CART_HEIGHT) : '');
    $quantityField zen_draw_input_field('cart_quantity[]'$products[$i]['quantity'], 'size="4"');
     
    $productsPrice $currencies->display_price($products[$i]['final_price'], zen_get_tax_rate($products[$i]['tax_class_id']), $products[$i]['quantity']) . ($products[$i]['onetime_charges'] != '<br />' $currencies->display_price($products[$i]['onetime_charges'], zen_get_tax_rate($products[$i]['tax_class_id']), 1) : '');
      
    $productsPriceEach $currencies->display_price($products[$i]['final_price'], zen_get_tax_rate($products[$i]['tax_class_id']), 1) . ($products[$i]['onetime_charges'] != '<br />' $currencies->display_price($products[$i]['onetime_charges'], zen_get_tax_rate($products[$i]['tax_class_id']), 1) : '');

    // Create a smaller Array to hold just the data above

      
    $productArray[$i] = array( 'productsImage'=>$productsImage,
                                                
    'productsName'=>$productsName,
                                                
    'quantityField'=>$quantityField,
                                                 
    'productsPrice'=>$productsPrice,
                                      
    'productsPriceEach'=>$productsPriceEach,
                                
    'rowClass'=>$rowClass,
                          
                                
    'id'=>$products[$i]['id']);
    // end FOR loop 
    I borrowed some of the code from header.php my question is will this work, in my class or will it have a conflict problem?

    Just created a new array with the same name and populated it with the same data.

    So later I can use it within my class ...
    I think I forgot to add >>>
    $products = $cart->get_products();
    at the top

  9. #39
    Join Date
    Jul 2008
    Posts
    360
    Plugin Contributions
    0

    Default Debugging Testing payment module

    I wanted to know if there are any specific requirements to be met prior to installing and testing a module, as I want to echo some variables, and array contents, but as the data is retrieved from a live cart, in a live session, I wanted to know in advance if that is possible or I have to install this testing module first, to avoid conflicts.

  10. #40
    Join Date
    Jul 2008
    Posts
    360
    Plugin Contributions
    0

    Default Re: Create a new module for International Checkout payment module

    Anything wrong with these code?
    I am getting a not found error in admin/modules.php local server
    But couldn't find why

    Warning: include(C:/server/xampp/htdocs/store/includes/languages/english/modules/payment/ic.php) [function.include]: failed to open stream: No such file or directory in C:\server\xampp\htdocs\store\admin\modules.php on line 173

    Warning: include() [function.include]: Failed opening 'C:/server/xampp/htdocs/store/includes/languages/english/modules/payment/ic.php' for inclusion (include_path='.;C:\server\xampp\php\pear\') in C:\server\xampp\htdocs\store\admin\modules.php on line 173


    PHP Code:

    // Admin mod section ---

      
    function check() {
        global 
    $db;
        if (!isset(
    $this->_check)) {
          
    $check_query $db->Execute("select configuration_value from " TABLE_CONFIGURATION " where configuration_key = 'MODULE_PAYMENT_IC_STATUS'");
          
    $this->_check $check_query->RecordCount();
        }
        return 
    $this->_check;
      }

        function 
    install() {
            global 
    $db;
    /*      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 International Checkout', 'MODULE_PAYMENT_IC_STATUS', 'True', 'Do you want to accept International Checkout 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 ('International Checkout Company', 'MODULE_PAYMENT_IC_COMPANY', '', 'Company used for International Checkout payments', '6', '0', now())");*/
          
    $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 International Checkout Module', 'MODULE_PAYMENT_IC_STATUS', 'True', 'Do you want to accept International Checkout payments?', '6', '130', '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_IC_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '131' , now())");
        
    $db->Execute("insert into " TABLE_CONFIGURATION " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('International Checkout Company ID', 'MODULE_PAYMENT_IC_COMPANY', '', 'Company used for International Checkout payments', '6', '132', now())");
       }

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

        function 
    keys() {
          return array(
    'MODULE_PAYMENT_IC_STATUS''MODULE_PAYMENT_IC_SORT_ORDER''MODULE_PAYMENT_IC_COMPANY');
        }
      } 

 

 
Page 4 of 7 FirstFirst ... 23456 ... LastLast

Similar Threads

  1. How to create new payment module?
    By Macedonium in forum Built-in Shipping and Payment Modules
    Replies: 2
    Last Post: 15 May 2009, 09:47 PM
  2. Create payment module for cc gateway
    By ccppll in forum Built-in Shipping and Payment Modules
    Replies: 7
    Last Post: 22 Apr 2009, 05:00 PM
  3. How to Create a Transaction ID for Payment Module?
    By Diego Vieira in forum Built-in Shipping and Payment Modules
    Replies: 0
    Last Post: 21 Mar 2009, 04:40 PM
  4. How to create new payment module?
    By mscro in forum Built-in Shipping and Payment Modules
    Replies: 9
    Last Post: 28 Apr 2008, 12:23 AM
  5. How do I create a new payment module?
    By meeven in forum Built-in Shipping and Payment Modules
    Replies: 7
    Last Post: 12 Aug 2007, 01:29 PM

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