Skip to content

Commit

Permalink
Configured Stripe in Project
Browse files Browse the repository at this point in the history
  • Loading branch information
aliarmaganuygun committed Oct 20, 2024
1 parent 02fff0f commit d244fec
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 2 deletions.
8 changes: 8 additions & 0 deletions Bulky.Utility/StripeSettings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace BookBazaar.Utility
{
public class StripeSettings
{
public string SecretKey { get; set; }
public string PublishableKey { get; set; }
}
}
3 changes: 2 additions & 1 deletion BulkyWeb/Areas/Customer/Controllers/CartController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ public IActionResult SummaryPOST()
if (applicationUser.CompanyId.GetValueOrDefault() == 0)
{
//it is a regular customer account and we need to capture payment
//stripe logic
//adyen logic
//var options = new AdyenPaymentOptions()

}

Expand Down
1 change: 1 addition & 0 deletions BulkyWeb/BookBazaar.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="8.0.6" />
<PackageReference Include="Stripe.net" Version="46.2.1" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 3 additions & 1 deletion BulkyWeb/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Identity.UI.Services;
using Microsoft.EntityFrameworkCore;
using Stripe;

var builder = WebApplication.CreateBuilder(args);

Expand All @@ -13,6 +14,7 @@
builder.Services.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlServer(builder.Configuration.GetConnectionString("DefaultConnection")));

builder.Services.Configure<StripeSettings>(builder.Configuration.GetSection("Stripe"));
builder.Services.AddIdentity<IdentityUser, IdentityRole>().AddEntityFrameworkStores<ApplicationDbContext>().AddDefaultTokenProviders();
builder.Services.ConfigureApplicationCookie(options =>
{
Expand All @@ -36,7 +38,7 @@

app.UseHttpsRedirection();
app.UseStaticFiles();

StripeConfiguration.ApiKey = builder.Configuration.GetSection("Stripe:SecretKey").Get<string>();
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
Expand Down
4 changes: 4 additions & 0 deletions BulkyWeb/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,9 @@
"AllowedHosts": "*",
"ConnectionStrings": {
"DefaultConnection": "Server=.;Database=Bulky;Trusted_Connection=True; TrustServerCertificate=True"
},
"Stripe": {
"SecretKey": "sk_test_51QBwYZAp4ASQ4CvpOMhUjEQC0kGQiEIMq11E5hhhKLZMyEixiWevtN2F8rgNfHOBNU4sizZgiPnnxBkJhmGwYJfm00o49xyO4G",
"PublishableKey": "pk_test_51QBwYZAp4ASQ4CvpCLbh03xF3omkVlTRoWR4hQ8mlBwplhWn7I6LBPKQT5GXS0SeR7ZAy181xxLnPI5mrwuNWyVw00vezNAAly"
}
}

0 comments on commit d244fec

Please sign in to comment.