Created using .Net 6 and Mediatr CQRS
https://billingapi1.herokuapp.com/swagger/index.html
Run the API in Visual Studio or run from terminal and go to https://localhost:7213/swagger/index.html to see the swagger docs
There is a repisotry branch with an older version of the api written with repository pattern if you want to see that for some reason (it is an older version tho, so it doesn't have the same "features")
Gateways that all payments get paid to. All payments are related to a payment, and all orders are related to a payment
Client user
User balance. Can be increased by user. It also acts as log of balance changes, the last added balance ( one with the max id ) is the current balance.
Orders placed and paid by the user.
Payments, can be succesfull or unseccfull when creating an order.
Account for managing users, gateways, balances, etc.
When creating an order, if the user has enough balance, a new succesfull payment will be created and an order related to that payment will also be created. Also a new balance log will be created ( which will be the new currect balance ) and the amount in it will be "last current balance amount - new order payment amount". If the user does not have enough balance, no order or balance will be created, and a new unsuccessfull payment will be created.
Here the authorization is only for managing Gateways, orders, seeing all the data, and etc. It is not for processing orders or adding to user balance, orders can be processed and user balance can be increased without authorization. (since this is a toy api, user balance can be increased willy nilly. Normally there would be some kind of bank api that would verify user before adding balance or processing orders ).
I have only written tests for 2 controller handlers, since the rest of handlers have more or less same testing scenarios, i didn't want to copy paste the same thing over and over since this is a toy api ( there would be more logic to each handler and it would be very critical to test each handler, even if the logic was same ).