I am currently working on a payment plugin and would like to store the credentials from our payment gateway in the appsettings.json file. In previous version of Nop (4.50) I created a config class that implements the IConfig interface from Nop.Core.Configuration. However, doing doing the same in version 4.60 throws an error that the given key does not exist in the dictionary.
var appSettings = Singleton<AppSettings>.Instance;
var paymentGateway= appSettings.Get<PayitConfig>();
var secretKey = appSettings.Get<PayitConfig>().SecretKey;
In the above code, PayItConfig is a class that implements IConfig.
The error I am getting
User
System.Collections.Generic.KeyNotFoundException: The given key 'Ccl.Plugin.Payments.Payit.Configuration.PayitConfig' was not present in the dictionary.
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at Nop.Core.Configuration.AppSettings.Get[TConfig]() in C:\Users\jcowo\source\repos\ClearCommerce-Limited\nopCommerce_4.60.4_Source\src\Libraries\Nop.Core\Configuration\AppSettings.cs:line 51
I have already tried to search for a solution in GitHub and the forums to no avail. I've also went over the docs many times and couldn't find anything. I also added the credentials to my appsettings.json file
"PayitConfig": {
"Login": "superSecretLogin",
"SecretKey": "SuperSecretKey"
},
TIA