Pull Request #3812
Add multi-currency support to checkout
Adds CurrencyService to convert USD checkout amounts to EUR, GBP, and JPY using live exchange rates. Wires into CheckoutController via an optional currency parameter.
Ready to merge
service/CurrencyService.java+38 additions
Viewed1
@Service
2
public class CurrencyService {
3
@Autowired
4
private ExchangeRateClient rateClient;
5
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
+ }
RB
rohit_backend
Approved review
Checked the math on a few examples โ looks correct. LGTM.