Welcome Guest, Not a member yet? Register   Sign In
Ebs payment gateway integration in CI - unable to get the response details
#1

[eluser]dev123[/eluser]
Hi ,
Im trying to integrate the ebs payment gateway code in the CI, im using the php-ebs-integration-kit-25
below is the link for the php code
https://support.ebs.in/app/index.php?/de...ion-kit-25
im not able to get the response after the successful submitting

A PHP Error was encountered
Severity: Warning
Message: Division by zero
Filename: libraries/Rc43.php
Line Number: 115

i have created the Rc43 .php inside the library folder below is code which im using,
Code:
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++) {
         [b]   $this->j = ($this->j + $this->s[$this->i] + ord($key[$this->i % $len])) % 256;[/b]
            $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

in controller
require APPPATH . '/libraries/Rc43.php';

Code:
function response() {
        $this->config->load('ebs');
        $key = $this->config->item('secret_key');
        if (isset($_GET['DR'])) {
            $DR = preg_replace("/\s/", "+", $_GET['DR']);
            $rc4 = new Crypt_RC4($key);
             $QueryString = base64_decode($DR);
            $rc4->decrypt($QueryString);
            $QueryString = preg_split('/&/', $QueryString);
            echo '<pre>';
            print_r($QueryString);
          
            $response = array();
            foreach ($QueryString as $param) {
                $param = preg_split('/=/', $param);
                $response[$param[0]] = urldecode($param[1]);
            }
            print_r($response);
       }
    }


#2

[eluser]TheFuzzy0ne[/eluser]
Welcome to the CodeIgniter forums!

What's at line number 115 of ./application/libraries/Rc43.php?

Also, please wrap your code in [code]code tags[/code]. It makes it easier to read. Smile
#3

[eluser]dev123[/eluser]
[quote author="TheFuzzy0ne" date="1365677915"]Welcome to the CodeIgniter forums!

What's at line number 115 of ./application/libraries/Rc43.php?

Also, please wrap your code in [code]code tags[/code]. It makes it easier to read. Smile[/quote]

Thanks for Reply

line number 115 of ./application/libraries/Rc43.php

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

[eluser]TheFuzzy0ne[/eluser]
When that error is being thrown, $len == 0. Fix that, and you'll fix your error. Smile
#5

[eluser]dev123[/eluser]
[quote author="TheFuzzy0ne" date="1365678805"]When that error is being thrown, $len == 0. Fix that, and you'll fix your error. Smile[/quote]

Thanks . Solved

Forgot pass the value in the construct




Theme © iAndrew 2016 - Forum software by © MyBB