Stripe Project Description

This post is the second in a complete and free course on Stripe, which is available both on this very website as well as on YouTube.

Both the course and its code are openly available for free. If you like the content, remember that you can support the website by becoming premium, or purchasing my book.

In the YouTube video, the content of this post starts at minute 19:03.

 

We are going to create a platform where we can buy books, similar to what I have on my own website where I sell the complete full stack development guide or the premium subscription.

 

 

1 - Project Creation

 

To do this, we are going to create an MVC project. Technically, we can use any type of project; it does not have to be MVC. You can separate the backend and frontend into two different applications if you prefer, but it is not necessary, and to save time, we will do it this way.

 

We will also check the box to create a project with users, since we will use them later for recurring subscriptions.

 

In fact, we are going to check the Docker box too, because we will also use it later on.

project creation visual studio

All these options and structure are to save time, but if you would like to have another type of backend, such as an API with a separate frontend, whether in Blazor or your favorite frontend framework, you can do so without any problem.

 

You can give any name to the app; when deploying, it won’t have any impact.

 

The structure is MVC, a structure based on the separation of model, view, and controller. I don’t want to go into much detail, that’s what the linked post is for, but we can summarize it as follows:

  • The view is responsible for displaying the data, either in an interface or as an API response.
  • The model manipulates the data; for me, the model layer is responsible for validations, data access, business logic, etc. Some argue that this logic belongs in the controller, to each their own.
  • The controller is responsible for receiving the correct call, as it contains the URLs you call, and it is also the link between the view and the model.

 

 

2 - The Project's Database

 

Since we chose users, we will need to store them somewhere. By default, with this option, an in-memory database is created, which is more than enough for testing on our own machine, but it is obviously not a good idea for production.

 

Here, what we’ll do is change the connection string to MySQL, simply because I like MySQL, but you can use whichever database you prefer.

Personally, I keep the database in Docker, just like before, but if you prefer to have it on your machine, you’re free to do so.

 

In order to have the database in Docker, you obviously need to have Docker installed, a container technology I recommend you get to know before continuing.

This is the .yaml file you will need to run a MySQL database in the Docker on your machine:

version: "3.8"
services:
  mysql-flagx0:
    container_name: mysql-bookplace
    image: mysql:5.6
    ports:
      - 5306:3306
    environment:
      - MYSQL_DATABASE=bookplace
      - MYSQL_ROOT_PASSWORD=pass

Personally, I like to place it at the root of the project, but if you have other priorities, you are free to do so your way.

 

 

In the code itself, we’ll use Entity Framework core to access the data, with a Code First approach. Entity Framework is a library developed by Microsoft that allows us to access databases in a simple and user-friendly way.

One of the great advantages is that we can use C# LINQ with the entities themselves to build queries without having to write SQL manually.

 

I don’t want to dig any deeper into Entity Framework. If you don’t know Entity Framework, I recommend you first check out the Complete Entity Framework Course.

 

 

3 - What is the Project About?

 

In the previous section, I mentioned Docker and the MySQL database, this is all we are going to need. In fact, if we run our code as it is right now, it works perfectly:

 

 

Although at the moment we are not querying anything from the database.

 

What we are going to do is create an application to simulate a bookstore, and why? Because I recently released my book and created a feature to enable payments through Stripe on my website, and that’s when I started to explore everything that can be done.

 

This post was translated from Spanish. You can see the original one here.
If there is any problem you can add a comment bellow or contact me in the website's contact form

Uso del bloqueador de anuncios adblock

Hola!

Primero de todo bienvenido a la web de NetMentor donde podrás aprender programación en C# y .NET desde un nivel de principiante hasta más avanzado.


Yo entiendo que utilices un bloqueador de anuncios como AdBlock, Ublock o el propio navegador Brave. Pero te tengo que pedir por favor que desactives el bloqueador para esta web.


Intento personalmente no poner mucha publicidad, la justa para pagar el servidor y por supuesto que no sea intrusiva; Si pese a ello piensas que es intrusiva siempre me puedes escribir por privado o por Twitter a @NetMentorTW.


Si ya lo has desactivado, por favor recarga la página.


Un saludo y muchas gracias por tu colaboración

© copyright 2025 NetMentor | Todos los derechos reservados | RSS Feed

Buy me a coffee Invitame a un café