I suggest you take a look at Mapping gateway providers to forms
If we take look inside the shopping cart:
CMSModules\Ecommerce\Controls\ShoppingCart\ShoppingCartPaymentGateway.ascx.cs
// Add payment gateway custom data
var provider = ShoppingCartControl.PaymentGatewayProvider;
mPaymentDataForm = Service.Resolve<IPaymentGatewayFormFactory>().GetPaymentGatewayForm(provider, this);
You need to create your implementation of PaymentGatewayFormFactory and the service class will resolve it. Here is the example of Mapping the gateway provider to the form