package com.paymentlink.service; import org.springframework.stereotype.Service; @Service public class ShippingService { /** * Calculate shipping cost based on method and country */ public long calculateShippingCost(String method, String country) { if (method == null || method.isEmpty()) { method = "standard"; } // Base rates in cents long baseRate = switch (method.toLowerCase()) { case "express" -> 2000; // $20 case "overnight" -> 3500; // $35 default -> 1000; // $10 for standard }; // International shipping surcharge if (country != null && !country.equals("US")) { baseRate += 1500; // $15 surcharge } return baseRate; } /** * Get available shipping methods */ public String[] getAvailableShippingMethods() { return new String[]{"standard", "express", "overnight"}; } /** * Validate shipping method */ public boolean isValidShippingMethod(String method) { if (method == null) return false; String lower = method.toLowerCase(); return lower.equals("standard") || lower.equals("express") || lower.equals("overnight"); } }