Page 2 of 7 FirstFirst 1234 ... LastLast
Results 11 to 20 of 64
  1. #11
    Join Date
    Jun 2009
    Location
    Europe
    Posts
    59
    Plugin Contributions
    1

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

    Quote Originally Posted by icecold View Post
    Well I am a computer engineer not the usual non-tech shopper owner ... I was looking into guidelines, I don't have time to study and figure out how all the scripts work, because I have to run my biz, I am not a module developer, I modified several things but it will be good if a good guide was something less complex than 'here is the structure', at least a list of the functions required to run a payment module, that's the open source way, to share and develop by many, and debug so we can build better apps ...

    It's really crazy to have to reverse engineer all payment modules ...
    Well, i am not a computer engineer/programmer but i am a reverse engineer!


    Btw, I am intending to update the Wiki pages
    http://www.zen-cart.com/wiki/index.p...ayment_Classes


  2. #12
    Join Date
    Jul 2008
    Posts
    360
    Plugin Contributions
    0

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

    Quote Originally Posted by zamzom View Post
    Well, i am not a computer engineer/programmer but i am a reverse engineer!


    Btw, I am intending to update the Wiki pages
    http://www.zen-cart.com/wiki/index.p...ayment_Classes

    Great post ZamZom! Please note that post was not intended for you!
    There are many people thinking they will get cash from everything ... and forgot about the basic principles of open source, that is to share and develop together for the greater good.

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

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

    I have been working on the module for a while and I have a few questions regarding the process_button method from paypal.php.

    PHP Code:
     function process_button() {
        global 
    $db$order$currencies$currency;
        
    $options = array();
        
    $optionsCore = array();
        
    $optionsPhone = array();
        
    $optionsShip = array();
        
    $optionsLineItems = array();
        
    $optionsAggregate = array();
        
    $optionsTrans = array();
        
    $buttonArray = array();

        
    $this->totalsum $order->info['total']; 
    From the above I understand these arrays holds the different data, needed to be submitted, but in my case I need only to submit:

    $optionsLineItems as it is the one controlling the ordered products list, my module needs only to submit:

    <input type="hidden" name="ItemStore1" value="theoutletseason">

    <input type="hidden" name="ItemDescription1" value="first item">
    <input type="hidden" name="ItemSKU1" value="product number of first item">
    <input type="hidden" name="ItemSize1" value="size of first item">
    <input type="hidden" name="ItemColor1" value="color of first item">
    <input type="hidden" name="ItemQuantity1" value="quantity of first item">
    <input type="hidden" name="ItemPrice1" value="price of the first">
    <input type="hidden" name="ItemImage1" value="COMPLETE path of their image" />

    So I thought if I modify slightly the code of function ipn_getLineItemDetails() from the paypal_functions.php script, I will be able to get the data I need.

    Correct me If I 'm wrong but I only need a list of the ordered products, not shipping, not tax, nothing like that.

    So my question is can I get rid of many of these $optionsxxx arrays, and still achieve the same functionality?


    PHP Code:
        // save the session stuff permanently in case internationalcheckout loses the session
        
    $_SESSION['ppipn_key_to_remove'] = session_id();
        
    $db->Execute("delete from " TABLE_INTERNATIONALCHECKOUT_SESSION " where session_id = '" zen_db_input($_SESSION['ppipn_key_to_remove']) . "'");

        
    $sql "insert into " TABLE_INTERNATIONALCHECKOUT_SESSION " (session_id, saved_session, expiry) values (
                '" 
    zen_db_input($_SESSION['ppipn_key_to_remove']) . "',
                '" 
    base64_encode(serialize($_SESSION)) . "',
                '" 
    . (time() + (1*60*60*24*2)) . "')"
    Regarding the SESSION Above it is needed by Zen Cart to work or it's just a requirement of Paypal?

    PHP Code:
        $db->Execute($sql);

        
    $my_currency select_pp_currency();
        
    $this->transaction_currency $my_currency;

        
    $this->transaction_amount = ($this->totalsum $currencies->get_value($my_currency)); 
    I keep the above

    and comment out the below code snippet

    PHP Code:
    /* Can I eliminate this section ???

        $telephone = preg_replace('/\D/', '', $order->customer['telephone']);
        if ($telephone != '') {
          $optionsPhone['H_PhoneNumber'] = $telephone;
          if (in_array($order->customer['country']['iso_code_2'], array('US','CA'))) {
            $optionsPhone['night_phone_a'] = substr($telephone,0,3);
            $optionsPhone['night_phone_b'] = substr($telephone,3,3);
            $optionsPhone['night_phone_c'] = substr($telephone,6,4);
            $optionsPhone['day_phone_a'] = substr($telephone,0,3);
            $optionsPhone['day_phone_b'] = substr($telephone,3,3);
            $optionsPhone['day_phone_c'] = substr($telephone,6,4);
        } else {
            $optionsPhone['night_phone_b'] = $telephone;
            $optionsPhone['day_phone_b'] = $telephone;
          }
        }

        $optionsCore = array(
                       'charset' => CHARSET,
                       'lc' => $order->customer['country']['iso_code_2'],
                       'page_style' => MODULE_PAYMENT_INTERNATIONALCHECKOUT_PAGE_STYLE,
                       'custom' => zen_session_name() . '=' . zen_session_id(),
                       'business' => MODULE_PAYMENT_INTERNATIONALCHECKOUT_BUSINESS_ID,
                       'return' => zen_href_link(FILENAME_CHECKOUT_PROCESS, 'referer=internationalcheckout', 'SSL'),
                       'cancel_return' => zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'),
                       'shopping_url' => zen_href_link(FILENAME_SHOPPING_CART, '', 'SSL'),
                       'notify_url' => zen_href_link('ipn_main_handler.php', '', 'SSL',false,false,true),
                       'redirect_cmd' => '_xclick',
                       'rm' => 2,
                       'bn' => 'zencart',
                       'mrb' => 'R-6C7952342H795591R',
                       'pal' => '9E82WJBKKGPLQ',
                       );
        $optionsCust = array(
                       'first_name' => replace_accents($order->customer['firstname']),
                       'last_name' => replace_accents($order->customer['lastname']),
                       'address1' => replace_accents($order->customer['street_address']),
                       'city' => replace_accents($order->customer['city']),
                       'state' => zen_get_zone_code($order->customer['country']['id'], $order->customer['zone_id'], $order->customer['zone_id']),
                       'zip' => $order->customer['postcode'],
                       'country' => $order->customer['country']['iso_code_2'],
                       'email' => $order->customer['email_address'],
                       );
        if ($order->customer['suburb'] != '') $optionsCust['address2'] = $order->customer['suburb'];
        if (MODULE_PAYMENT_INTERNATIONALCHECKOUT_ADDRESS_REQUIRED == 2) $optionsCust = array(
                       'address_name' => replace_accents($order->customer['firstname'] . ' ' . $order->customer['lastname']),
                       'address_street' => replace_accents($order->customer['street_address']),
                       'address_city' => replace_accents($order->customer['city']),
                       'address_state' => zen_get_zone_code($order->customer['country']['id'], $order->customer['zone_id'], $order->customer['zone_id']),
                       'address_zip' => $order->customer['postcode'],
                       'address_country' => $order->customer['country']['title'],
                       'address_country_code' => $order->customer['country']['iso_code_2'],
                       'payer_email' => $order->customer['email_address'],
                       );
        $optionsShip = array(
                       //'address_override' => MODULE_PAYMENT_INTERNATIONALCHECKOUT_ADDRESS_OVERRIDE,
                       'no_shipping' => MODULE_PAYMENT_INTERNATIONALCHECKOUT_ADDRESS_REQUIRED,
                       );*/ 

    I understand the code below loops through the ordered products and get the info

    PHP Code:
        if (MODULE_PAYMENT_INTERNATIONALCHECKOUT_DETAILED_CART == 'Yes'$optionsLineItems ipn_getLineItemDetails();
        if (
    sizeof($optionsLineItems) > 0) {
          
    $optionsLineItems['cmd'] = '_cart';
    //      $optionsLineItems['num_cart_items'] = sizeof($order->products); 
    PHP Code:
    /* Not needed as I don't have to pass shipping nor handling data

          if (isset($optionsLineItems['shipping'])) {
            $optionsLineItems['shipping_1'] = $optionsLineItems['shipping'];
            unset($optionsLineItems['shipping']);
          }
          if (isset($optionsLineItems['handling'])) {
            $optionsLineItems['handling_1'] = $optionsLineItems['handling'];
            unset($optionsLineItems['handling']);
          }*/
          
    unset($optionsLineItems['subtotal']);
          
    // if line-item details couldn't be kept due to calculation mismatches or discounts etc, default to aggregate mode
          
    if (!isset($optionsLineItems['item_name_1'])) $optionsLineItems = array();
          
    //if ($optionsLineItems['amount'] != $this->transaction_amount) $optionsLineItems = array();
          /*ipn_debug_email('Line Item Details (if blank, this means there was a data mismatch, and thus bypassed): ' . "\n" . print_r($optionsLineItems, true));
        }*/ 
    // Aggregate is it an Auxiliary array? Redundant?

    PHP Code:
        $optionsAggregate = array(
                       
    'cmd' => '_ext-enter',
                       
    'item_name' => MODULE_PAYMENT_INTERNATIONALCHECKOUT_PURCHASE_DESCRIPTION_TITLE,
                       
    'item_number' => MODULE_PAYMENT_INTERNATIONALCHECKOUT_PURCHASE_DESCRIPTION_ITEMNUM,
                       
    //'num_cart_items' => sizeof($order->products),
                       
    'amount' => number_format($this->transaction_amount$currencies->get_decimal_places($my_currency)),
                       
    'shipping' => '0.00',
                        );
        if (
    MODULE_PAYMENT_INTERNATIONALCHECKOUT_TAX_OVERRIDE == 'true'$optionsAggregate['tax'] = '0.00';
        if (
    MODULE_PAYMENT_INTERNATIONALCHECKOUT_TAX_OVERRIDE == 'true'$optionsAggregate['tax_cart'] = '0.00'

    From here I think everything is needed, please note I only need to submit the detailed order and nothing else ...

    PHP Code:
     $optionsTrans = array(
                       
    'upload' => (int)(sizeof($order->products) > 0),
                       
    'currency_code' => $my_currency,
    //                   'internationalcheckout_order_id' => $internationalcheckout_order_id,
                       //'no_note' => '1',
                       //'invoice' => '',
                        
    );

        
    // if line-item info is invalid, use aggregate:
        
    if (sizeof($optionsLineItems) > 0$optionsAggregate $optionsLineItems;

        
    // prepare submission
        
    $options array_merge($optionsCore$optionsCust$optionsPhone$optionsShip$optionsTrans$optionsAggregate);
        
    ipn_debug_email('Keys for submission: ' print_r($optionstrue));
        
    // build the button fields
        
    foreach ($options as $name => $value) {
          
    // remove quotation marks
          
    $value str_replace('"'''$value);
          
    // check for invalid chars
          
    if (preg_match('/[^a-zA-Z_0-9]/'$name)) {
            
    ipn_debug_email('datacheck - ABORTING - preg_match found invalid submission key: ' $name ' (' $value ')');
            break;
          }
          
    // do we need special handling for & and = symbols?
          //if (strpos($value, '&') !== false || strpos($value, '=') !== false) $value = urlencode($value);

          
    $buttonArray[] = zen_draw_hidden_field($name$value);
        }
        
    $process_button_string implode("\n"$buttonArray) . "\n";

        
    $_SESSION['internationalcheckout_transaction_info'] = array($this->transaction_amount$this->transaction_currency);
        return 
    $process_button_string;
      }
      
    /**
       * Store transaction info to the order and process any results that come back from the payment gateway
       */ 

  4. #14
    Join Date
    Jun 2009
    Location
    Europe
    Posts
    59
    Plugin Contributions
    1

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

    in paypal.php

    PHP Code:
     $options array_merge($optionsCore$optionsCust$optionsPhone$optionsShip$optionsTrans$optionsAggregate); 
    is basically holding all the parameters that will be transfered to the payment gateway (later transferred to an HTTP POST function).

    This is basically handled in:
    PHP Code:
    foreach ($options as $name => $value) {
          
    // ....
          // some lines removed
          //

          
    $buttonArray[] = zen_draw_hidden_field($name$value);
        }
        
    $process_button_string implode("\n"$buttonArray) . "\n"
    So send only the things that are required, with the correct post item names as your payment gateway requires.

    I don't understand why you use html input command, do you expect your customers to enter that data from a form? I think those items knowledge must be available in your cart items data, and you need fetch/form them somehow from there (i don't know how).

    Paypal.php module creates paypal session history and keeps it in the database. session_id in the following is a reference to that database item. If you follow the methods you will recognize that it will be removed from the database later on after successful payment. You can keep this (provided you change the database name from TABLE_PAYPAL_SESSION to yours, unless you want to screw up the paypal database )
    PHP Code:
    $_SESSION['ppipn_key_to_remove'] = session_id(); 

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

    Default Using an iFrame or PHP with CUrl to emulate it in a payment module?

    Hi,

    I was wondering if I can use a an iFrame or I have to use curl to emulate it to post data, in a payment module?

    The iframe will connect to the processor's page and just pass POST data (cart info, products and quantities), there is no need to validate anything, just retrieve the info from the shopping cart and pass it to the other site and the transaction will be completed in there.

  6. #16
    Join Date
    Jun 2005
    Location
    Cumbria, UK
    Posts
    10,266
    Plugin Contributions
    3

    Default Re: Using an iFrame or PHP with CUrl to emulate it in a payment module?

    As you are not being sufficiently specific, I make the assumption that you are trying to run zencart (or parts of it) in an Iframe.

    Generally speaking this is not a good idea. You may experience session issues, and secondly, many payment gateways reject transactions coming out of an iframe.
    20 years a Zencart User

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

    Default Re: Using an iFrame or PHP with CUrl to emulate it in a payment module?

    Sorry for being so vague, it's exactly the opposite!

    Within Zen Cart:

    I need to run an iFrame with a payment module that uses it to connect to the processor. In this case I only need to pass checkout data, shopping cart contents as POST variables, only product info, description, price, quantities, plus a new field because I need to add shipping cost to their warehouse nothing else ...

    That's why I was worried about compatibility issues, if a use a pure iFrame, as their system is designed to display my user page within this iFrame, there the customer will fulfill all his info, whatever payment and shipping method they choose, and personal data.
    All within this iFrame.

    So my question was, will it work or I better pass these parameters and vars using curl?

  8. #18
    Join Date
    Jun 2005
    Location
    Cumbria, UK
    Posts
    10,266
    Plugin Contributions
    3

    Default Re: Using an iFrame or PHP with CUrl to emulate it in a payment module?

    That is an answer that's beyond my modest skills, I'm afraid...
    20 years a Zencart User

  9. #19
    Join Date
    Jan 2004
    Posts
    66,443
    Plugin Contributions
    279

    Default Re: Using an iFrame or PHP with CUrl to emulate it in a payment module?

    Much more secure, and much simpler to code (no templating, no UI, no "view" components) if you just use CURL.
    .

    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.

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

    Default Re: Using an iFrame or PHP with CUrl to emulate it in a payment module?

    Quote Originally Posted by DrByte View Post
    Much more secure, and much simpler to code (no templating, no UI, no "view" components) if you just use CURL.
    Then I will got for it ...
    Thanks!

 

 
Page 2 of 7 FirstFirst 1234 ... 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