Page 1 of 2 12 LastLast
Results 1 to 10 of 12
  1. #1
    Join Date
    Sep 2007
    Location
    Chepstow, SE Wales
    Posts
    101
    Plugin Contributions
    0

    Default Customize epdq form

    My client has gone down the epdq road, and after much troubles I have got the thng working but one problem is the fact that user needs to re-enter all their address details again.

    I went to Barclays and they told me that they dont know how to do it in zen but basically, I will need to get access to the page posting to the epdq page (index.php?main_page=checkout_confirmation), which isnt as straight forward with zen, and insert the form values there.

    They said that I can submit the billing address for customers as well, and even tell the CPI whether to even display a delivery address page, which as it goes i dont, as delivery goes to the shipping address.

    Please can somebody help me out with this.

    Lee
    Are we there yet?

    Just one more line of code and im done...

  2. #2
    Join Date
    Sep 2007
    Location
    Chepstow, SE Wales
    Posts
    101
    Plugin Contributions
    0

    Default Re: Customize epdq form

    I know this is going to be a lot, but I have found the php that zen created to allow epdq to work, and I will post the whole page below. But I am still struggling ot work it out.

    Code:
    <?php
    //
    // +----------------------------------------------------------------------+
    // |zen-cart Open Source E-commerce                                       |
    // +----------------------------------------------------------------------+
    // | Copyright (c) 2003 The zen-cart developers                           |
    // |                                                                      |
    // | http://www.zen-cart.com/index.php                                    |
    // |                                                                      |
    // | Portions Copyright (c) 2003 osCommerce                               |
    // +----------------------------------------------------------------------+
    // | This source file is subject to version 2.0 of the GPL license,       |
    // | that is bundled with this package in the file LICENSE, and is        |
    // | available through the world-wide-web at the following url:           |
    // | http://www.zen-cart.com/license/2_0.txt.                             |
    // | If you did not receive a copy of the zen-cart license and are unable |
    // | to obtain it through the world-wide-web, please send a note to       |
    // | [email protected] so we can mail you a copy immediately.          |
    // +----------------------------------------------------------------------+
    // $Id: EPDQ_form.php,v 1.1 2005/03/08 10:20:00 jennweir
    //
    
      class epdq_form {
        var $code, $title, $description, $enabled;
    
    // class constructor
        function epdq_form() {
          global $order;
          $this->code = 'epdq_form';
          $this->title = MODULE_PAYMENT_EPDQ_FORM_TEXT_TITLE;
          $this->description = MODULE_PAYMENT_EPDQ_FORM_TEXT_DESCRIPTION;
          $this->enabled = ((MODULE_PAYMENT_EPDQ_FORM_STATUS == 'True') ? true : false);
          $this->sort_order = MODULE_PAYMENT_EPDQ_FORM_SORT_ORDER;
    
          if ((int)MODULE_PAYMENT_EPDQ_FORM_ORDER_STATUS_ID > 0) {
            $this->order_status = MODULE_PAYMENT_EPDQ_FORM_ORDER_STATUS_ID;
          }
    
          if (is_object($order)) $this->update_status();
    
          $this->form_action_url = 'https://secure2.epdq.co.uk/cgi-bin/CcxBarclaysEpdq.e';
        }
    
    // class methods
        function update_status() {
          global $order, $db;
    
          if ( ($this->enabled == true) && ((int)MODULE_PAYMENT_EPDQ_FORM_ZONE > 0) ) {
            $check_flag = false;
            $check = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_PAYMENT_EPDQ_FORM_ZONE . "' and zone_country_id = '" . $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;
            }
          }
        }
    
        function javascript_validation() {
          return false;
        }
    
        function simpleXor($InString, $Key) {
          $KeyList = array();
          $output = "";
    
          for($i = 0; $i < strlen($Key); $i++){
            $KeyList[$i] = ord(substr($Key, $i, 1));
          }
    
          for($i = 0; $i < strlen($InString); $i++) {
            $output.= chr(ord(substr($InString, $i, 1)) ^ ($KeyList[$i % strlen($Key)]));
          }
    
          return $output;
        }
    
        function selection() {
          return array('id' => $this->code,
                       'module' => $this->title);
        }
    
        function pre_confirmation_check() {
          return false;
        }
    
        function confirmation() {
          return false;
        }
    
        function process_button() {
          global $order, $currencies, $currency, $order_total_modules;
    
    	//barclays requires us to send them the order id encrypted 
    	//so we have to save this order in a pending state prior to posting the form to them.
      	  $order_totals = $order_total_modules->pre_confirmation_check();
    	  $order_totals = $order_total_modules->process();
    
          $new_order_id = $order->create($order_totals);
    
          $order->create_add_products($new_order_id, 2);
    
          switch (MODULE_PAYMENT_EPDQ_FORM_CURRENCY) {
            case 'Default Currency':
              $EPDQ_currency = DEFAULT_CURRENCY;
              break;
            case 'Any Currency':
            default:
              $EPDQ_currency = $currency;
              break;
          }
    
    
    		#the following function performs a HTTP Post and returns the whole response
    		function pullpage( $host, $usepath, $postdata = "" ) {
    		 
    			# open socket to filehandle(epdq encryption cgi)
    			 $fp = fsockopen( $host, 80, &$errno, &$errstr, 60 );
    		
    			#check that the socket has been opened successfully
    			 if( !$fp ) {
    				print "$errstr ($errno)<br>\n";
    			 }
    			 else {
    		
    				#write the data to the encryption cgi
    				fputs( $fp, "POST $usepath HTTP/1.0\n");
    				$strlength = strlen( $postdata );
    				fputs( $fp, "Content-type: application/x-www-form-urlencoded\n" );
    				fputs( $fp, "Content-length: ".$strlength."\n\n" );
    				fputs( $fp, $postdata."\n\n" );
    		
    				#clear the response data
    			   $output = "";
    		 
    		 
    				#read the response from the remote cgi 
    				#while content exists, keep retrieving document in 1K chunks
    				while( !feof( $fp ) ) {
    					$output .= fgets( $fp, 1024);
    				}
    		
    				#close the socket connection
    				fclose( $fp);
    			 }
    		
    			#return the response
    			 return $output;
    		}
    		
    		#define the remote cgi in readiness to call pullpage function 
    		$server="secure2.epdq.co.uk";
    		$url="/cgi-bin/CcxBarclaysEpdqEncTool.e";
    		$currencycode = 826;
    		$passphrase = MODULE_PAYMENT_EPDQ_FORM_PASSWORD;
    		$clientid = MODULE_PAYMENT_EPDQ_FORM_VENDOR_ID;
    
    		//// Does this store use preauth
    			if (MODULE_PAYMENT_EPDQ_FORM_PREAUTH == 'true') {
    				$transaction_type = 'PreAuth';
    			} else {
    				$transaction_type = 'Auth';
    			}
    
    		
    		#the following parameters have been obtained earlier in the merchant's webstore
    		#clientid, passphrase, oid, currencycode, total
    		$params="clientid=$clientid";
    		$params.="&password=$passphrase";
    		$params.="&oid=$new_order_id";
    		$params.="&chargetype=$transaction_type";
    		$params.="&currencycode=$currencycode";
    		$params.="&total=".number_format($order->info['total'] * $currencies->get_value($EPDQ_currency), $currencies->get_decimal_places($EPDQ_currency)) ;
    		
    		#perform the HTTP Post
    		$response = pullpage( $server,$url,$params );
    		   
    		#split the response into separate lines
    		$response_lines=explode("\n",$response);
    		
    		#for each line in the response check for the presence of the string 'epdqdata'
    		#this line contains the encrypted string
    		$response_line_count=count($response_lines);
    		for ($i=0;$i<$response_line_count;$i++){
    			if (preg_match('/epdqdata/',$response_lines[$i])){
    				$strEPDQ=$response_lines[$i];
    			}
    		}
    
    
          $plain = "VendorTxCode=" . date('Ymdhis') . "&";
          $plain .= "Amount=" . number_format($order->info['total'] * $currencies->get_value($EPDQ_currency), $currencies->get_decimal_places($EPDQ_currency)) . "&";
          $plain .= "Currency=" . $EPDQ_currency . "&";
          $plain .= "Description='" . STORE_NAME . "'&";
          $plain .= "SuccessURL=" . zen_href_link(FILENAME_CHECKOUT_PROCESS, '', 'SSL', true) . "&";
          $plain .= "FailureURL=" . zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL', true) . "&";
          $plain .= "CustomerName=" . $order->billing['firstname'] . ' ' . $order->billing['lastname'] . "&";
          $plain .= "CustomerEmail=" . $order->customer['email_address'] . "&";
          $plain .= "VendorEMail=" . STORE_OWNER_EMAIL_ADDRESS . "&";
          $plain .= "DeliveryAddress=" . $order->delivery['street_address'] . "\n" .
                                         $order->delivery['suburb'] . "\n" .
                                         $order->delivery['city'] . "\n" .
                                         $order->delivery['state'] . "\n" .
                                         $order->delivery['country']['title'] . "&";
          $plain .= "DeliveryPostCode=" . $order->delivery['postcode'] . "&";
          $plain .= "BillingAddress=" . $order->billing['street_address'] . "\n" .
                                        $order->billing['suburb'] . "\n" .
                                        $order->billing['city'] . "\n" .
                                        $order->billing['state'] . "\n" .
                                        $order->billing['country']['title'] . "&";
          $plain .= "BillingPostCode=" . $order->billing['postcode'] . "";
    
          $process_button_string = zen_draw_hidden_field('oid', $new_order_id) .
                                   zen_draw_hidden_field('returnurl', MODULE_PAYMENT_EPDQ_FORM_RETURNURL) .
                                   $strEPDQ .
                                   zen_draw_hidden_field('merchantdisplayname', MODULE_PAYMENT_EPDQ_FORM_VENDOR_NAME);
    
          return $process_button_string;
        }
    
        function before_process() {
           global $order_total_modules;
         // now just need to check here whether we are here because of IPN or auto-return, we cn use the referer variable for that
         // If we have come from auto return, check to see wether the order has been created by IPN and if not create it now.
         if ($_GET['referer'] == 'epdq_form') {
           $_SESSION['cart']->reset(true);
           unset($_SESSION['sendto']);
           unset($_SESSION['billto']);
           unset($_SESSION['shipping']);
           unset($_SESSION['payment']);
           unset($_SESSION['comments']);
           $order_total_modules->clear_posts();//ICW ADDED FOR CREDIT CLASS SYSTEM
           zen_redirect(zen_href_link(FILENAME_CHECKOUT_SUCCESS, '', 'SSL'));
         } else {
           zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));
         }
        }
    
        function check_referrer($zf_domain) {
          return true;
        }
    
        function after_process() {
          $_SESSION['order_created'] = '';
          return false;
        }
    
        function get_error() {
          global $_GET;
    
          if (isset($_GET['message']) && (strlen($_GET['message']) > 0)) {
            $error = stripslashes(urldecode($_GET['message']));
          } else {
            $error = MODULE_PAYMENT_EPDQ_FORM_TEXT_ERROR_MESSAGE;
          }
    
          return array('title' => MODULE_PAYMENT_EPDQ_FORM_TEXT_ERROR,
                       'error' => $error);
        }
    
        function check() {
        global $db;
          if (!isset($this->_check)) {
            $check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_PAYMENT_EPDQ_FORM_STATUS'");
            $this->_check = $check_query->RecordCount();
          }
          return $this->_check;
        }
    
        function install() {
        global $db;
          $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 EPDQ Form Module', 'MODULE_PAYMENT_EPDQ_FORM_STATUS', 'True', 'Do you want to accept EPDQ Form payments?', '6', '1', '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 ('Client ID', 'MODULE_PAYMENT_EPDQ_FORM_VENDOR_ID', '12345', 'Client ID to use with the EPDQ Form service', '6', '2', now())");
          $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Client Name', 'MODULE_PAYMENT_EPDQ_FORM_VENDOR_NAME', 'My Store Name', 'Client Name to use with the EPDQ Form service', '6', '2', now())");
          $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Password', 'MODULE_PAYMENT_EPDQ_FORM_PASSWORD', 'testvendor', 'Password to use with the EPDQ Form service', '6', '2', now())");
          $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('ReturnURL', 'MODULE_PAYMENT_EPDQ_FORM_RETURNURL', 'http://www.mystore.co.uk/epdq_response.php', 'Return URL to use with the EPDQ Form service', '6', '2', 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 ('Transaction Mode', 'MODULE_PAYMENT_EPDQ_FORM_TEST_STATUS', 'true', 'Use Test Mode?', '6', '4', '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, set_function, date_added) values ('Use Pre-Authorisation', 'MODULE_PAYMENT_EPDQ_FORM_PREAUTH', 'true', 'Use Pre-Authorisation for all transactions?', '6', '5', '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, set_function, date_added) values ('Transaction Currency', 'MODULE_PAYMENT_EPDQ_FORM_CURRENCY', 'Any Currency', 'The currency to use for credit card transactions', '6', '3', 'zen_cfg_select_option(array(\'Any Currency\', \'Default Currency\'), ', 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_EPDQ_FORM_SORT_ORDER', '0', 'Sort order of display. 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, use_function, set_function, date_added) values ('Payment Zone', 'MODULE_PAYMENT_EPDQ_FORM_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, set_function, use_function, date_added) values ('Set Order Status', 'MODULE_PAYMENT_EPDQ_FORM_ORDER_STATUS_ID', '0', 'Set the status of orders made with this payment module to this value', '6', '0', 'zen_cfg_pull_down_order_statuses(', 'zen_get_order_status_name', now())");
        }
    
        function remove() {
        global $db;
          $db->Execute("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
        }
    
        function keys() {
          return array('MODULE_PAYMENT_EPDQ_FORM_STATUS', 'MODULE_PAYMENT_EPDQ_FORM_VENDOR_ID', 'MODULE_PAYMENT_EPDQ_FORM_VENDOR_NAME', 'MODULE_PAYMENT_EPDQ_FORM_PASSWORD', 'MODULE_PAYMENT_EPDQ_FORM_RETURNURL', 'MODULE_PAYMENT_EPDQ_FORM_TEST_STATUS', 'MODULE_PAYMENT_EPDQ_FORM_PREAUTH', 'MODULE_PAYMENT_EPDQ_FORM_CURRENCY', 'MODULE_PAYMENT_EPDQ_FORM_SORT_ORDER', 'MODULE_PAYMENT_EPDQ_FORM_ZONE', 'MODULE_PAYMENT_EPDQ_FORM_ORDER_STATUS_ID');
        }
      }
    ?>


    Lee
    Are we there yet?

    Just one more line of code and im done...

  3. #3
    Join Date
    Sep 2007
    Location
    Chepstow, SE Wales
    Posts
    101
    Plugin Contributions
    0

    Default Re: Customize epdq form

    Ok I have made some in roads and have got epdq working to a certain extent, but now I need some help to pass over billing address details.

    The cancelling out of the delivery address, is done by adding this line of code below to the epdq_form.php page around line 222.

    Code:
    'zen_draw_hidden_field('collectdeliveryaddress'), 0)'
    The next step is to pass over the billing address details, and the line of code below is the start.

    Code:
    zen_draw_hidden_field('baddr1', ?????);
    But as you can see I dont know what goes in the ????? area to reference the street address line 1 in this case.

    Thanks

    Lee
    Are we there yet?

    Just one more line of code and im done...

  4. #4
    Join Date
    Sep 2007
    Location
    Chepstow, SE Wales
    Posts
    101
    Plugin Contributions
    0

    Default Re: Customize epdq form

    It doesnt look right to me but this is what Im trying to pass over:

    Code:
    zen_draw_hidden_field('baddr1', $plain .= "BillingAddress=" . $order->billing['street_address'])
    Lee
    Are we there yet?

    Just one more line of code and im done...

  5. #5
    Join Date
    Sep 2007
    Location
    Chepstow, SE Wales
    Posts
    101
    Plugin Contributions
    0

    Default Re: Customize epdq form

    If anybody can help, I have worked it out and I need the following too to make up the epdq form with the customers billing address:

    baddr1 - address line 1 (street address)
    bcity - city
    bcountyprovince - state
    bcountry - country
    bpostalcode - postcode



    Lee
    Are we there yet?

    Just one more line of code and im done...

  6. #6
    Join Date
    Sep 2007
    Location
    Chepstow, SE Wales
    Posts
    101
    Plugin Contributions
    0

    Default Re: Customize epdq form

    Just so that i can make sure that I can push things up, I was going to hard code the address into the form, and was wondering if anybody can help me do this.

    eg:

    Code:
    zen_draw_hidden_field('baddr1',  '2 Swallow Drive');
    But that isnt working above

    Lee
    Are we there yet?

    Just one more line of code and im done...

  7. #7
    Join Date
    Sep 2007
    Location
    Chepstow, SE Wales
    Posts
    101
    Plugin Contributions
    0

    Default Re: Customize epdq form

    Its the variable names for the billing address fields Im looking for I think?

    Lee
    Are we there yet?

    Just one more line of code and im done...

  8. #8
    Join Date
    Sep 2007
    Location
    Chepstow, SE Wales
    Posts
    101
    Plugin Contributions
    0

    Default Re: Customize epdq form

    Good afternoon everyone,

    I finally got a load of stuff sorted today, but I got one thing left to find, if an expert zen cart user coudl help me with this one.

    As you will see below, I managed to stop the collectdeliverypage, and also hard code the billing address and other details into the Customer Payment Interface:

    Code:
    							   zen_draw_hidden_field('collectdeliveryaddress', '0') .	
    							   zen_draw_hidden_field('baddr1', "2 Swallow Drive") .
    							   zen_draw_hidden_field('baddr2', "Second address line") .
    							   zen_draw_hidden_field('baddr3', "Third Address line") .
    							   zen_draw_hidden_field('bcity', "Caldicot") . 
    							   zen_draw_hidden_field('bcountyprovince', "Monmouthshire") .
    							   zen_draw_hidden_field('bcountry', "UK") . 
    							   zen_draw_hidden_field('bstate', "state if US") .
    							   zen_draw_hidden_field('bpostalcode', "NP26 5RD") .
    							   zen_draw_hidden_field('email', "[email protected]") .
    							   zen_draw_hidden_field('btelephonenumber', "01291 421412");
    Obviously now, what I need are the zen cart variables for the Billing address for all above.

    Can anybody help me get these please.

    Thanks

    Lee
    Are we there yet?

    Just one more line of code and im done...

  9. #9
    Join Date
    Sep 2007
    Location
    Chepstow, SE Wales
    Posts
    101
    Plugin Contributions
    0

    Default Re: Customize epdq form

    Ok I've worked it out, and im going to post it for anybody else who needs help with zen cart and epdq...

    Here is the code thats needed in order to push up the data needed to fill in the billing address details so that the customer doesnt need to, also there is a line of code for collectdeliveryaddress, which when set to zero stops that second option (delivery address) being available.

    Code:
    $process_button_string = zen_draw_hidden_field('oid', $new_order_id) .
                                   zen_draw_hidden_field('returnurl', MODULE_PAYMENT_EPDQ_FORM_RETURNURL) .
                                   $strEPDQ .
                                   zen_draw_hidden_field('merchantdisplayname', MODULE_PAYMENT_EPDQ_FORM_VENDOR_NAME) .
    							   zen_draw_hidden_field('collectdeliveryaddress', '0') .	
    							   zen_draw_hidden_field('baddr1', $order->billing['street_address']) . "\n" .
    							   zen_draw_hidden_field('baddr2', $order->billing['suburb']) . "\n" .
    							   zen_draw_hidden_field('baddr3', "") . "\n" .
    							   zen_draw_hidden_field('bcity', $order->billing['city']) . "\n" . 
    							   zen_draw_hidden_field('bcountyprovince', $order->billing['state']) . "\n" .
    							   zen_draw_hidden_field('bcountry', $order->billing['title']) . "&" .
    							   zen_draw_hidden_field('bpostalcode', $order->billing['postcode']) . "&" .
    							  zen_draw_hidden_field('email', $order->customer['email_address']) . "\n" .   
    
          return $process_button_string;
        }


    You add this code to the epdq_form.php page around line 224.

    There is another post in this forum with the epdq_form.php + other pages, which are zipped.

    Anyway, its been a long old job this one, but its here for somebody else now.

    Cheers

    Lee
    Are we there yet?

    Just one more line of code and im done...

  10. #10
    Join Date
    Jun 2007
    Posts
    2
    Plugin Contributions
    0

    Default Re: Customize epdq form

    Hiya,

    Currently trying to tackle this for a customer myself. However I'm having a small issue that the code for the epdq_form.php isn't PHP5 compatible... Or at least that appears to be the case.

    Anybody got any ideas? and the reason I've replied to this post, is that it contains the most useful information I've found sofar

    Pete A

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. customize contact us form text color?
    By hooai12 in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 29 Nov 2009, 11:34 AM
  2. Customize the Registraition form required info
    By stefanl in forum Managing Customers and Orders
    Replies: 0
    Last Post: 30 Aug 2009, 08:32 AM
  3. To EPDQ or not to EPDQ
    By junpit in forum Built-in Shipping and Payment Modules
    Replies: 1
    Last Post: 15 Jul 2007, 10:28 PM

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