An ASP.NET Core 8.0 RESTful API for an e-commerce platform, built with Entity Framework Core, ASP.NET Identity, JWT authentication, and Stripe integration for payments.
-
Authentication & Authorization
- Register, confirm email, login, reset password (via code or link)
- JWT-based authentication
- Role-based access (
SuperAdmin,Admin,Customer)
-
User Management
- View all users (SuperAdmin only)
- Change user roles
- Lock / unlock users
-
Product Management
- CRUD operations with image upload
- Toggle product status
- Manage stock quantity (increase/decrease)
-
Categories & Brands
- CRUD operations
- Toggle active/inactive status
-
Cart
- Add, update, remove, and clear cart items
- Calculate total price
-
Orders
- Create and manage orders
- Track order status (Pending, Approved, Shipped, Cancelled, Completed)
-
Checkout & Payments
- Stripe payment gateway integration
- Cash on delivery option
- Refund support
- Stripe webhook for session status updates
-
Reviews
- Leave product reviews (only after purchase & completion)
- Prevent duplicate reviews
- Update/Delete reviews
- Automatic product rating & review count updates
-
Utilities
- Email service (for account confirmation, reset password, notifications)
- DB Initializer with roles and seed data
- Scalar API reference documentation
- Framework: ASP.NET Core 8.0
- Database: Microsoft SQL Server (EF Core 9)
- Authentication: ASP.NET Identity + JWT
- Payments: Stripe API
- ORM: Entity Framework Core
- Mapping: Mapster
- API Docs: Scalar
- Email: SMTP (Gmail configured in
appsettings.json)
- .NET 8 SDK
- SQL Server
- Stripe account (for payment keys)
- Gmail (or SMTP provider) for email service
- Clone the repository:
git clone https://github.com/mohammadsofan/Ecommerce_Api.git cd Ecommerce_Api/Mshop.Api - Configure appsettings.json:
"ConnectionStrings": { "DefaultConnection": "Server=.; Database=Mshop; Trusted_Connection=True; TrustServerCertificate=True;" }, "JWT": { "SecretKey": "your-secret-key" }, "Stripe": { "SecretKey": "your-stripe-secret", "PublishableKey": "your-stripe-publishable" }, "EmailSender": { "FromEmail": "your-email@gmail.com", "Password": "your-app-password" }
- Run migrations:
dotnet ef database update
- Run the project:
dotnet run
POST /api/account/register– Register userPOST /api/account/login– LoginGET /api/account/confirmEmail– Confirm emailGET /api/account/sendResetPasswordCode– Send reset codePOST /api/account/confirmResetPassword– Reset password
GET /api/products– Get all products (with pagination & search)POST /api/products– Add product (Admin/SuperAdmin)PUT /api/products/{id}– Update productPATCH /api/products/toggleStatus/{id}– Activate/Deactivate product
GET /api/cart– Get cart itemsPOST /api/cart– Add to cartPATCH /api/cart/{id}– Update quantityDELETE /api/cart/{id}– Remove item
GET /api/orders/user– Get current user’s ordersPOST /api/orders– Create orderPATCH /api/orders/changeStatus/{id}– Change order status (Admin only)
POST /api/checkout/createCheckoutSession– Start checkoutGET /api/checkout/success/{orderId}– Payment successGET /api/checkout/cancel/{orderId}– Payment canceledPOST /api/checkout/refund– Refund payment (SuperAdmin)
POST /api/reviews/product/{id}– Add review (after purchase)PUT /api/reviews/{id}– Update reviewDELETE /api/reviews/{id}– Delete reviewGET /api/reviews/product/{id}– Get product reviews
- SuperAdmin: Full access (manage users, refunds, etc.)
- Admin: Manage products, categories, brands, and orders
- Customer: Shopping, checkout, reviews