feat: Implement real Daya API integration with configurable mock/real service
This commit is contained in:
@@ -32,7 +32,39 @@ public static class ConfigureServices
|
||||
services.AddScoped<INetworkPlacementService, NetworkPlacementService>();
|
||||
services.AddScoped<IAlertService, AlertService>();
|
||||
services.AddScoped<IUserNotificationService, UserNotificationService>();
|
||||
services.AddScoped<IDayaLoanApiService, MockDayaLoanApiService>(); // Mock - جایگزین با Real برای Production
|
||||
|
||||
// Daya Loan API Service - قابل تغییر بین Mock و Real
|
||||
var useMockDayaApi = configuration.GetValue<bool>("DayaApi:UseMock", false);
|
||||
|
||||
if (useMockDayaApi)
|
||||
{
|
||||
// Mock برای Development/Testing
|
||||
services.AddScoped<IDayaLoanApiService, MockDayaLoanApiService>();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Real Implementation با HttpClient
|
||||
services.AddHttpClient<IDayaLoanApiService, DayaLoanApiService>()
|
||||
.SetHandlerLifetime(TimeSpan.FromMinutes(5))
|
||||
.ConfigureHttpClient((sp, client) =>
|
||||
{
|
||||
var config = sp.GetRequiredService<IConfiguration>();
|
||||
|
||||
// Base Address
|
||||
var baseAddress = config["DayaApi:BaseAddress"] ?? "https://testdaya.tadbirandishan.com";
|
||||
client.BaseAddress = new Uri(baseAddress);
|
||||
|
||||
// Merchant Permission Key
|
||||
var permissionKey = config["DayaApi:MerchantPermissionKey"];
|
||||
if (!string.IsNullOrEmpty(permissionKey))
|
||||
{
|
||||
client.DefaultRequestHeaders.Add("merchant-permission-key", permissionKey);
|
||||
}
|
||||
|
||||
// Timeout
|
||||
client.Timeout = TimeSpan.FromSeconds(30);
|
||||
});
|
||||
}
|
||||
|
||||
// Payment Gateway Service - فقط Daya (درگاه اینترنتی از Gateway میاد نه CMS)
|
||||
var useRealPaymentGateway = configuration.GetValue<bool>("UseRealPaymentGateway", false);
|
||||
|
||||
Reference in New Issue
Block a user