Problems with Cielo Library and communication with Codeigniter

Asked

Viewed 331 times

1

I am implementing the communication with Cielo servers for a system of my.

However, when I try to load the Cielo library, I get an error. The folder structure is as follows:

  • third_party / Cielo / {lib files straight from Cielo git}
  • controllers / Cielo_homol.php { my test controller }

On the controller Cielo_Homol.php I have the following code:

<?php defined('BASEPATH') OR exit('No direct script access allowed');

require APPPATH.'third_party/Cielo/Cielo.php';
require APPPATH.'third_party/Cielo/CieloException.php';
require APPPATH.'third_party/Cielo/Transaction.php';
require APPPATH.'third_party/Cielo/Holder.php';
require APPPATH.'third_party/Cielo/PaymentMethod.php';


use Cielo\Cielo;
use Cielo\CieloException;
use Cielo\Transaction;
use Cielo\Holder;
use Cielo\PaymentMethod;

class Cielo_Homol extends CI_Controller {

    private $mid = '1006993069';
    private $key = '25fbb99741c739dd84d7b06ec78c9bac718838630f30b112d033ce2e621b34f3';

    public function index(){
       $cielo = new Cielo($this->mid, $this->key, Cielo::TEST);
    }

}

I’m just trying to run the object to generate errors and start filling in the request data... BUT, and now begins my problems, Is returning me the following error:

An uncaught Exception was encountered

Type: Error

Message: Class 'Cielo Merchant' not found

Filename: /Users/raphaelschubert/projects/clients/miPague/application/third_party/Cielo/Cielo.php

Line Number: 59

Backtrace:

File: /Users/raphaelschubert/projects/clients/miPague/application/controllers/Cielo_homol.php Line: 23 Function: __Construct

File: /Users/raphaelschubert/projects/clients/miPague/index.php Line: 292 Function: require_once

Cielo.php I didn’t move, it’s original same as the library provided in the Cielo git link. LINK TO GITHUB ARCHIVE HERE

Would anyone have a light to give me? Grateful for the help...

1 answer

0

/Users/raphaelschubert/projects/clients/miPague/application/controllers/Cielo_homol.php

<?php defined('BASEPATH') OR exit('No direct script access allowed');

use Cielo\Cielo;
use Cielo\CieloException;
use Cielo\Transaction;
use Cielo\Holder;
use Cielo\PaymentMethod;

class Cielo_Homol extends CI_Controller {

    private $mid = '1006993069';
    private $key = '25fbb99741c739dd84d7b06ec78c9bac718838630f30b112d033ce2e621b34f3';

    public function index(){
       $cielo = new Cielo($this->mid, $this->key, Cielo::TEST);
    }

}

/Users/raphaelschubert/projects/clients/miPague/index.php

// adicionar autoloader:
spl_autoload_extensions('.php');

spl_autoload_register(function($classname) {
    if (strpos($classname, '\\') !== false) {
        // Namespaced Classes
        $classfile = (str_replace('\\', '/', $classname));

        if ($classname[0] !== '/') {
            $classfile = APPPATH . 'third_party/' . $classfile . '.php';
        }
        require($classfile);
    }
}, true, true);
/*
 * --------------------------------------------------------------------
 * LOAD THE BOOTSTRAP FILE
 * --------------------------------------------------------------------
 *
 * And away we go...
 *
 */
require_once BASEPATH.'core/CodeIgniter.php';
  • Thank you! Now the library is loading... But now returned the following error: Class 'Cielo\Cielo' not found

  • from what I understand, on the line where there is: code $cielo = new Cielo(...); ele não conseguiu fazer o Load da class

  • COMPLETE ERROR: An uncaught Exception was encountered&#xA;&#xA;Type: Error&#xA;&#xA;Message: Class 'Cielo\Cielo' not found&#xA;&#xA;Filename: /Users/raphaelschubert/projetos/clientes/miPague/application/controllers/Cielo_Homol.php&#xA;&#xA;Line Number: 16

Browser other questions tagged

You are not signed in. Login or sign up in order to post.