Pull Request #3812
Add multi-currency support to checkout
Adds CurrencyService to convert USD checkout amounts to EUR, GBP, and JPY. Wires into CheckoutController via an optional currency parameter.
Ready to merge
service/CurrencyService.java+15 additions
1
+ @Service
2
+ public class CurrencyService {
3
+ @Autowired private ExchangeRateClient rateClient;
4
+
5
+ // Converts amountUsd to the target currency using live rates.
6
+ public double convert(double amountUsd, String targetCurrency) {
7
+ double rate = rateClient.getRate("USD", targetCurrency);
8
+ double converted = amountUsd * rate;
9
+ return Math.round(converted * 100.0) / 100.0;
10
+ }
11
+
12
+ public String format(double amount, String currency) {
13
+ return String.format("%.2f %s", amount, currency);
14
+ }
15
+ }
Review comments ยท service/CurrencyService.java