Welcome Guest, Not a member yet? Register   Sign In
payment processor and CodeIgniter
#1

[eluser]SPeed_FANat1c[/eluser]
Hi,

I am trying to integrate payment processor to codeigniter application. The code examples of that payment processor are written in pure PHP. I do them in codeigniter style, but if I do everything in CI style, it does not work. If I do partly in CI style it works.

What I do not in CI style is callback function. Callback is called by payment processor server when the money is paid. I simply place callback.php file out of CI directory and it works.

The function from payment processor throws an exception
WebToPayException: Incompatible library and response versions: libwebtopay 1.3.3, response

and before exception there is PHP errors:

A PHP Error was encountered

Severity: Notice
Message: Undefined index: version
Filename: libwebtopay/WebToPay.php
Line Number: 628

and

A PHP Error was encountered

Severity: Notice
Message: Undefined index: version
Filename: libwebtopay/WebToPay.php
Line Number: 631

Here is how this function who throws exceptions looks:
Code:
public static function checkResponse($response, $user_data=array()) {
        self::$verified = false;

        $response = self::getPrefixed($response, self::PREFIX);

        // *get* response type (makro|mikro)
        list($type, $specs) = self::getSpecsForResponse($response);

        try {
            // *check* response
            $version = explode('.', self::VERSION);
            $version = $version[0].'.'.$version[1];
            if ('makro' == $type && $response['version'] != $version) {
                throw new WebToPayException(
                    self::_('Incompatible library and response versions: ' .
                            'libwebtopay %s, response %s', self::VERSION, $response['version']),
                    WebToPayException::E_INVALID);
            }

            if ('makro' == $type && $response['projectid'] != $user_data['projectid']) {
                throw new WebToPayException(
                    self::_('Bad projectid: ' .
                            'libwebtopay %s, response %s', self::VERSION, $response['version']),
                    WebToPayException::E_INVALID);
            }

            if ('makro' == $type) {
                self::$verified = 'RESPONSE VERSION '.$response['version'].' OK';
            }

            $orderid = 'makro' == $type ? $response['orderid'] : $response['id'];
            $password = $user_data['sign_password'];

            // *check* SS2
            if (self::useSS2()) {
                $cert = 'public.key';
                if (self::checkResponseCert($response, $cert)) {
                    self::$verified = 'SS2 public.key';
                }
            }

            // *check* SS1
            else if (self::checkSS1($response, $password, $orderid)) {
                self::$verified = 'SS1';
            }

            // *check* status
            if ('makro' == $type && '1' != $response['status']) {
                throw new WebToPayException(
                    self::_('Returned transaction status is %d, successful status '.
                            'should be 1.', $response['status']),
                    WebToPayException::E_INVALID);
            }

        }

        catch (WebToPayException $e) {
            if (isset($user_data['log'])) {
                self::log('ERR',
                    self::responseToLog($type, $response) .
                    ' ('. get_class($e).': '. $e->getMessage().')',
                    $user_data['log']);
            }
            throw $e;
        }

        if (isset($user_data['log'])) {
            self::log('OK', self::responseToLog($type, $response), $user_data['log']);
        }

        return $response;
    }

Maybe there is problem with $_GET, don't know, I tried $config['enable_query_strings'] = TRUE; but it didn't help.

The question is - is it good practice to just place callback.php somewhere and tell payment server call it directly, without any CI controllers?
#2

[eluser]pickupman[/eluser]
Take a [url="http://stackoverflow.com/questions/2043070/enabling-get-in-codeigniter"]read[/url]. That config value doesn't completely help you as it kills clean urls. There's alot of results on the forums and google for this kind of setup. It would be nice if the payment processors/APIs would you POST instead or offer you the option.
#3

[eluser]skunkbad[/eluser]
I've coded up a few gateway scripts. There's nothing special about doing them. Which gateway are you trying to use?
#4

[eluser]SPeed_FANat1c[/eluser]
I am trying to use https://www.webtopay.com/
Here is the library file if you want to take a look at it http://bitbucket.org/webtopay/libwebtopa...bToPay.php
Here is how to integrate it https://www.webtopay.com/macro_specification.html
but I cannot see the option about using POST.
#5

[eluser]skunkbad[/eluser]
[quote author="SPeed_FANat1c" date="1290606307"]I am trying to use https://www.webtopay.com/
Here is the library file if you want to take a look at it http://bitbucket.org/webtopay/libwebtopa...bToPay.php
Here is how to integrate it https://www.webtopay.com/macro_specification.html
but I cannot see the option about using POST.[/quote]

This isn't like a traditional gateway, but is like the paypal gateway that I made in Community Cart. You might take a look at it and it might help.
#6

[eluser]SPeed_FANat1c[/eluser]
Will take a look later when I finish some tasks, thanks Smile




Theme © iAndrew 2016 - Forum software by © MyBB