Commit: 188fc92

Commit Details

SHA188fc92ac938e5ecdaaba64fb6d1dbffeba30181
Tree2cc04755c4f7f8be29aafd7e581f1f25e14edd58
Author<f69e50@finnacloud.com> 1766442998 +0300
Committer<f69e50@finnacloud.com> 1766442998 +0300
Message
increment
GPG Signature
-----BEGIN PGP SIGNATURE-----

iQJSBAABCAA8FiEEWJb139mJI+vZ81KkoAIVSUsXI0oFAmlJx/YeHHNvcGhpYS5l
cmFzbGFuQGZpbm5hY2xvdWQuY29tAAoJEKACFUlLFyNKyF8P/j6F8McjkGTBhDFX
frSY0CqkszvNegnZnDj4AkVjoJl7AK0RY0KLLQxrRUJq/MIA/FPj9G7df9jUJcae
TS+tvTZzWOXZ3EXomyNPangFgm5yAgmelwJYgeQdTmzIY3miM8/BdQg10GNC6Fjq
iEn6PKkpkItfiy+vftAABqe73SI9Vn6nwkUn2zVEsXBX1Kmv/ya9auodjFegvcbz
pRx5BL3xNYaA57c8WG9Fx+XaQPdaeLMcu/kM8diY0XTWqtdR+OfrPlU2JOApB0yO
G4P6zG6h5w2XWCqtbqfszDt94drbArJ9cQbWLlgbiNjpK+qJVvG+HGXxPGgvzLA3
9HhZxzUJobkt0MycngmZryj25b6kdO6OA5BCBCjdMkHjIvmBpLXYD5y5uYnerR0n
YEDyB5noRAiYbb2Skg1dp9dpNxq5LF1WkJpWM+nCXlOU6jKj3ucOJ7JP2+gVWA7N
jFdEUIfX65Q9CcBQqQX1vWyGJCc/Z0sNGE0Dc06PrpPk/U10oFNZOdCbUNEWU4Pk
yqATdaAI1BdvZjAip6QQ/jtIuHkwigAk9uUp21VlZ1NnXXLixmA53y12fi8f3DnB
yl55qYeoTOyEg5N7k1ukOt5rgoJ28szscEwvYmwL56uDtlrXly/vrSNrMi322aJK
IJeozLKMpf6Q9A3vN000vGTA6VjP
=Whh7
-----END PGP SIGNATURE-----

✓ Verified

File: src/main/java/com/paymentlink/controller/api/TaxApiController.java

1 package com.paymentlink.controller.api;
2
3 import com.paymentlink.service.TaxService;
4 import org.springframework.http.HttpStatus;
5 import org.springframework.http.ResponseEntity;
6 import org.springframework.web.bind.annotation.*;
7
8 import java.util.HashMap;
9 import java.util.Map;
10
11 @RestController
12 @RequestMapping("/api/tax")
13 public class TaxApiController {
14
15 private final TaxService taxService;
16
17 public TaxApiController(TaxService taxService) {
18 this.taxService = taxService;
19 }
20
21 /**
22 * GET /api/tax/calculate - Calculate tax
23 */
24 @GetMapping("/calculate")
25 public ResponseEntity<Map<String, Object>> calculateTax(
26 @RequestParam Long subtotal,
27 @RequestParam(required = false) String country,
28 @RequestParam(required = false) String state) {
29
30 try {
31 long taxAmount = taxService.calculateTax(subtotal, country, state);
32 double taxRate = taxService.getTaxRate(country, state);
33
34 Map<String, Object> response = new HashMap<>();
35 response.put("success", true);
36 response.put("taxAmount", taxAmount);
37 response.put("taxRate", taxRate);
38 return ResponseEntity.ok(response);
39
40 } catch (Exception e) {
41 Map<String, Object> error = new HashMap<>();
42 error.put("success", false);
43 error.put("error", e.getMessage());
44 return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(error);
45 }
46 }
47
48 /**
49 * GET /api/tax/rate - Get tax rate
50 */
51 @GetMapping("/rate")
52 public ResponseEntity<Map<String, Object>> getTaxRate(
53 @RequestParam(required = false) String country,
54 @RequestParam(required = false) String state) {
55
56 try {
57 double taxRate = taxService.getTaxRate(country, state);
58
59 Map<String, Object> response = new HashMap<>();
60 response.put("success", true);
61 response.put("taxRate", taxRate);
62 return ResponseEntity.ok(response);
63
64 } catch (Exception e) {
65 Map<String, Object> error = new HashMap<>();
66 error.put("success", false);
67 error.put("error", e.getMessage());
68 return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(error);
69 }
70 }
71 }
72
73