Jump to content

pass the current orders_id as reference_no


raj3396

Recommended Posts

hi I am on zen cart 1.39h, here is the ebs payment module file, this code ($ref_no = date('YmdHis');) passes the current date and time as reference_no, i just want to pass the current orders_id as reference_no , the entire code is below:

 

<?php

 

/*

 

Zencart

 

Copyright © 2003 Zencart

 

 

 

Released under the GNU General Public License

 

*/

/**

* RC4 stream cipher routines implementation

*

* in PHP4 based on code written by Damien Miller <djm@mindrot.org>

*

* Usage:

* $key = "pear";

* $message = "PEAR rulez!";

*

* $rc4 = new Crypt_RC4;

* $rc4->key($key);

* echo "Original message: $message <br>\n";

* $rc4->crypt($message);

* echo "Encrypted message: $message <br>\n";

* $rc4->decrypt($message);

* echo "Decrypted message: $message <br>\n";

*

* @version $Revision: 1.6 $

* @access public

* @package Crypt

* @author Dave Mertens <dmertens@zyprexia.com>

*/

class Crypt_RC4 {

 

/**

* Real programmers...

* @var array

*/

var $s= array();

/**

* Real programmers...

* @var array

*/

var $i= 0;

/**

* Real programmers...

* @var array

*/

var $j= 0;

 

/**

* Key holder

* @var string

*/

var $_key;

 

/**

* Constructor

* Pass encryption key to key()

*

* @see key()

* @param string key - Key which will be used for encryption

* @return void

* @access public

*/

function Crypt_RC4($key = null) {

if ($key != null) {

$this->setKey($key);

}

}

 

function setKey($key) {

if (strlen($key) > 0)

$this->_key = $key;

}

 

/**

* Assign encryption key to class

*

* @param string key - Key which will be used for encryption

* @return void

* @access public

*/

function key(&$key) {

$len= strlen($key);

for ($this->i = 0; $this->i < 256; $this->i++) {

$this->s[$this->i] = $this->i;

}

 

$this->j = 0;

for ($this->i = 0; $this->i < 256; $this->i++) {

$this->j = ($this->j + $this->s[$this->i] + ord($key[$this->i % $len])) % 256;

$t = $this->s[$this->i];

$this->s[$this->i] = $this->s[$this->j];

$this->s[$this->j] = $t;

}

$this->i = $this->j = 0;

}

 

/**

* Encrypt function

*

* @param string paramstr - string that will encrypted

* @return void

* @access public

*/

function crypt(&$paramstr) {

 

//Init key for every call, Bugfix 22316

$this->key($this->_key);

 

$len= strlen($paramstr);

for ($c= 0; $c < $len; $c++) {

$this->i = ($this->i + 1) % 256;

$this->j = ($this->j + $this->s[$this->i]) % 256;

$t = $this->s[$this->i];

$this->s[$this->i] = $this->s[$this->j];

$this->s[$this->j] = $t;

 

$t = ($this->s[$this->i] + $this->s[$this->j]) % 256;

 

$paramstr[$c] = chr(ord($paramstr[$c]) ^ $this->s[$t]);

}

}

 

/**

* Decrypt function

*

* @param string paramstr - string that will decrypted

* @return void

* @access public

*/

function decrypt(&$paramstr) {

//Decrypt is exactly the same as encrypting the string. Reuse (en)crypt code

$this->crypt($paramstr);

}

 

 

} //end of RC4 class

 

// Please make sure you insert your merchant id in the OSC admin area

 

class ebs2_5 {

 

var $code, $title, $description, $enabled;

 

 

 

// class constructor

 

function ebs2_5() {

 

global $order;

 

$this->code = 'ebs2_5';

 

$this->title = MODULE_PAYMENT_EBS_TEXT_TITLE;

 

$this->description = MODULE_PAYMENT_EBS_TEXT_DESCRIPTION;

 

$this->sort_order = MODULE_PAYMENT_EBS_SORT_ORDER;

 

$this->enabled = ((MODULE_PAYMENT_EBS_STATUS == 'True') ? true : false);

 

$this->form_action_url = 'https://secure.ebs.in/pg/ma/sale/pay/';

 

}

 

 

 

function update_status() {

/* Check whether the zones/geo_zones is valid */

global $order;

if (((int) MODULE_PAYMENT_EBS_VALID_ZONE > 0)) {

$checkFlag = false;

global $db;

$sql = "select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_PAYMENT_EBS_VALID_ZONE . "' and zone_country_id = '".$order->delivery['country']['id']."' order by zone_id";

$result = $db->Execute($sql);

if($result) while(!$result->EOF) {

if ($result->fields['zone_id'] < 1) {

$checkFlag = true;

break;

}

elseif ($result->fields['zone_id'] == $order->delivery['zone_id']) {

$checkFlag = true;

break;

}

// Move Next

}

 

/* Set whether this should be valid or not */

if ($checkFlag == false) {

$this->enabled = false;

}

}

}

 

 

 

 

// class methods

 

 

function javascript_validation() {

 

return '';

}

 

 

 

function selection() {

 

global $order;

 

 

 

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' => MODULE_PAYMENT_EBS_TEXT_CREDIT_CARD_OWNER_FIRST_NAME,

 

'field' => zen_draw_input_field('ebs_cc_owner_firstname', $order->billing['firstname'])),

 

array('title' => MODULE_PAYMENT_EBS_TEXT_CREDIT_CARD_OWNER_LAST_NAME,

 

'field' => zen_draw_input_field('ebs_cc_owner_lastname', $order->billing['lastname']))));

 

 

return $selection;

 

}

 

 

 

function pre_confirmation_check() {

 

return false;

}

 

 

 

