backend phase 9

This commit is contained in:
hamid
2026-07-06 19:23:44 +03:30
parent 2cfc082a04
commit 12c7e51c32
101 changed files with 11666 additions and 8 deletions
@@ -0,0 +1,28 @@
#nullable enable
using Baya.Application.Contracts.Common;
using Microsoft.Extensions.Options;
namespace Baya.Infrastructure.CrossCutting.Seams;
/// <summary>
/// Deterministic mock <see cref="IPaymentCaptureSimulator"/> — the temporary conversion trigger until b10's
/// real card capture. It returns a <i>succeeded</i> capture with a stable fake gateway reference and the
/// configured PSP fee, so <c>ConvertRequestToBookingCommand</c> can be exercised end-to-end now. Set
/// <see cref="PaymentCaptureOptions.ForceFailure"/> to exercise the "capture failed → no booking" path.
/// The real capture replaces this registration in b10 — no mock behaviour is baked into any handler.
/// </summary>
public sealed class MockPaymentCaptureSimulator(IOptions<SeamOptions> options) : IPaymentCaptureSimulator
{
private readonly PaymentCaptureOptions _options = options.Value.PaymentCapture;
public ValueTask<PaymentCaptureResult> ConfirmCaptureAsync(long bookingRequestId, CancellationToken cancellationToken = default)
{
if (_options.ForceFailure)
return ValueTask.FromResult(new PaymentCaptureResult(false, string.Empty, null));
return ValueTask.FromResult(new PaymentCaptureResult(
Succeeded: true,
GatewayReference: $"mock-capture-{bookingRequestId}",
PspFeeAmount: _options.PspFeeAmount));
}
}
@@ -14,6 +14,21 @@ public sealed class SeamOptions
public GeocodingOptions Geocoding { get; set; } = new();
public ShahkarOptions Shahkar { get; set; } = new();
public IdentityKycOptions IdentityKyc { get; set; } = new();
public PaymentCaptureOptions PaymentCapture { get; set; } = new();
}
/// <summary>
/// Tunes the mock <c>IPaymentCaptureSimulator</c> (backend-phase-9). By default every capture succeeds with
/// a fake gateway reference and <see cref="PspFeeAmount"/>. Set <see cref="ForceFailure"/> to exercise the
/// "capture failed → no booking" path. The real b10 card capture ignores these.
/// </summary>
public sealed class PaymentCaptureOptions
{
/// <summary>When true, every capture returns a failed result so conversion refuses to create a booking.</summary>
public bool ForceFailure { get; set; }
/// <summary>The PSP/gateway fee (IRR) the mock reports on a successful capture.</summary>
public long? PspFeeAmount { get; set; }
}
/// <summary>
@@ -43,6 +43,11 @@ public static class ServiceCollectionExtension
services.AddSingleton<IIdentityKycProvider, MockIdentityKycProvider>();
services.AddSingleton<ICredentialVerifier, MockCredentialVerifier>();
// Payment-capture trigger (backend-phase-9). The mock returns a deterministic succeeded capture so
// ConvertRequestToBooking is testable now; in b10 the real card capture replaces this registration
// and calls ConvertRequestToBooking directly on a real payment_transactions.succeeded.
services.AddSingleton<IPaymentCaptureSimulator, MockPaymentCaptureSimulator>();
return services;
}
}