Defining constant values
There are times when a custom plugin requires the use of constant strings. For example, you need to define constant values when using the PipelineDisplayName attribute in a class to assign names to pipeline blocks.
Follow these best practices when you define constant values in a new plugin:
-
Create one class in your custom plugin to store all constant values.
-
Use the following naming convention for the new class defining constant values:
[FunctionalArea]Constants. For example:PaymentsBraintreeConstants.cs. -
Place the class defining constant values at the root of the plugin project folder.
-
Declare each constant as a public constant string (
public const string). -
Briefly describe the purpose or each constant string.
The PaymentsBraintreeConstants.cs class in the sample plugin project Plugin.Sample.Payments.Braintree (within the Commerce Engine SDK) provides a good example of constants definition class:
namespace Plugin.Sample.Payments.Braintree
{
/// <summary>
/// The payments constants.
/// </summary>
public static class PaymentsBraintreeConstants
{
/// <summary>
/// The get client token block name.
/// </summary>
public const string GetClientTokenBlock = "PaymentsBraintree.block.getclienttoken";
/// <summary>
/// The add federated payment block
/// </summary>
public const string UpdateFederatedPaymentBlock = "PaymentsBraintree.block.updatefederatedpayment";
/// <summary>
/// The update order after federated payment settlement block name
/// </summary>
public const string UpdateOrderAfterFederatedPaymentSettlementBlock = "PaymentsBraintree.block.UpdateOrderAfterFederatedPaymentSettlement";
/// <summary>
/// The create federated payment block
/// </summary>
public const string CreateFederatedPaymentBlock = "PaymentsBraintree.block.createfederatedpayment";
/// <summary>
/// The settle federated payment block name
/// </summary>
public const string SettleFederatedPaymentBlock = "PaymentsBraintree.block.SettleFederatedPayment";
/// <summary>
/// The void cancel order federated payment block
/// </summary>
public const string VoidCancelOrderFederatedPaymentBlock = "PaymentsBraintree.block.voidcancelorderfederatedpayment";
/// <summary>
/// The refund federated payment block
/// </summary>
public const string RefundFederatedPaymentBlock = "PaymentsBraintree.block.refundfederatedpayment";
/// <summary>
/// The registered plugin block name.
/// </summary>
public const string RegisteredPluginBlock = "PaymentsBraintree.block.RegisteredPlugin";
/// <summary>
/// Settle order sales activities block name.
/// </summary>
public const string SettleOrderSalesActivitiesBlock = "PaymentsBraintree.block.SettleOrderSalesActivities";
}
}