After listening to the feedback, publish it via NuGet to make it easier to integrate it in new projects, makes a lot of sense.

Currently, two NuGet packages are available: SaasEcom.Core and SaasEcom.FrontEnd. I’ll show how it can be used in an MVC project:

The source code for this sample is available in GitHub

1.Create a new Web Application in Visual Studio 2013.

create new project

2.Select MVC using Individual User Accounts.

new project select individual account

new project

04

3.Search for ‘SaasEcom’ on NuGet Package Manager, and install SaasEcom.FrontEnd. SaasEcom.Core is a dependency so it will be installed too.

05

04.You can see that two controllers and some views have been added:

06

05.If you try to compile the solution at this point, it will fail. You need to your IdentityUser and your DbContext. By default, they are in Models/IdentityModels.cs. They need to inherit from SaasEcomUser and SaasEcomDbContext respectively:

07

06.Add your Stripe Keys to Web.config:

08

07.Enhancing Register form to create a Stripe user and Subscribe to a plan.

Edit “Models/AccountViewModels.cs” and add the following property to RegisterViewModel:

Edit “Controllers/AccountController.cs” and add the following property:

Also Edit Register method adding these 3 lines (notice that when ApplicationUser is created, I’ve added a property “CreatedAt”):

The last thing that we need to add to complete the Registration process is add the drop-down to the view. Edit Views/Account/Register.cshtml and add the drop-down:

One thing to note here is that I am using 3 subscription plans. Each plan FriendlyId is Starter / Premium / Ultimate. They need to exist in the Database. If you’re using migrations you can just add them to the DB. Otherwise, you can just run the solution, then the db will be created inside the folder App_Data, you can open the database from Visual Studio and add the Plans there.

If you navigate to the Register page, you’ll see the drop-down there. Go ahead and register. If you go to your Stripe Dashboard you should see your user there.

09

Views included with SaasEcom.Frontend

If you navigate to http://localhost/SaasEcom you should see this:

10

From there, you can Add / Change a Credit card:

11

You can change subscription plan:

12

And then the same page would look like:

13

If you set up on Stripe Dashboard your endpoint for Stripe Web hooks, should be: http://your-public-domain.com/StripeWebhooks the invoices for your customers will be created in the system:

14

As I mentioned earlier, this is all available in NuGet as a Prerelease package. Try it and any feedback will be welcome.