Commit: 690c1f6

Commit Details

SHA690c1f6ce426c62c29e87ac132dda0f8125192ff
Tree5a67fd55b56735ab4e469c7d06c1c73c4c2b4c20
Author<f69e50@finnacloud.com> 1766368110 +0300
Committer<f69e50@finnacloud.com> 1766368110 +0300
Message
initialize backend structure with controllers, DTOs, and configuration files
GPG Signature
-----BEGIN PGP SIGNATURE-----

iQJSBAABCAA8FiEEWJb139mJI+vZ81KkoAIVSUsXI0oFAmlIo24eHHNvcGhpYS5l
cmFzbGFuQGZpbm5hY2xvdWQuY29tAAoJEKACFUlLFyNKwXYP/RvWx8mxXoZbKEVA
wQFC9UnzcoL/lElB5QMr9opKzRv4uGgFkKMDhbSnqE6NoET5H5VanOFQ9u5a4Khi
9PBTLIEBjbEqA1trC+aTDk3EplVtQYYbSn19CdMSCW7FXJNSg0IiyWKA44iH8Ts0
Xcxh59m6WcwvRDhxQDy6hCXqUa9ISNNk75KRnJS/qRGIEy94DwUYxVfCJpAfzyVu
VmdinE6kZM2GDj8MBTPQTzi6hMf/e9CcAg51tf4oNtd9tnW8QKpTsPsFy434VUDh
Vxtv/oAJ5tuTIprs2BSnyZ6Kb8RDwDdmQyuKjZMUIwZTH/TCE85SZFf5sa5tpYOH
2KekT52ffZgKw/DUtpNosW6qeHgCJlSvwY7BW7M90X5xJuahrKS04lEDBO04cIRn
bg0ayPFTp7Idhl1OuTRhWS6e344g44mJ/9sZK1sXd/0U8OKBbytk35AnCIPCEdSX
8vgjqBR9Wt3A/Kel5j2VcUFDhrAR72a9lJiQHNBicvcVu9Nd41vDnEwUDdNQv6Uc
6omEz3pkVkq+89/eW1KQM8LvrIuGQ/wIUgykvCNSCQ5oba2fjtAXzI+SmxpeCWOz
jTKZOEJyhIQE7uvaUj6/0D2JwlxbMG27fcUN7N3aKv6mSVP7hYnHaUbRLQ+f8/xU
VfU776FkUXS+4CfSooHtu+ioul9O
=ZuqE
-----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