I am trying to add items to merchant.php
(the CI-Merchant library's config file, which I believe is auto-loaded by CodeIgniter). I want to be able to set the settings for the payment gateway (driver) I am choosing in the settings so that I don't have to write it out in every controller that is calling the library/driver and I do not want to hardcode the settings in the driver.
These are the settings I am trying to save, but I could have others with different gateways:
$config['authorize_net']['api_login_id'] = '***';
$config['authorize_net']['transaction_key'] = '***';
$config['authorize_net']['test_mode'] = TRUE;
$config['authorize_net']['developer_mode'] = TRUE;
However this is causing 2 warnings. The first:
A PHP Error was encountered
Severity: Warning
Message: stripos() expects parameter 1 to be string, array given
Filename: libraries/merchant.php
Line Number: 97
And the second:
A PHP Error was encountered
Severity: Warning
Message: strtolower() expects parameter 1 to be string, array given
Filename: libraries/merchant.php
Line Number: 103
So it seems to me that CodeIgniter is automatically passing the merchant.php
config file to the library but it was not expecting it (which also confuses me, because in the CI-Merchant download it comes with the config file).
My worst case scenario would be to change the "default settings" in merchant_authorize_net.php
the but I really want to avoid this, below is what that default settings function looks like.
public function default_settings()
{
return array(
'api_login_id' => '',
'transaction_key' => '',
'test_mode' => FALSE,
'developer_mode' => FALSE,
);
}
My questions are:
The config file is actually just there as boilerplate code which should probably be removed. CI-merchant itself doesn't have any logic to automatically read the config file for you.
Generally the recommended approach is to store the settings in your own config file (or environment variables), and then use those settings in your controller to initialize the library. You are correct that it's best to try and avoid editing anything inside the library folder.
If you are starting a new project I also recommend you check out Omnipay, the successor to CI-Merchant, as CI-Merchant will not be receiving any further development.