Results 1 to 10 of 10
  1. #1
    Join Date
    Jul 2012
    Location
    Kochi,Kerala
    Posts
    58
    Plugin Contributions
    4

    Default Help needed for Creating New Payment Module

    Hi,

    Please find the below Sample given by payment gateway provider, Can anyone give me a rough idea how to create a Module for Zen Cart. I am having little knowledge in PHP


    PHP Code:
    <?php

    function getHash($details){
        
    ksort($details);
        
    $str '';
        foreach (
    $details as $k => $v) {
            if (
    $k != 'hash' && isset($v))     $str .= "$v|";
        }
        
    $str .= "16c08268921b6485617b2f71c4e5ec"// Your secret key goes here. 
        
    return md5($str);
    }
    function 
    main(){
        
    $request_url "https://www.payzippy.com/payment/api/charging/v1"//Charging Url
        
    $details_array = array();
        
    $details_array['merchant_id'] = "test_t152"//Your MID issued by PayZippy.
        
    $details_array['buyer_email_address'] = "[email protected]"// Email Address
        
    $details_array['merchant_transaction_id'] = "MT123ID12345"//Your Transaction Id
        
    $details_array['transaction_type'] = "SALE"//This is the default Value.
        
    $details_array['transaction_amount'] = "10000"//Amount must be in paise. So, 1 Rupee= 100.
        
    $details_array['payment_method'] = "CREDIT"// CREDIT,DEBIT,EMI,NET
        
    $details_array['bank_name'] = ""//Bank Name required in case of EMI/NET.
        
    $details_array['emi_months'] = "0"// Emi Months in case of EMI.
        
    $details_array['currency'] = "INR"//INR is default.
        
    $details_array['ui_mode'] = "REDIRECT"//REDIRECT/IFRAME.
        
    $details_array['hash_method'] = "MD5"//MD5, SHA256
        
    $details_array['merchant_key_id'] = "payment"//This is the default value.
        
    $details_array['timegmt']= round(microtime(true) * 1000);
        
    $details_array['callback_url']="http://localhost";
        
    $details_array['hash'] = getHash($details_array);
        
        
        
    $request_url_to_be_hit  $request_url."?".http_build_query($details_array);
        
    print_r($request_url_to_be_hit); //This url printed needs to be redirected or put in iframe 

    as the case may be.
    }

    main();
    ?>

  2. #2
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,399
    Plugin Contributions
    87

    Default Re: Help needed for Creating New Payment Module

    Start by reviewing the linkpoint*.php files in /includes/modules/payment. They're much less complicated than the PayPal ones. Get a (free) linkpoint developer account so that you can see how the linkpoint module interacts with Zen Cart. Model your payment-provider's interface in a similar manner.

  3. #3
    Join Date
    Jul 2012
    Location
    Kochi,Kerala
    Posts
    58
    Plugin Contributions
    4

    Default Re: Help needed for Creating New Payment Module

    Hi,

    I just managed to write the Module but error Happens when hashing the values and passing to Payment gateway, I don't what went wrong

    as per Payment Gateway provider we need to generate hash as


    merchant_id=test_merchant
    merchant_key_id=payment
    hash_method=MD5
    hash=ignore_this
    merchant_transaction_id=MT123
    transaction_amount=100
    currency=INR
    transaction_type=SALE
    buyer_phone_no=9999999999
    [email protected]
    ui_mode=IFRAME
    payment_method=CREDIT

    1. ignore Hash as a parameter and sort all the request parameters by their key (not value).
    2. concatenate all values of the sorted keys of parameters with pipe - ‘|’ character.


    Like this
    str = [email protected]|9999999999|INR|SHA256|test_merchant|payment|MT123|CREDIT|100|SAL E|IFRAME|asdflkafuq347riuvgyrgfbwqbvq
    hash = MD5(str);

    3.Now, use this "hash" and pass it along to the API. Your call is authenticated and PayZippy passes the results of the API back to you.

    Code I Used is

    Code:
    <?php
    class payzippy extends base
    {
      var $code, $title, $description, $enabled;
      // class constructor
      function payzippy()
      {
        $this->code = 'payzippy';
        $this->title = MODULE_PAYMENT_PAYZIPPY_TEXT_TITLE;
        $this->description = MODULE_PAYMENT_PAYZIPPY_TEXT_DESCRIPTION;
        $this->sort_order = MODULE_PAYMENT_PAYZIPPY_SORT_ORDER;
        $this->enabled = ((MODULE_PAYMENT_PAYZIPPY_STATUS == 'True') ? true : false);
        if ((int)MODULE_PAYMENT_PAYZIPPY_ORDER_STATUS_ID > 0) {
          $this->order_status = MODULE_PAYMENT_PAYZIPPY_ORDER_STATUS_ID;
        }
        if (is_object($order)) $this->update_status();
     	$this->form_action_url = 'https://www.payzippy.com/payment/api/charging/v1';
    	//$this->form_action_url = 'http://www.prabhusbooks.com/TESTCAPTURE.PHP';
      }
      // class methods
      function update_status()
      {
        global $order, $db;
        if (($this->enabled == true) && ((int)MODULE_PAYMENT_PAYZIPPY_ZONE > 0)) {
          $check_flag = false;
          $check_query = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_PAYMENT_PAYZIPPY_ZONE . "' and zone_country_id = '" . $order->delivery['country']['id'] . "' order by zone_id");
          while ($check = mysql_fetch_array($check_query)) {
            if ($check['zone_id'] < 1) {
              $check_flag = true;
              break;
            } elseif ($check['zone_id'] == $order->delivery['zone_id']) {
              $check_flag = true;
              break;
            }
          }
          if ($check_flag == false) {
            $this->enabled = false;
          }
        }
        // disable the module if the order only contains virtual products
        if ($this->enabled == true) {
          if ($order->content_type == 'virtual') {
            $this->enabled = false;
          }
        }
      }
    
      function javascript_validation()
      {
        return false;
      }
    
      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;
        if (MODULE_PAYMENT_PAYZIPPY_CONVERSION == 'Enabled'){
        if (DEFAULT_CURRENCY <> 'INR'){
           $cOrderTotal = $currencies->get_value("INR") * $order->info['total'];
        }
     } else {
      $cOrderTotal = $order->info['total'];
     }
        $MerchantId=MODULE_PAYMENT_PAYZIPPY_LOGIN;
    	$Merchantkeyid=MODULE_PAYMENT_PAYZIPPY_KEY_ID;
        $Amount = $cOrderTotal;
        $currencyType = "INR";
        $OrderId = $_SESSION['customer_id'] . '-' . date('Ymdhis');
        $Url = zen_href_link(FILENAME_CHECKOUT_PROCESS, '', 'SSL', true, false);
    	
        
            	$billing_address=$order->customer['street_address'];
    			$billing_city=$order->customer['city'];
    			$billing_country=$order->customer['country']['title'];
    			$billing_name=$order->customer['firstname'] . ' ' . $order->customer['lastname'];
    			$billing_state=$order->customer['state'];
    			$billing_zip=$order->customer['postcode'];
    			$buyer_email_address=$order->customer['email_address'];
    			$buyer_phone_no=$order->customer['telephone'];
    			$callback_url=$Url;
    			$currency=$currencyType;
    			$hash_method="MD5";
    			$merchant_id=$MerchantId;
    			$merchant_key_id=MODULE_PAYMENT_PAYZIPPY_KEY_ID;
    			$merchant_transaction_id=$OrderId;
    			$payment_method="CREDIT";
    			$timegmt=round(microtime(true) * 1000);
    			$transaction_amount=$order->info['total'];
    			$transaction_type="SALE";
    			$ui_mode="REDIRECT";
    			$hash=MODULE_PAYMENT_PAYZIPPY_KEY;
    			$WorkingKey="$billing_address|$billing_city|$billing_country|$billing_name|$billing_state|$billing_zip|$buyer_email_address|$buyer_phone_no|$callback_url|$currency|$hash_method|$merchant_id|$merchant_key_id|$merchant_transaction_id|$payment_method|$transaction_amount|$transaction_type|$ui_mode|$hash";
    		$hashed=md5($WorkingKey);
        //Variables to be passed to Payzippy as a POST  
        
    
    
    	$process_button_string =zen_draw_hidden_field('billing_address',$billing_address) .
    							zen_draw_hidden_field('billing_city',$billing_city) .
    							zen_draw_hidden_field('billing_country',$billing_country) .
    							zen_draw_hidden_field('billing_name',$billing_name) .
    							zen_draw_hidden_field('billing_state',$billing_state) .
    							zen_draw_hidden_field('billing_zip',$billing_zip) .
    							zen_draw_hidden_field('buyer_email_address', $buyer_email_address) . // Email Address
    							zen_draw_hidden_field('buyer_phone_no',$buyer_phone_no) .
    							zen_draw_hidden_field('callback_url',$callback_url) .
    							zen_draw_hidden_field('currency', $currency) . //INR is default.
    							zen_draw_hidden_field('hash_method', $hash_method) . //MD5, SHA256
    							zen_draw_hidden_field('merchant_id',$merchant_id) . //Your MID issued by PayZippy.
    							zen_draw_hidden_field('merchant_key_id', $merchant_key_id) . //This is the default value.
    							zen_draw_hidden_field('merchant_transaction_id', $merchant_transaction_id) . //Your Transaction Id
    							zen_draw_hidden_field('payment_method', $payment_method) . // CREDIT,DEBIT,EMI,NET
    							zen_draw_hidden_field('transaction_amount', $transaction_amount) . //Amount must be in paise. So, 1 Rupee= 100.
    							zen_draw_hidden_field('transaction_type', $transaction_type) . //This is the default Value.
    							zen_draw_hidden_field('ui_mode', $ui_mode) . //REDIRECT/IFRAME.
    							zen_draw_hidden_field('hash',$hashed);
    						//echo $process_button_string;
    							
    							return $process_button_string;
        
      }
    
      function before_process()
      {
        global $messageStack;
        $bank_name =  $_GET['bank_name'];
    	$fraud_action=  $_GET['fraud_action'];
    	$fraud_details=  $_GET['fraud_details'];
    	$hash_method=  $_GET['hash_method'];
    	$is_international=  $_GET['is_international'];
    	$merchant_id=  $_GET['merchant_id'];
    	$merchant_key_id=  $_GET['merchant_key_id'];
    	$merchant_transaction_id=  $_GET['merchant_transaction_id'];
    	$payment_method=  $_GET['payment_method'];
    	$payzippy_transaction_id=  $_GET['payzippy_transaction_id'];
    	$transaction_amount=  $_GET['transaction_amount'];
    	$transaction_currency=  $_GET['transaction_currency'];
    	$transaction_response_code=  $_GET['transaction_response_code'];
    	$transaction_response_message=  $_GET['transaction_response_message'];
    	$transaction_status=  $_GET['transaction_status'];
    	$transaction_time=  $_GET['transaction_time'];
    	$transaction_type=  $_GET['transaction_type'];
    	$udf1=  $_GET['udf1'];
    	$udf2=  $_GET['udf2'];
    	$udf3=  $_GET['udf3'];
    	$udf4=  $_GET ['udf4'];
    	$udf5=  $_GET['udf5'];
    	$version=  $_GET['version'];
    	$hash=MODULE_PAYMENT_PAYZIPPY_KEY;
    	$AuthDesc=$_GET['transaction_status'];
    	$recievedhash=$_GET['hash'];
    	$WorkingKey="$bank_name|$fraud_action|$fraud_details|$hash_method|$is_international|$merchant_id|$merchant_key_id|$merchant_transaction_id|$payment_method|$payzippy_transaction_id|$transaction_amount|$transaction_currency|$transaction_response_code|$transaction_response_message|$transaction_status|$transaction_time|$transaction_type|$udf1|$udf2|$udf3|$udf4|$udf5|$version|$hash";
    	$Checksum=md5($WorkingKey);
        if (recievedhash == $Checksum)
          $Checksum = 'true';
        else
          $Checksum = 'false';
        if ($Checksum != 'true') {
          $messageStack->add_session('checkout_payment', MODULE_PAYMENT_PAYZIPPY_ALERT_ERROR_MESSAGE, 'error');
          zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL', true, false));
        }
        if ($Checksum == 'true' && $AuthDesc == 'FAILED') {
          $messageStack->add_session('checkout_payment', MODULE_PAYMENT_PAYZIPPY_ALERT_ERROR_MESSAGE, 'error');
          zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL', true, false));
        }
    	if ($Checksum == 'true' && $AuthDesc == 'PENDING') {
          $messageStack->add_session('checkout_payment', MODULE_PAYMENT_PAYZIPPY_ALERT_ERROR_MESSAGE, 'error');
          zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL', true, false));
        }
      }
    
      function after_process()
      {
        return false;
      }
    
      function output_error()
      {
        $output_error_string = '<table border="0" cellspacing="0" cellpadding="0" width="100%">' . "\n" . '  <tr>' . "\n" . '    <td class="main">&nbsp;<font color="#FF0000"><b>' . MODULE_PAYMENT_PAYZIPPY_TEXT_ERROR . '</b></font><br>&nbsp;' . MODULE_PAYMENT_PAYZIPPY_ALERT_ERROR_MESSAGE . '&nbsp;</td>' . "\n" . '  </tr>' . "\n" . '</table>' . "\n";
        return $output_error_string;
      }
    
      function check()
      {
        global $db;
        if (! isset($this->_check)) {
          $check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_PAYMENT_PAYZIPPY_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 payzippy Module', 'MODULE_PAYMENT_PAYZIPPY_STATUS', 'True', 'Do you want to accept payzippy 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 ('Merchant_Id', 'MODULE_PAYMENT_PAYZIPPY_LOGIN', 'Your_PAYZIPPY_ID', 'Merchant ID used for the payzippy 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 ('Sort order of display.', 'MODULE_PAYMENT_PAYZIPPY_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '5', 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_PAYZIPPY_ZONE', '0', 'If a zone is selected, only enable this payment method for that zone.', '6', '6', '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_PAYZIPPY_ORDER_STATUS_ID', '0', 'Set the status of orders made with this payment module to this value', '6', '7', 'zen_cfg_pull_down_order_statuses(', 'zen_get_order_status_name', 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 ('Currency Converter', 'MODULE_PAYMENT_PAYZIPPY_CONVERSION', 'Enabled', 'Currency Conversion', '6', '10', 'zen_cfg_select_option(array(\'Enabled\', \'Disable\'), ', now())");     
    	  $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Working_Key', 'MODULE_PAYMENT_PAYZIPPY_KEY', 'Working_Key', 'put in the  alphanumeric key from Payzippy', '6', '3', now())");
    	  $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Merchant_Key_Id', 'MODULE_PAYMENT_PAYZIPPY_KEY_ID', 'Merchant_Key_Id', 'Given Merchant Key Id', '6', '3', now())");
        }
    
       function remove() {
    	global $db;
           $db->Execute("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
       }
    
    
      function keys() {
         return array('MODULE_PAYMENT_PAYZIPPY_STATUS', 'MODULE_PAYMENT_PAYZIPPY_LOGIN','MODULE_PAYMENT_PAYZIPPY_KEY', 'MODULE_PAYMENT_PAYZIPPY_ZONE', 'MODULE_PAYMENT_PAYZIPPY_ORDER_STATUS_ID', 'MODULE_PAYMENT_PAYZIPPY_SORT_ORDER', 'MODULE_PAYMENT_PAYZIPPY_CONVERSION','MODULE_PAYMENT_PAYZIPPY_KEY_ID');
       }
     }
    
    ?>
    When Tried using above code
    Response I got is

    http://mysite.com/index.php?main_pag...ey_id=payment&transaction_response_code=MERCHANT_AUTH_FAILED&bank_name=NULL&hash=44f2df01322ca0b830d9642f96e0170e&transaction_type=SALE&
    transaction_response_message=PayZippy+was+unable+to+authenticate+the+request+due +to+hash+mismatch&version=C&payzippy_transaction_id=PZT13082711535017621&transaction_status=FAILE D&hash_method=MD5&fraud_action=no_decision&merchant_transaction_id=1-20130827062433&transaction_amount=70500&is_international=false&fraud_details=No+ fraud+status+obtained&merchant_id=test_t190&payment_method=CREDIT

    Pleaseeeeee help

  4. #4
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,399
    Plugin Contributions
    87

    Default Re: Help needed for Creating New Payment Module

    In the example you gave in your first post, the payment provider's sample code contains:
    Code:
    $details_array['merchant_id'] = "test_t152"; //Your MID issued by PayZippy.
        $details_array['buyer_email_address'] = "[email protected]"; // Email Address
        $details_array['merchant_transaction_id'] = "MT123ID12345"; //Your Transaction Id
        $details_array['transaction_type'] = "SALE"; //This is the default Value.
        $details_array['transaction_amount'] = "10000"; //Amount must be in paise. So, 1 Rupee= 100.
        $details_array['payment_method'] = "CREDIT"; // CREDIT,DEBIT,EMI,NET
        $details_array['bank_name'] = ""; //Bank Name required in case of EMI/NET.
        $details_array['emi_months'] = "0"; // Emi Months in case of EMI.
        $details_array['currency'] = "INR"; //INR is default.
        $details_array['ui_mode'] = "REDIRECT"; //REDIRECT/IFRAME.
        $details_array['hash_method'] = "MD5"; //MD5, SHA256
        $details_array['merchant_key_id'] = "payment"; //This is the default value.
        $details_array['timegmt']= round(microtime(true) * 1000);
        $details_array['callback_url']="http://localhost";
    This implies to me that it is only these fields that should be in the hash calculation and that the fields should be added to the value-to-be-hashed in the (top-to-bottom) order that they appear in the details_array.

  5. #5
    Join Date
    Jul 2012
    Location
    Kochi,Kerala
    Posts
    58
    Plugin Contributions
    4

    Default Re: Help needed for Creating New Payment Module

    Hi ,


    I have Tried the same only with mandatory fields even then same error is showing,

    I think that I have done something wrong in the Code, I am a just a beginner in PHP

  6. #6
    Join Date
    Jul 2012
    Location
    Kochi,Kerala
    Posts
    58
    Plugin Contributions
    4

    Default Re: Help needed for Creating New Payment Module

    Additionally I nave Tried with CCavenue Payment Gateway, Its also showing Error Code: 108
    Error Description: Checksum+mismatch


    am using CCavenue module updated by @DrByte

    Is is it a Problem of Hosting Provider or I need to enable any PHP Module ????

    Any help is highly Appreciated

  7. #7
    Join Date
    Jul 2012
    Location
    Kochi,Kerala
    Posts
    58
    Plugin Contributions
    4

    Default Re: Help needed for Creating New Payment Module

    Hi all,

    Pleaseeeeeee help me

    is there any mitake in this process, I am getting White Screen and no Debug information
    PHP Code:
    function before_process()
      {
        global 
    $messageStack;
        
    $merchantId $_POST['merchant_id'];
        
    $merchant_key_id $_POST['merchant_key_id'];
        
    $merchant_transaction_id $_POST['merchant_transaction_id'];
        
    $payzippy_transaction_id $_POST['payzippy_transaction_id'];
        
    $transaction_status $_POST['transaction_status'];
        
    $transaction_response_code $_POST['transaction_response_code'];
        
    $transaction_response_message $_POST['transaction_response_message'];
        
    $payment_method $_POST['payment_method'];
        
    $bank_name $_POST['bank_name'];
        
    $emi_months $_POST['emi_months'];
        
    $transaction_amount $_POST['transaction_amount'];
        
    $transaction_currency $_POST['transaction_currency'];
        
    $transaction_time $_POST['transaction_time'];
        
    $fraud_action $_POST['fraud_action'];
        
    $fraud_details $_POST['fraud_details'];
        
    $is_international $_POST['is_international'];
        
    $version $_POST['version'];
        
    $udf1 $_POST['udf1'];
        
    $udf2 $_POST['merchant_id'];
        
    $udf3 $_POST['udf3'];
        
    $udf4 $_POST['udf4'];
        
    $udf5 $_POST['udf5'];
        
    $hash_method $_POST['hash_method'];
        
    $hash$_POST['hash'];
        
    $securitykey=MODULE_PAYMENT_PAYZIPPY_KEY;
        
    $AuthDesc=$_POST['transaction_status'];
        
    $recievedhash=$_POST['hash'];

    $Workingstring="$bank_name|$emi_months|$fraud_action|$fraud_details|$hash|$hash_method|$is_international|$merchant_key_id|$merchant_transaction_id|$MerchantId|$payment_method|$payzippy_transaction_id|$transaction_amount|$transaction_currency|$transaction_response_code|$transaction_response_message|$transaction_status|$transaction_time|$udf1|$udf2|$udf3|$udf4|$udf5|$version|$securitykey";
    //Generate hash
       
    $Checksum=md5($Workingstring);


    if (
    $recievedhash == $Checksum)
          
    $Checksum 'true';
        else
          
    $Checksum 'false';
        if (
    $Checksum != 'true') {
          
    $messageStack->add_session('checkout_payment'MODULE_PAYMENT_PAYZIPPY_ALERT_ERROR_MESSAGE'error');
          
    zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT'''SSL'truefalse));
        }
        if (
    $Checksum == 'true' && $AuthDesc == 'FAILED') {
          
    $messageStack->add_session('checkout_payment'MODULE_PAYMENT_PAYZIPPY_TEXT_ERROR_MESSAGE'error');
          
    zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT'''SSL'truefalse));
        }
      } 

  8. #8
    Join Date
    Jul 2012
    Location
    Kochi,Kerala
    Posts
    58
    Plugin Contributions
    4

    Default Help needed on New Payment Module before process function

    Hi all

    Pls help me

    am getting white screen after confirmation from payment gateway(New Payment Gateway)

    My Before process code is given pls help me

    My response from Gateway is

    HTML Code:
    http://localhost/payzippy_response.php?transaction_currency=INR&transaction_time=2013-08-29+16%3A28%3A42&transaction_response_code=SUCCESS&merchant_key_id=payment&bank_name=NULL&hash=19906f6d691936387368d50b9d82970d&transaction_type=SALE&transaction_response_message=The+transaction+is+successful&version=Cv1&udf2=&udf1=&transaction_status=SUCCESS&payzippy_transaction_id=PZT13082916284265345&hash_method=MD5&merchant_transaction_id=1-20130829105840&udf5=&fraud_action=review&udf4=&transaction_amount=70500&is_international=false&udf3=&fraud_details=[Suspected+txn+by+extended+international+check]&merchant_id=test_t190&payment_method=CREDIT

    PHP Code:

    function before_process()
      {
        global 
    $messageStack;
        
    $merchantId $_POST['merchant_id'];
        
    $merchant_key_id $_POST['merchant_key_id'];
        
    $merchant_transaction_id $_POST['merchant_transaction_id'];
        
    $payzippy_transaction_id $_POST['payzippy_transaction_id'];
        
    $transaction_status $_POST['transaction_status'];
        
    $transaction_response_code $_POST['transaction_response_code'];
        
    $transaction_response_message $_POST['transaction_response_message'];
        
    $payment_method $_POST['payment_method'];
        
    $bank_name $_POST['bank_name'];
        
    $emi_months $_POST['emi_months'];
        
    $transaction_amount $_POST['transaction_amount'];
        
    $transaction_currency $_POST['transaction_currency'];
        
    $transaction_time $_POST['transaction_time'];
        
    $fraud_action $_POST['fraud_action'];
        
    $fraud_details $_POST['fraud_details'];
        
    $is_international $_POST['is_international'];
        
    $version $_POST['version'];
        
    $udf1 $_POST['udf1'];
        
    $udf2 $_POST['merchant_id'];
        
    $udf3 $_POST['udf3'];
        
    $udf4 $_POST['udf4'];
        
    $udf5 $_POST['udf5'];
        
    $hash_method $_POST['hash_method'];
    $recievedhash=$_POST['hash'];
        
    $securitykey=MODULE_PAYMENT_PAYZIPPY_KEY;
        
    $AuthDesc=$_POST['transaction_status'];
        

    $Workingstring="$bank_name|$emi_months|$fraud_action|$fraud_details|$hash|$hash_method|$is_international|$merchant_key_id|$merchant_transaction_id|$MerchantId|$payment_method|$payzippy_transaction_id|$transaction_amount|$transaction_currency|$transaction_response_code|$transaction_response_message|$transaction_status|$transaction_time|$udf1|$udf2|$udf3|$udf4|$udf5|$version|$securitykey";
       
       
    $Checksum=md5($Workingstring);


        if (
    $recievedhash == $Checksum)
          
    $Checksum 'true';
        else
          
    $Checksum 'false';
        if (
    $Checksum != 'true') {
          
    $messageStack->add_session('checkout_payment'MODULE_PAYMENT_PAYZIPPY_ALERT_ERROR_MESSAGE'error');
          
    zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT'''SSL'truefalse));
        }
        if (
    $Checksum == 'true' && $AuthDesc == 'FAILED') {
          
    $messageStack->add_session('checkout_payment'MODULE_PAYMENT_PAYZIPPY_TEXT_ERROR_MESSAGE'error');
          
    zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT'''SSL'truefalse));
        }
      } 

  9. #9
    Join Date
    Jul 2012
    Location
    Kochi,Kerala
    Posts
    58
    Plugin Contributions
    4

    Default Re: Help needed on New Payment Module before process function

    hi, Please find the Entire code and Help me to finish the Module

    Problem is Order is not Generated even successful response from payment gateway

    Response got is

    Code:
     http://www.mysite.com/payzippy_response.php?transaction_currency=INR&transaction_time=2013-08-29+23%3A35%3A22&transaction_response_code=SUCCESS&merchant_key_id=payment&bank_name=NULL&hash=9801bcf830144f2fc9588520b1d35d6d&transaction_type=SALE&transaction_response_message=The+transaction+is+successful&version=Cv1&udf2=&udf1=&transaction_status=SUCCESS&payzippy_transaction_id=PZT13082923352234844&hash_method=MD5&merchant_transaction_id=1-20130829060520&udf5=&fraud_action=review&udf4=&transaction_amount=70500&is_international=false&udf3=&fraud_details=%5B6+success+mid-value+txns+on+this+day%2C+Fraud+level+reduced+as+suspected+fraud+by+only+one+detector%2C+Suspected+txn+by+extended+international+check%5D&merchant_id=test_t190&payment_method=CREDIT
    PHP Code:
    <?php
    class payzippy extends base
    {
      var 
    $code$title$description$enabled;
      
    // class constructor
      
    function payzippy()
      {
        
    $this->code 'payzippy';
        
    $this->title MODULE_PAYMENT_PAYZIPPY_TEXT_TITLE;
        
    $this->description MODULE_PAYMENT_PAYZIPPY_TEXT_DESCRIPTION;
        
    $this->sort_order MODULE_PAYMENT_PAYZIPPY_SORT_ORDER;
        
    $this->enabled = ((MODULE_PAYMENT_PAYZIPPY_STATUS == 'True') ? true false);
        if ((int)
    MODULE_PAYMENT_PAYZIPPY_ORDER_STATUS_ID 0) {
          
    $this->order_status MODULE_PAYMENT_PAYZIPPY_ORDER_STATUS_ID;
        }
        if (
    is_object($order)) $this->update_status();
    $this->form_action_url 'https://www.payzippy.com/payment/api/charging/v1';
        
      }
      
    // class methods
      
    function update_status()
      {
        global 
    $order$db;
        if ((
    $this->enabled == true) && ((int)MODULE_PAYMENT_PAYZIPPY_ZONE 0)) {
          
    $check_flag false;
          
    $check_query $db->Execute("select zone_id from " TABLE_ZONES_TO_GEO_ZONES " where geo_zone_id = '" MODULE_PAYMENT_PAYZIPPY_ZONE "' and zone_country_id = '" $order->delivery['country']['id'] . "' order by zone_id");
          while (
    $check mysql_fetch_array($check_query)) {
            if (
    $check['zone_id'] < 1) {
              
    $check_flag true;
              break;
            } elseif (
    $check['zone_id'] == $order->delivery['zone_id']) {
              
    $check_flag true;
              break;
            }
          }
          if (
    $check_flag == false) {
            
    $this->enabled false;
          }
        }
        
    // disable the module if the order only contains virtual products
        
    if ($this->enabled == true) {
          if (
    $order->content_type == 'virtual') {
            
    $this->enabled false;
          }
        }
      }

      function 
    javascript_validation()
      {
        return 
    false;
      }

      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;
        if (
    MODULE_PAYMENT_PAYZIPPY_CONVERSION == 'Enabled'){
        if (
    DEFAULT_CURRENCY <> 'INR'){
           
    $cOrderTotal $currencies->get_value("INR") * $order->info['total'];
        }
     } else {
      
    $cOrderTotal $order->info['total'];
     }
        
    $MerchantId=MODULE_PAYMENT_PAYZIPPY_LOGIN;
        
    $Merchantkeyid=MODULE_PAYMENT_PAYZIPPY_KEY_ID;
        
    $Amount $cOrderTotal;
        
    $currencyType "INR";
        
    $OrderId $_SESSION['customer_id'] . '-' date('Ymdhis');
      
    $Url zen_href_link(FILENAME_CHECKOUT_PROCESS,'','SSL',true,false);
        
        
        
                
    $billing_address=$order->customer['street_address'];
                
    $billing_city=$order->customer['city'];
                
    $billing_country=$order->customer['country']['title'];
                
    $billing_name=$order->customer['firstname'].' '.$order->customer['lastname'];
                
    $billing_state=$order->customer['state'];
                
    $billing_zip=$order->customer['postcode'];
                
    $buyer_email_address=$order->customer['email_address'];
                
    $buyer_phone_no=$order->customer['telephone'];
                
    $callback_url=$Url;
                
    $currency=$currencyType;
                
    $hash_method="MD5";
                
    $merchant_id=$MerchantId;
                
    $merchant_key_id=MODULE_PAYMENT_PAYZIPPY_KEY_ID;
                
    $merchant_transaction_id=$OrderId;
                
    $payment_method="CREDIT";
                
    $transaction_amount=$Amount*100;
                
    $transaction_type="SALE";
                
    $securityToken=$_SESSION['securityToken'];
                
    $ui_mode="REDIRECT";
                
    $hash=MODULE_PAYMENT_PAYZIPPY_KEY;
                
    $WorkingKey="$billing_address|$billing_city|$billing_country|$billing_name|$billing_state|$billing_zip|$buyer_email_address|$buyer_phone_no|$callback_url|$currency|$hash_method|$merchant_id|$merchant_key_id|$merchant_transaction_id|$payment_method|$securityToken|$transaction_amount|$transaction_type|$ui_mode|$hash";
            
    $hashed=md5($WorkingKey);
        
    //Variables to be passed to Payzippy as a POST  
        


        
    $process_button_string =zen_draw_hidden_field('billing_address',$billing_address) .
                                
    zen_draw_hidden_field('billing_city',$billing_city) .
                                
    zen_draw_hidden_field('billing_country',$billing_country) .
                                
    zen_draw_hidden_field('billing_name',$billing_name) .
                                
    zen_draw_hidden_field('billing_state',$billing_state) .
                                
    zen_draw_hidden_field('billing_zip',$billing_zip) .
                                
    zen_draw_hidden_field('buyer_email_address'$buyer_email_address) . // Email Address
                                
    zen_draw_hidden_field('buyer_phone_no',$buyer_phone_no) .
                                
    zen_draw_hidden_field('callback_url',$callback_url) .
                                
    zen_draw_hidden_field('currency'$currency) . //INR is default.
                                
    zen_draw_hidden_field('hash_method'$hash_method) . //MD5, SHA256
                                
    zen_draw_hidden_field('merchant_id',$merchant_id) . //Your MID issued by PayZippy.
                                
    zen_draw_hidden_field('merchant_key_id'$merchant_key_id) . //This is the default value.
                                
    zen_draw_hidden_field('merchant_transaction_id'$merchant_transaction_id) . //Your Transaction Id
                                
    zen_draw_hidden_field('payment_method'$payment_method) . // CREDIT,DEBIT,EMI,NET
                                
    zen_draw_hidden_field('transaction_amount'$transaction_amount) . //Amount must be in paise. So, 1 Rupee= 100.
                                
    zen_draw_hidden_field('transaction_type'$transaction_type) . //This is the default Value.
                                
    zen_draw_hidden_field('ui_mode'$ui_mode) . //REDIRECT/IFRAME.
                                
    zen_draw_hidden_field('hash',$hashed);
                            
    //echo $process_button_string;
                                
                                
    return $process_button_string;
        
      }

      function 
    before_process()
      {
      
        global 
    $messageStack$HTTP_POST_VARS;
        
    $bank_name =  $_REQUEST['bank_name'];
        
    $fraud_action =  $_REQUEST['fraud_action'];
        
    $fraud_details =  $_REQUEST['fraud_details'];
        
    $hash_method =  $_REQUEST['hash_method'];
        
    $is_international =  $_REQUEST['is_international'];
        
    $merchant_id =  $_REQUEST['merchant_id'];
        
    $merchant_key_id =  $_REQUEST['merchant_key_id'];
        
    $merchant_transaction_id =  $_REQUEST['merchant_transaction_id'];
        
    $payment_method =  $_REQUEST['payment_method'];
        
    $payzippy_transaction_id =  $_REQUEST['payzippy_transaction_id'];
        
    $transaction_amount =  $_REQUEST['transaction_amount'];
        
    $transaction_currency =  $_REQUEST['transaction_currency'];
        
    $transaction_response_code =  $_REQUEST['transaction_response_code'];
        
    $transaction_response_message =  $_REQUEST['transaction_response_message'];
        
    $transaction_status =  $_REQUEST['transaction_status'];
        
    $transaction_time =  $_REQUEST['transaction_time'];
        
    $transaction_type =  $_REQUEST['transaction_type'];
        
    $udf1 =  $_REQUEST['udf1'];
        
    $udf2 =  $_REQUEST['udf2'];
        
    $udf3 =  $_REQUEST['udf3'];
        
    $udf4 =  $_REQUEST ['udf4'];
        
    $udf5 =  $_REQUEST['udf5'];
        
    $version =  $_REQUEST['version'];
        
    $hash MODULE_PAYMENT_PAYZIPPY_KEY;
        
    $AuthDesc=$_REQUEST['transaction_status'];
        
    $recievedhash=$_REQUEST['hash'];
        
    $Workingstring="$bank_name|$fraud_action|$fraud_details|$hash_method|$is_international|$merchant_id|$merchant_key_id|$merchant_transaction_id|$payment_method|$payzippy_transaction_id|$transaction_amount|$transaction_currency|$transaction_response_code|$transaction_response_message|$transaction_status|$transaction_time|$transaction_type|$udf1|$udf2|$udf3|$udf4|$udf5|$version|$hash";
        
    $Checksum=md5($Workingstring);
            
    /*if ($recievedhash == $Checksum)
          $Checksum = 'true';
        else
          $Checksum = 'false';*/
          
        
    if ($Checksum != $recievedhash) {
          
    $messageStack->add_session('checkout_payment'MODULE_PAYMENT_PAYZIPPY_ALERT_ERROR_MESSAGE'error');
          
    zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT'''SSL'truefalse));
        }
        if (
    $Checksum == $recievedhash && $AuthDesc == 'FAILED') {
          
    $messageStack->add_session('checkout_payment'MODULE_PAYMENT_PAYZIPPY_ALERT_ERROR_MESSAGE'error');
          
    zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT'''SSL'truefalse));
        }
        if (
    $Checksum == $recievedhash && $AuthDesc == 'PENDING') {
          
    $messageStack->add_session('checkout_payment'MODULE_PAYMENT_PAYZIPPY_ALERT_ERROR_MESSAGE'error');
          
    zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT'''SSL'truefalse));
        }
        
      }

      function 
    after_process()
      {
        return 
    false;
      }

      function 
    output_error()
      {
        
    $output_error_string '<table border="0" cellspacing="0" cellpadding="0" width="100%">' "\n" '  <tr>' "\n" '    <td class="main">&nbsp;<font color="#FF0000"><b>' MODULE_PAYMENT_PAYZIPPY_TEXT_ERROR '</b></font><br>&nbsp;' MODULE_PAYMENT_PAYZIPPY_ALERT_ERROR_MESSAGE '&nbsp;</td>' "\n" '  </tr>' "\n" '</table>' "\n";
        return 
    $output_error_string;
      }

      function 
    check()
      {
        global 
    $db;
        if (! isset(
    $this->_check)) {
          
    $check_query $db->Execute("select configuration_value from " TABLE_CONFIGURATION " where configuration_key = 'MODULE_PAYMENT_PAYZIPPY_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 payzippy Module', 'MODULE_PAYMENT_PAYZIPPY_STATUS', 'True', 'Do you want to accept payzippy 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 ('Merchant_Id', 'MODULE_PAYMENT_PAYZIPPY_LOGIN', 'Your_PAYZIPPY_ID', 'Merchant ID used for the payzippy 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 ('Sort order of display.', 'MODULE_PAYMENT_PAYZIPPY_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '5', 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_PAYZIPPY_ZONE', '0', 'If a zone is selected, only enable this payment method for that zone.', '6', '6', '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_PAYZIPPY_ORDER_STATUS_ID', '0', 'Set the status of orders made with this payment module to this value', '6', '7', 'zen_cfg_pull_down_order_statuses(', 'zen_get_order_status_name', 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 ('Currency Converter', 'MODULE_PAYMENT_PAYZIPPY_CONVERSION', 'Enabled', 'Currency Conversion', '6', '10', 'zen_cfg_select_option(array(\'Enabled\', \'Disable\'), ', now())");     
          
    $db->Execute("insert into " TABLE_CONFIGURATION " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Working_Key', 'MODULE_PAYMENT_PAYZIPPY_KEY', 'Working_Key', 'put in the  alphanumeric key from Payzippy', '6', '3', now())");
          
    $db->Execute("insert into " TABLE_CONFIGURATION " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Merchant_Key_Id', 'MODULE_PAYMENT_PAYZIPPY_KEY_ID', 'Merchant_Key_Id', 'Given Merchant Key Id', '6', '3', now())");
        }

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


      function 
    keys() {
         return array(
    'MODULE_PAYMENT_PAYZIPPY_STATUS''MODULE_PAYMENT_PAYZIPPY_LOGIN','MODULE_PAYMENT_PAYZIPPY_KEY''MODULE_PAYMENT_PAYZIPPY_ZONE''MODULE_PAYMENT_PAYZIPPY_ORDER_STATUS_ID''MODULE_PAYMENT_PAYZIPPY_SORT_ORDER''MODULE_PAYMENT_PAYZIPPY_CONVERSION','MODULE_PAYMENT_PAYZIPPY_KEY_ID');
       }
     }

    ?>

  10. #10
    Join Date
    Jul 2012
    Location
    Kochi,Kerala
    Posts
    58
    Plugin Contributions
    4

    Default Re: Help needed on New Payment Module before process function

    Dear Admin,


    Please delete this entire Thread as it contains some data which will cause issues with payment service provider

    Hence I request you to please delete this Entire Thread

    Regds
    Vinod

 

 

Similar Threads

  1. Help needed for writting payment module
    By andes in forum General Questions
    Replies: 6
    Last Post: 16 Jul 2009, 02:11 PM
  2. Creating New Payment Module
    By The One in forum Built-in Shipping and Payment Modules
    Replies: 0
    Last Post: 12 Jun 2009, 05:07 PM
  3. Help needed for a zen cart redirection payment module...
    By angeloio in forum Addon Payment Modules
    Replies: 0
    Last Post: 10 Jun 2009, 06:54 AM
  4. Help needed config new payment module
    By nicojanssis in forum Built-in Shipping and Payment Modules
    Replies: 1
    Last Post: 23 May 2008, 01:03 AM
  5. Creating a new payment module...
    By tehbadseed in forum Built-in Shipping and Payment Modules
    Replies: 1
    Last Post: 14 Feb 2008, 01:51 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