Move Payment Method Config from XML to UI
Payment method configuration moved from standard .NET config files like PayPal.config into the backend UI to make configuration easier and more accessible. Furthermore it enables Ucommerce to support multiple instances of each payment method, e.g. PayPal US, PayPal EU, each with their own unique configuration.
To accommodate the new capabilities the configuration must be moved from the XML config file to the payment method itself in the backend.
Finding the Payment Method Configuration Files.
Each payment method has a configuration file associated, which is located in the file system:
- For Umbraco:
'\Umbraco\Ucommerce\Configuration\Payments'
(relative to the application root) - For Sitecore:
'\sitecore modules\Shell\Ucommerce\Configuration\Payments'
(relative to the application root)
The files use the payment method name as the file name. When you open up one of the files you'll find a single XML node with the properties you need to configure for the gateway.
Setting Values in the Backend
To set the properties in the backend, log in to the CMS and find the paymentmethod that uses the payment method you need. They are located under "Settings -> Orders -> Payment Methods".
For each of the old values there will be a field available under the "Common" tab for the payment method as long as the service are set to the right payment gateway.
Accessing Configuration via the API
The Old Way
Using the old approach you had a CommerceConfigurationProvider
injected in your constructor so you could get the section with the configured values:
public MyPaymentMethodService(CommerceConfigurationProvider configProvider) { Section = configProvider.GetSection<PayExPaymentMethodServiceConfigurationSection>(); }
You could then use the section to retrieve the configuration values like so:
string callbackUrl = Section.CallbackUrl;
The New Way
The code is now a little simpler since you can remove the CommerceConfigurationProvider from the constructor and retrieve the values directly on the payment method like so:
string callBackUrl = paymentMethod.DynamicProperty<string>().CallbackUrl;