OrchardCore.Commerce icon indicating copy to clipboard operation
OrchardCore.Commerce copied to clipboard

Obsolete `KnownCurrencyTable` and move currency loading into `CurrencyProvider` (OCC-323)

Open sarahelsaig opened this issue 10 months ago • 1 comments

This KnownCurrencyTable is a static class that locks threads and loads in culture resources from the OS. As of https://github.com/OrchardCMS/OrchardCore.Commerce/pull/526 we know it's not entirely thread safe. Requiring the currency list to be derived from the operating system's culture settings may also be opinionated in certain cases.

A side effect of this is that the named currency props in Currency.extra.cs have to be obsoleted as well, because they are loaded from that table. With the exception of UnspecifiedCurrency and Euro, which are not culture-specific currencies and they are initialized without relying on external resources (we may similarly hard-code USD for backwards compatibility). Do we know if anyone actually uses the other named currency static properties besides our unit tests? I don't think they were ever a good fit for a CMS as they are not flexible and not accessible outside of code. I will ask this on Discord as well, but I suspect they are safe to be ditched.

Also make the default CurrencyProvider optional by moving it into a feature and re-adding it into the default recipe. Should be made a dependency of Stripe and Exactly as they need standard currencies, but it's possible that other hypothetical payment providers wouldn't need it.

Jira issue

sarahelsaig avatar Mar 10 '25 11:03 sarahelsaig

Details of the investigation: https://github.com/OrchardCMS/OrchardCore.Commerce/pull/526#discussion_r1987068238.

Piedone avatar Mar 10 '25 15:03 Piedone