So I'm pretty new to .NET and I'm wondering how to integrate Stripe payment element into .NET application.
I've read the documentation but I'm just unclear on the file structure and how the files are interlinked.
In the docs I'm just unclear on where to put the Server.cs file is it a controller does it need a Product model?
What about the products registered on Stripe do I need to add those in first for it to work.
Here is a link to the docs:
Stripe Payment .NET Integration
Here is my program.cs file
using CoffeeShop.Data;
using CoffeeShop.Models.Interfaces;
using CoffeeShop.Models.Services;
using Microsoft.EntityFrameworkCore;
using Microsoft.AspNetCore.Identity;
using Stripe;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllersWithViews();
builder.Services.AddScoped<IProductRepository, ProductRepository>();
builder.Services.AddScoped<IOrderRepository, OrderRepository>();
builder.Services.AddDbContext<CoffeeShopDBContext>(option => option.UseSqlServer(builder.Configuration.GetConnectionString("CoffeeShopDbConnection")));
builder.Services.AddDefaultIdentity<IdentityUser>(options => options.SignIn.RequireConfirmedAccount = false).AddEntityFrameworkStores<CoffeeShopDBContext>();
builder.Services.AddScoped<IShoppingCartRepository, ShoppingCartRepository>(s => ShoppingCartRepository.GetCart(s));
builder.Services.AddSession();
builder.Services.AddHttpContextAccessor();
builder.Services.AddRazorPages();
var app = builder.Build();
app.UseSession();
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Home/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.MapRazorPages();
app.UseRouting();
StripeConfiguration.ApiKey = builder.Configuration.GetSection("Stripe:SecretKey").Get<string>();
app.UseAuthentication();
app.UseAuthorization();
app.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
app.Run();
Here is my project Structure
I've tried looking at examples going through videos but for some reason I'm finding it difficult to grasp.