function confirmation() {

 

$confirmation = array ('title' => $this->description);

return $confirmation;

 

}

 

 

 

function process_button() {

 

global $order,$order_total_modules,$currencies;

 

$temp=mysql_query("select value from zen_currencies where code='INR'")or die(mysql_error());

 

$currency_value=mysql_fetch_array($temp);

$products_ordered = '';

for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {

$products_ordered .= $order->products[$i]['qty'] . ' x ' . $order->products[$i]['name'] . ' (' . $order->products[$i]['model'] . ') = ' . $currencies->display_price($order->products[$i]['final_price'], $order->products[$i]['tax'], $order->products[$i]['qty']) . $products_ordered_attributes . "\n";

}

$products_ordered .= "\n";

$order_totals = $order_total_modules->process();

for ($i=0, $n=sizeof($order_totals); $i<$n; $i++) {

$products_ordered .= strip_tags($order_totals[$i]['title']) . ' ' . strip_tags($order_totals[$i]['text']) . "\n";

}

 

$amount = $order->info['total'];

$ref_no = date('YmdHis');

 

$return_url = zen_href_link(FILENAME_CHECKOUT_PROCESS, 'DR=${DR}', 'SSL');

 

 

$hash = MODULE_PAYMENT_EBS_SECRET_KEY."|".MODULE_PAYMENT_EBS_ACCOUNTID."|". $amount."|".$ref_no."|".html_entity_decode($return_url)."|".MODULE_PAYMENT_EBS_T ESTMODE;

 

 

$secure_hash = md5($hash);

 

 

 

 

 

 

 

 

$process_button_string = zen_draw_hidden_field('account_id', MODULE_PAYMENT_EBS_ACCOUNTID) .

 

 

 

zen_draw_hidden_field('amount', $amount).

 

zen_draw_hidden_field('description','Order ID'. $order->info['orders_id']).

 

zen_draw_hidden_field('reference_no',$ref_no) .

 

zen_draw_hidden_field('name', $order->customer['firstname'] . ' ' . $order->customer['lastname']) .

 

zen_draw_hidden_field('address', $order->customer['street_address']) .

 

zen_draw_hidden_field('city', $order->customer['city']) .

 

zen_draw_hidden_field('state', $order->customer['state']) .

 

zen_draw_hidden_field('postal_code', $order->customer['postcode']) .

 

zen_draw_hidden_field('country', $order->customer['country']['iso_code_3']) .

 

zen_draw_hidden_field('email', $order->customer['email_address']) .

 

zen_draw_hidden_field('phone', $order->customer['telephone']) .

 

zen_draw_hidden_field('ship_name', $order->delivery['firstname'] . ' ' . $order->delivery['lastname']) .

 

zen_draw_hidden_field('ship_address', $order->delivery['street_address']) .

 

zen_draw_hidden_field('ship_city', $order->delivery['city']) .

 

zen_draw_hidden_field('ship_state', $order->delivery['state']) .

 

zen_draw_hidden_field('ship_postal_code', $order->delivery['postcode']) .

 

zen_draw_hidden_field('ship_country', $order->delivery['country']['iso_code_3']) .

 

zen_draw_hidden_field('ship_phone', $order->delivery['telephone']) .

 

zen_draw_hidden_field('mode', MODULE_PAYMENT_EBS_TESTMODE) .

 

zen_draw_hidden_field('secure_hash', $secure_hash) .

 

 

zen_draw_hidden_field('return_url',$return_url);

 

return $process_button_string;

 

}

 

 

 

function before_process() {

 

$QueryString = base64_decode($_GET['DR']);

 

$secret_key = MODULE_PAYMENT_EBS_SECRET_KEY;

$rc4 = new Crypt_RC4($secret_key);

$rc4->decrypt($QueryString);

$QueryString=explode('&',$QueryString);

$response = array();

foreach($QueryString as $param){

$param = split('=',$param);

$response[$param[0]] = $param[1];

}

if (!isset($response['ResponseCode']) || !is_numeric($response['ResponseCode']) || $response['ResponseCode'] != '0') {

 

zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . urlencode(MODULE_PAYMENT_EBS_TEXT_ERROR_MESSAGE), 'SSL', true, false));

 

}

 

}

 

 

 

function after_process() {

 

return false;

 

}

 

 

 

function get_error() {

 

 

 

$error = array('title' => MODULE_PAYMENT_EBS_TEXT_ERROR,

 

'error' => stripslashes(urldecode($_GET['error'])));

 

return $error;

 

}

 

 

 

function check() {

 

global $db;

 

if (!isset($this->_check)) {

 

$check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_PAYMENT_EBS_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 EBS Payment Module', 'MODULE_PAYMENT_EBS_STATUS', 'True', 'Do you want to accept EBS payments?', '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 ('Merchant User ID', 'MODULE_PAYMENT_EBS_ACCOUNTID', '5', 'Your Merchant Account ID of EBS', '5087', '0', now())");

 

$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Secret key', 'MODULE_PAYMENT_EBS_SECRET_KEY', '18157', 'Your secret key of EBS', '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 ('Test Mode', 'MODULE_PAYMENT_EBS_TESTMODE', 'TEST', 'Test mode used for the EBS', '6', '0', 'zen_cfg_select_option(array(\'TEST\', \'LIVE\'), ', 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_EBS_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '2', now())");

 

}

 

 

 

function remove() {

 

global $db;

 

$db->Execute("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");

 

}

 

 

 

function keys() {

 

return array('MODULE_PAYMENT_EBS_STATUS', 'MODULE_PAYMENT_EBS_ACCOUNTID', 'MODULE_PAYMENT_EBS_SECRET_KEY', 'MODULE_PAYMENT_EBS_TESTMODE');

 

}

 

}

 

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.