void.cat/VoidCat/Services/Payment/PaymentFactory.cs
Kieran 4de977c1dd
All checks were successful
continuous-integration/drone/push Build is passing
v5 (#65)
Co-authored-by: Kieran <kieran@harkin.me>
Reviewed-on: #65
2023-05-09 13:56:57 +00:00

23 lines
650 B
C#

using VoidCat.Database;
using VoidCat.Services.Abstractions;
namespace VoidCat.Services.Payment;
public class PaymentFactory : IPaymentFactory
{
private readonly IServiceProvider _services;
public PaymentFactory(IServiceProvider services)
{
_services = services;
}
public ValueTask<IPaymentProvider> CreateProvider(PaywallService svc)
{
return ValueTask.FromResult<IPaymentProvider>(svc switch
{
PaywallService.Strike => _services.GetRequiredService<StrikePaymentProvider>(),
_ => throw new ArgumentException("Must have a payment config", nameof(svc))
});
}
}