https://github.com/mscbuild/-e-commerce-app
π§±Building Ecommerce web application
https://github.com/mscbuild/-e-commerce-app
core development ecommerce framework net payment postgresql razor-pages server webapp website
Last synced: about 1 month ago
JSON representation
π§±Building Ecommerce web application
- Host: GitHub
- URL: https://github.com/mscbuild/-e-commerce-app
- Owner: mscbuild
- License: mit
- Created: 2025-05-10T16:15:40.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-08-08T13:18:50.000Z (10 months ago)
- Last Synced: 2025-08-15T18:03:36.517Z (10 months ago)
- Topics: core, development, ecommerce, framework, net, payment, postgresql, razor-pages, server, webapp, website
- Language: C#
- Homepage:
- Size: 54.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Building Ecommerce web application with C#








## π§ Core Functional Requirements.
### 1. Product Management.
### 2. Inventory Management.
### 3. Customer Management.
### 4. Order Management
### 5. Shopping Cart & Checkout
### 6. Payment Processing
## π Optional (but valuable) Features
## π§± Technology Stack Suggestion (C#/.NET Core)
## ποΈ Project Structure
Assuming you're building an ASP.NET Core Web API backend, your folder structure might look like this:
```ruby
EcommerceApp/
β
βββ Controllers/ β API endpoints (ProductsController, OrdersController, etc.)
βββ Models/ β Data models (Product, Customer, Order, etc.)
βββ Data/ β DbContext and seed data
βββ DTOs/ β Data Transfer Objects for requests/responses
βββ Services/ β Business logic (e.g., OrderService, PaymentService)
βββ Repositories/ β Data access layer (optional abstraction)
βββ Migrations/ β EF Core migrations
βββ wwwroot/ β Static files (if applicable)
βββ Program.cs β App entry point
βββ appsettings.json β Configuration (connection strings, etc.)
```
### π§© 1. Database Schema
### π¦ 2. Order
### π 3. OrderItem
### π€ 4. Customer
### π³ 5. Payment (Optional if using external gateway only)
### π 6. AppDbContext.cs
### π§Ύ 7. ProductsController.cs
# π§ͺ Example Test with curl or Postman.
### GET all products
```ruby
GET http://localhost:5000/api/products
```
### POST new product
```ruby
POST http://localhost:5000/api/products
Content-Type: application/json
{
"name": "Laptop",
"description": "High-performance laptop",
"price": 1200.00,
"stock": 15,
"sku": "LAP123",
"imageUrl": "https://example.com/laptop.jpg"
}
```
### π§© 8. OrderService.cs
# β How to Use OrderService
Example us
```ruby
[HttpPost("create")]
public async Task CreateOrder(CreateOrderRequest request)
{
var result = await _orderService.CreateOrderAsync(request.CustomerId, request.Items);
if (!result.Success)
return BadRequest(result.Message);
return Ok(result.Message);
}
```
### DTO
```ruby
public class CreateOrderRequest
{
public int CustomerId { get; set; }
public List Items { get; set; }
}
public class OrderItemRequest
{
public int ProductId { get; set; }
public int Quantity { get; set; }
}
```
# π³ Step-by-Step: Stripe Integration for
### β 1. Set Up Stripe in Your
Install the Stripe
```ruby
dotnet add package Stripe.net
```
In `appsettings.json`, add you
```ruby
"Stripe": {
"SecretKey": "sk_test_YourSecretKey",
"PublishableKey": "pk_test_YourPublicKey"
}
```
### Load Stripe configuration in Program.cs or Startup.cs:
```ruby
StripeConfiguration.ApiKey = builder.Configuration["Stripe:SecretKey"];
```
### π§Ύ 2. Create a PaymentService
This will handle creating a Stripe charge (or PaymentIntent for newer APIs):
### π― 3. Payment Controller Endpoint
### π§ͺ 4. Testing
You can now POST to /api/payments/create-checkout-session/{orderId} and redirect the user to the returned url
# π‘ Stripe Webhook Integration (Payment Confirmation)
### β 1. Why Use Webhooks?
Stripe Checkout redirects users after payment, but the most secure way to confirm payment is by listening to Stripeβs server-side webhooks.
### π οΈ 2. Add Webhook Endpoint to Your App
>π Note: When creating the Checkout Session earlier, you can add Metadata = new Dictionary { { "order_id", order.Id.ToString() } } to the SessionCreateOptions.
Stripe Checkout redirects users after payment, but the most secure way to confirm payment is by listening to Stripeβs server-side webhooks.
### π§ͺ 3. Expose Localhost for Stripe Testing
# β Result
1.Now your app will:
2.Create Stripe Checkout sessions.
3.Send users to Stripe to pay.
4.Listen for successful payments via webhook.
5.Automatically mark the order as βPaidβ in your database.
# πΌοΈ Basic UI Components
### π Pages/Products.razor
### π Services/CartService.cs
# π³ Checkout Page
### π Pages/Checkout.razor
### π§ͺ Test Flow
1.Run your backend API and Blazor app
2.Visit /products
3.Add items to cart
4. /checkout
5.Click "Proceed to Payment" β redirects to Stripe
6.After successful payment, Stripe webhook marks order as "Paid"
# π Azure Deployment:
β Backend (ASP.NET Core Web API)
β Frontend
β SQL Databas
β Stripe Webhooks (via Stripe CLI or Azure F)
# π GitHub Ac
π§ Y
β Automatic build and test on each push
β Publish to Azure App Servi (API and Blazor)
### π§ Step 1: Prep Your Azure App Services
### π Step 2: Create Azure Deployment Credentials
### π Step 3: Create GitHub Workflow Files
### π Step 4: Add Secrets to GitHub
### π§ͺ Step 5: Test CI/CD
# β Result
Every time you push changes:
### Perfect β you're now fully set up with:
β A C# e-commerce backend (API)
β A Blazor Server frontend
β Stripe payment + webhook handling
β Azure SQL integration
β Fully automated CI/CD via GitHub Actions
This stack is solid for portfolio use, production trials, or job interviews.