Viincenttt / MollieApi

This project allows you to easily add the Mollie payment provider to your application.
MIT License
148 stars 85 forks source link

Improve support for multi tenant setups #391

Closed Viincenttt closed 3 weeks ago

Viincenttt commented 4 weeks ago

Allow library consumers to configure a custom implementation to retrieve the API key. This can be usefull in case they are running a multi-tenant setup with multiple API keys.

Usage: When registering dependencies:

builder.Services.AddMollieApi(options => {
    //options.ApiKey = builder.Configuration["MySecretManagerMollie:ApiKey"]!;
    options.SetCustomMollieSecretManager<TenantSecretManager>();
    options.RetryPolicy = MollieHttpRetryPolicies.TransientHttpErrorRetryPolicy();
});

Custom secret manager for multi-tenant setup:

public class TenantSecretManager : IMollieSecretManager {
    private readonly ITenantService _tenantService;

    public string GetBearerToken() => _tenantService.GetCurrentTenant().ApiKey;
}