I want to add the Mollie library (https://github.com/mollie/mollie-api-php) in my CodeIgniter project.
I have followed the steps on the github page, and since I'm not using composer I have downloaded the files and added 'require ../Molie/API/Autoloader.php
' in my controller.
But with the code below, I get an error like: Undefined variable: mollie
(in function ideal_get()
). What I'm doing wrong?
require APPPATH.'/libraries/REST_Controller.php';
require "../Mollie/API/Autoloader.php";
class Pay extends REST_Controller {
public $mollie;
function __construct()
{
parent::__construct();
$this->load->model('group_model');
$this->load->model('participant_model');
$mollie = new Mollie_API_Client;
$mollie->setApiKey("test_jcQEp2Hkb6pBaC38GsfSPHwkcNVBGU");
}
function ideal_get(){
$issuers = $mollie->issuers->all();
$this->response($issuers, 200);
}
}
you should put the mollie lib in your third party folder besides of that - try the following - you don't access to your mollie variable declared in your controller correctly
require APPPATH.'/libraries/REST_Controller.php';
require "../Mollie/API/Autoloader.php";
class Pay extends REST_Controller {
public $mollie;
function __construct()
{
parent::__construct();
$this->load->model('group_model');
$this->load->model('participant_model');
$this->mollie = new Mollie_API_Client;
$this->mollie->setApiKey("test_jcQEp2Hkb6pBaC38GsfSPHwkcNVBGU");
}
function ideal_get(){
$issuers = $this->mollie->issuers->all();
$this->response($issuers, 200);
}
}