Hi, I namespaced all the files, I moved all files to one folder and if a file has more than one class I create a separate file for the other classes in order to have 1 class per file.
I have the files in the following folder:
app/Libraries/Openpay
I added the following line at the top of each file under the folder Openpay
PHP Code:
namespace App\Libraries\Openpay;
In app/Config/Autoload.php file
$psr4 = [
'App' => APPPATH, // To ensure filters, etc still found,
APP_NAMESPACE => APPPATH, // For custom namespace
'Config' => APPPATH . 'Config',
'Openpay' => APPPATH . 'Libraries\Openpay'
];
In my controller I added the following
use App\Libraries\Openpay\Openpay;
And in the function where I need to use it I added the following:
Openpay::setId('mysecretid');
Openpay::setApiKey('mysecretkey');
The problem that I have now it's when I call any of the class/method like:
$customer = $openpay->customers->add($customerData);
$charge = $openpay->charges->create($chargeData);
I get the following error:
Call to undefined method stdClass::create()
Call to undefined method stdClass::add()
I don't know why I'm getting this error and how to fix it.
Do you have an idea what I'm doing wrong or what I need to change?
Thanks for your help.