Checkout total in the shopper's currency

C# · ASP.NET Core · intermediate · modification

The checkout page can now show the order total in the shopper's currency next to the euro total. `GET /api/checkout/summary` accepts an optional `currency` and, for one of the six supported currencies, adds a `display` block with the converted total and the FX provider's quote id, which payment uses later. The provider call lives in the new `Fx/FxQuoteClient.cs` behind `IFxQuoteClient`: it posts the euro total to `/v1/quotes` with the API key and a 3-second timeout, and turns error statuses, timeouts, network failures and unreadable bodies into `FxUnavailableException`, which `CheckoutEndpoints.cs` logs before falling back to the euro-only summary. `Program.cs` binds the `Fx` options and registers the client. `CheckoutSummaryCurrencyTests.cs` covers the endpoint with a fake quote client.

ASP.NET Core 10 minimal API on .NET 10 (C# 14, nullable reference types enabled, implicit usings), xUnit for tests. Existing and unchanged: `CheckoutSummaryService.ForUserAsync(userId, ct)` returns the shopper's open cart as `CheckoutSummary(SubtotalCents, ShippingCents, TotalCents)` (`long` euro cents, the total from 0 to 10,000,000) or `null` when there is no open cart; it prices shipping through `ShippingRatesClient`, the typed client registered in `Program.cs`. `User.GetUserId()` (`Shop.Api.Auth`) reads the signed-in shopper's id. Configuration always sets `Fx:BaseUrl` (the provider's origin, `https://api.fxquotes.example`) and `Fx:ApiKey` (from the secret store). The FX provider is an HTTPS API at about a 20 ms round trip (TLS 1.3); a successful `POST /v1/quotes` answers 201 with `{ "quoteId", "to", "amountMinor", "expiresAt" }`, where `to` echoes the request, `amountMinor` is a non-negative integer and `expiresAt` an ISO 8601 timestamp; failures answer 4xx or 5xx. The API runs as three Linux containers (Kestrel) behind a load balancer and calls the provider directly, with no proxy. JSON uses the ASP.NET Core web defaults (camelCase names). Tests use the existing `ShopApiFactory` (`WebApplicationFactory<Program>` with a test authentication scheme: a request with an `X-Test-User` header is signed in as that user; `u-1` has an open cart of 3,650 cents plus 500 cents shipping). The checkout page change ships separately.

Requirements

Files touched

Review this PR

C# practice