Integrating with 6.2 TPC Ecommerce
Extending or Building Custom Providers
The TPC Checkout widget has been designed to allow most components to be overwritten/extended. The main extensible components are listed below:
ITpcPaymentProvider – This interface represents the class responsible for interacting with a specific payment provider, processing a payment transaction, validating it, and generating the view specific to a payment provider. This interface requires a custom configuration type to be provided as a generic argument.
ITpcPaymentLogicProvider – This interface represents the class responsible for the way a payment interacts with Dynamics CRM. It is used to decouple the business logic from any specific payment processor. It is used to dispatch events, update entities in CRM, and dispatch workflows. This interface does not require a configuration type.
ITpcTaxProvider – This interface represents the class responsible for applying taxes to an order. This interface requires a custom configuration type to be provided as a generic argument.
ITpcShippingProvider – This interface represents the class responsible for how shipping quotes are generated and how shipping is processed after the payment is complete. This interface requires a configuration type to be provided as a generic argument.
Registering a Custom Provider
To create your own provider to extend the TPC Checkout widget, you will need to register the provider /configuration. The first step in registering the custom provider/configuration is to create a NinjectModule that will bind the dependencies. You can call the file InterfaceMappings.cs. Below is a sample of what this will look like.
/// This class is used to describe the bindings which will be used by the Ninject container when resolving ecommerce classes
public class EcommerceMappings : NinjectModule
/// Loads the module into the kernel.
public override void Load()
//Get System Configuration
ConfigManager manager = ConfigManager.GetManager();
SystemConfig systemConfig = manager.GetSection<SystemConfig>();
//Bind Payment Provider/Configuration Example
Bind<ITpcPaymentProviderConfiguration>().To<SylogistPayPaymentProviderConfiguration>().InTransientScope().WithConstructorArgument("parent", systemConfig);
Bind<ITpcPaymentProvider>().To<SylogistPayPaymentProvider>().InTransientScope();
//Bind Payment Logic Provider Example
Bind<ITpcPaymentLogicProvider>().To<DefaultPaymentLogicProvider>().InTransientScope();
//Bind Shipping Provider/Configuration Example
Bind<ITpcShippingProviderConfiguration>().To<PickupShippingProviderConfiguration>().InTransientScope().WithConstructorArgument("parent", systemConfig);
Bind<ITpcShippingProvider>().To<PickupShippingProvider>().InTransientScope();
//Bind Tax Provider/Configuration Example
Bind<ITpcTaxProviderConfiguration>().To<FlatTaxProviderConfiguration>().InTransientScope().WithConstructorArgument("parent", systemConfig);
Bind<ITpcTaxProvider>().To<FlatTaxProvider>().InTransientScope();
If you are registering an extension to an element that requires a configuration such as the ITpcPaymentProvider, ITpcTaxProvider, or ITpcShippingProvider, there are 2 additional steps to finish registering the classes. Both steps can be completed using the TpcAdminAppSitefinityInitializer class. You will also need to register your custom initializer using dependency injection like we did in the previous step. Below is an example of DemoEcommerceAdminAppInitializer.cs. The ImplementationTypeMappings method is required to be overridden as it will allow Sitefinity to work with the dynamic configurations you create for your custom providers. The method InitializeConfigurations can also be used if you want to register a default empty configuration for your dynamic configuration types.
public DemoEcommerceAdminAppInitializer()
ModuleName = PortalConnectorMvcEcommerceModule.ModuleName;
/// This method is used to add the implementation type mappings for Ecomm Configuration Elements
/// <returns>Type Mappings</returns>
public override Tuple<Type, Type>[] ImplementationTypeMappings()
return new Tuple<Type, Type>[]
Tuple.Create( typeof(SylogistPayPaymentProviderConfiguration), typeof(ITpcPaymentProviderConfiguration)),
Tuple.Create (typeof(PickupShippingProviderConfiguration), typeof(ITpcShippingProviderConfiguration)),
Tuple.Create (typeof(FlatTaxProviderConfiguration), typeof(ITpcTaxProviderConfiguration))
/// This method is used to initialize configuration logic for Ecomm Configuration Elements.
public override void InitializeConfigurations()
bool saveChanges = false;
//Get Configurations Manager
ConfigManager configManager = ConfigManager.GetManager();
PortalConnectorMvcEcommerceConfig config = configManager.GetSection<PortalConnectorMvcEcommerceConfig>();
//Add Default Tax Configuration(s)
AddDefaultToConfigElementDictionary<TpcTaxProviderConfiguration, FlatTaxProviderConfiguration, FlatTaxProvider>(config.TaxProviders, ref saveChanges);
//Add Default Shipping Configurations(s)
AddDefaultToConfigElementDictionary<TpcShippingProviderConfiguration, PickupShippingProviderConfiguration, PickupShippingProvider>(config.ShippingProviders, ref saveChanges);
//Add Default Payment Configurations(s)
AddDefaultToConfigElementDictionary<TpcPaymentProviderConfiguration, SylogistPayPaymentProviderConfiguration, SylogistPayPaymentProvider>(config.PaymentProviders, ref saveChanges);
if (saveChanges) configManager.SaveSection(config);
ExceptionManager.HandleError("Initialize Ecommerce Configurations", ex);
The last step is to add the binding to the Ninject Module we created earlier. Once this has been completed, your custom provider and configurations should be registered correctly with The Portal Connector, and the TPC Checkout widget should show your new providers as options within the configuration backend. You can navigate to Sitefinity > Administration > Configurations > Advanced > PortalConnectorMvcEcommerce if you would like to add or modify existing provider configurations!
Bind<ITpcAdminAppSitefinityInitializer>().To<TpcEcommerceAdminAppInitializer>().InSingletonScope();
ITpcPaymentProvider
This class might be not complete yet but it has the method signatures to be implemented by the payment provider.
When creating your own ITpcPaymentLogicProvider you have 2 options. You can create one from scratch by creating a class that implements ITpcPaymentLogicProvider, or you can extend the class DefaultPaymentLogicProvider if you only need to overwrite select functionality. ITpcPaymentLogicProvider implements the following methods:
ITpcLogicInterface PrePaymentInput { get; }
ITpcLogicInterface PostPaymentInput { get; }
TpcPaymentEntity GetProducts(ITpcPaymentTransaction transaction);
TpcPaymentEntity CreatePrePaymentEntities(ITpcPaymentTransaction transaction);
void DispatchPrePaymentEvent(ITpcPaymentTransaction transaction);
TpcPaymentEntity CreatePostPaymentEntities(ITpcPaymentTransaction transaction);
void DispatchPostPaymentEvent(ITpcPaymentTransaction transaction);
void SavePrePaymentEntities(ITpcPaymentTransaction transaction);
void SavePostPaymentEntities(ITpcPaymentTransaction transaction);
ITpcTaxProvider
When creating your own ITpcTaxProvider you have 2 options. You can create one from scratch by creating a class that implements ITpcTaxProvider, or you can extend an existing provider if you only need to overwrite select functionality. The ITpcTaxProvider implements the following methods:
IList<ITpcTaxInformation> GetTaxes(ITpcPaymentTransaction transaction);
The custom tax provider configuration needs to extend the TpcTaxProviderConfiguration class. It can be extended to include any additional properties you would like to set as part of your custom tax provider configuration.
ITpcShippingProvider
When creating your own ITpcShippingProvider you have 2 options. You can create one from scratch by creating a class that implements ITpcShippingProvider, or you can extend an existing provider if you only need to overwrite select functionality. The ITpcShippingProvider implements the following methods:
ITpcShippingInformation ProcessShippingRequest(ITpcPaymentTransaction transaction);
ITpcShippingQuoteInformation[] GenerateShippingQuotes(ITpcContactDetails contactDetails, ITpcShippingDetails shippingDetails, ITpcCartDetails cartDetails);
The custom shipping provider configuration needs to extend the TpcShippingProviderConfiguration class. It can be extended to include any additional properties you would like to set as part of your custom shipping provider configuration.
More on Payment Providers
TPC 6.2 can support multiple types of payment provider's request. Whenever extending Payment Provider, please make sure to assign PaymentViewPath and TransactionType.
Payment Provider will have its own View which will have a Pay Button to send the request to payment provider. Create a View for the payment provider you want to integrate with and assign the property “PaymentViewPath” with the View path you create.
Currently we are supporting 4 Payment Processing requests:
ExecutePostPayment - This function is used to execute post payment for javascript API payment providers.
PaymentPost - This function is used to return from a payment provider that sends a POST request after the transaction is complete.
PaymentGet - This function is used to return from a payment provider that sends a GET request after the transaction is complete.
ExecutePayment - This function is used to execute payment for server-side processing payment providers. This requires PCI compliance.
When the Transaction is complete, it needs to make an ajax request to any of the above methods to process the transaction from your view.