blocker phase 5
This commit is contained in:
+31
-14
@@ -8,6 +8,7 @@ using Baya.Application.Contracts.Payments;
|
||||
using Baya.Application.Contracts.Persistence;
|
||||
using Baya.Application.Contracts.Search;
|
||||
using Baya.Application.Contracts.SupportAlerts;
|
||||
using Baya.Domain.Entities.Bnpl;
|
||||
using Baya.Domain.Entities.Payments;
|
||||
using Baya.Infrastructure.Persistence.Interceptors;
|
||||
using Baya.Infrastructure.Persistence.Repositories.Common;
|
||||
@@ -128,27 +129,43 @@ public static class ServiceCollectionExtensions
|
||||
|
||||
/// <summary>
|
||||
/// Idempotently seeds one active <c>standard</c> payment gateway so the b10 card rail has a selectable
|
||||
/// provider out of the box. <c>config_json</c> is encrypted at rest by the EF converter on save (so it
|
||||
/// must go through the DbContext, not <c>HasData</c>). Real merchant credentials come from appsettings /
|
||||
/// environment per deployment — this sandbox row is non-secret and only enables the local/dev flow.
|
||||
/// provider out of the box, plus one active <c>bnpl</c> gateway (<c>balinyaar</c>, the in-house
|
||||
/// net-of-fee provider per money.md §6 — needs no external credentials) so b12's eligibility/initiate
|
||||
/// handlers have a gateway to select instead of short-circuiting. <c>config_json</c> is encrypted at rest
|
||||
/// by the EF converter on save (so it must go through the DbContext, not <c>HasData</c>). Real merchant
|
||||
/// credentials come from appsettings / environment per deployment — these sandbox rows are non-secret and
|
||||
/// only enable the local/dev flow.
|
||||
/// </summary>
|
||||
public static async Task SeedPaymentGatewaysAsync(this WebApplication app)
|
||||
{
|
||||
await using var scope = app.Services.CreateAsyncScope();
|
||||
var context = scope.ServiceProvider.GetRequiredService<ApplicationDbContext>();
|
||||
|
||||
if (await context.Set<PaymentGateway>().AnyAsync(g => g.Type == PaymentGatewayType.Standard))
|
||||
return;
|
||||
|
||||
context.Set<PaymentGateway>().Add(new PaymentGateway
|
||||
if (!await context.Set<PaymentGateway>().AnyAsync(g => g.Type == PaymentGatewayType.Standard))
|
||||
{
|
||||
ProviderCode = "zarinpal",
|
||||
Type = PaymentGatewayType.Standard,
|
||||
DisplayName = "ZarinPal (sandbox)",
|
||||
ConfigJson = "{\"merchantId\":\"00000000-0000-0000-0000-000000000000\",\"baseUrl\":\"https://sandbox.zarinpal.com\",\"sandbox\":true}",
|
||||
IsActive = true,
|
||||
Priority = 0
|
||||
});
|
||||
context.Set<PaymentGateway>().Add(new PaymentGateway
|
||||
{
|
||||
ProviderCode = "zarinpal",
|
||||
Type = PaymentGatewayType.Standard,
|
||||
DisplayName = "ZarinPal (sandbox)",
|
||||
ConfigJson = "{\"merchantId\":\"00000000-0000-0000-0000-000000000000\",\"baseUrl\":\"https://sandbox.zarinpal.com\",\"sandbox\":true}",
|
||||
IsActive = true,
|
||||
Priority = 0
|
||||
});
|
||||
}
|
||||
|
||||
if (!await context.Set<PaymentGateway>().AnyAsync(g => g.Type == PaymentGatewayType.Bnpl))
|
||||
{
|
||||
context.Set<PaymentGateway>().Add(new PaymentGateway
|
||||
{
|
||||
ProviderCode = BnplProviderCodes.Balinyaar,
|
||||
Type = PaymentGatewayType.Bnpl,
|
||||
DisplayName = "Balinyaar BNPL",
|
||||
ConfigJson = "{\"sandbox\":true}",
|
||||
IsActive = true,
|
||||
Priority = 0
|
||||
});
|
||||
}
|
||||
|
||||
await context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user