diff --git a/src/main/java/com/gcc/communityHall/entity/erpPostData.java b/src/main/java/com/gcc/communityHall/entity/erpPostData.java new file mode 100644 index 00000000..1ddc770a --- /dev/null +++ b/src/main/java/com/gcc/communityHall/entity/erpPostData.java @@ -0,0 +1,82 @@ +package com.gcc.communityHall.entity; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import org.springframework.context.annotation.EnableAspectJAutoProxy; + +import java.time.LocalDate; +import java.util.Date; + +@Entity +public class erpPostData { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + private String tx_id; + private int booking_det_booking_id; + private boolean status; + private LocalDate cdate; + private int pay_status; + + public void setId(Long id) { + this.id = id; + } + + public Long getId() { + return id; + } + + public String getTx_id() { + return tx_id; + } + + public void setTx_id(String tx_id) { + this.tx_id = tx_id; + } + + public int getBooking_det_booking_id() { + return booking_det_booking_id; + } + + public void setBooking_det_booking_id(int booking_det_booking_id) { + this.booking_det_booking_id = booking_det_booking_id; + } + + public boolean isStatus() { + return status; + } + + public void setStatus(boolean status) { + this.status = status; + } + + public LocalDate getCdate() { + return cdate; + } + + public void setCdate(LocalDate cdate) { + this.cdate = cdate; + } + + public int getPay_status() { + return pay_status; + } + + public void setPay_status(int pay_status) { + this.pay_status = pay_status; + } + + @Override + public String toString() { + return "erpPostData{" + + "id=" + id + + ", tx_id='" + tx_id + '\'' + + ", booking_det_booking_id=" + booking_det_booking_id + + ", status=" + status + + ", cdate=" + cdate + + ", pay_status=" + pay_status + + '}'; + } +} diff --git a/src/main/java/com/gcc/communityHall/others/AppConfig.java b/src/main/java/com/gcc/communityHall/others/AppConfig.java index abd3f14e..940b31ed 100644 --- a/src/main/java/com/gcc/communityHall/others/AppConfig.java +++ b/src/main/java/com/gcc/communityHall/others/AppConfig.java @@ -13,6 +13,7 @@ public class AppConfig { private String erpUrl; private String assetURL; private String manualRefundCode; + private String commErpUrl; private String fullUrl; @@ -71,4 +72,12 @@ public class AppConfig { public void setFullUrl(String fullUrl) { this.fullUrl = fullUrl; } + + public String getCommErpUrl() { + return commErpUrl; + } + + public void setCommErpUrl(String commErpUrl) { + this.commErpUrl = commErpUrl; + } } diff --git a/src/main/java/com/gcc/communityHall/paymentService/controller/PaymentController.java b/src/main/java/com/gcc/communityHall/paymentService/controller/PaymentController.java index 0a276a7e..e44260ef 100644 --- a/src/main/java/com/gcc/communityHall/paymentService/controller/PaymentController.java +++ b/src/main/java/com/gcc/communityHall/paymentService/controller/PaymentController.java @@ -1,24 +1,33 @@ package com.gcc.communityHall.paymentService.controller; +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.net.HttpURLConnection; +import java.net.URL; import java.security.NoSuchAlgorithmException; +import java.security.Timestamp; +import java.text.SimpleDateFormat; import java.time.LocalDate; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.Optional; +import java.time.format.DateTimeFormatter; +import java.util.*; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.gcc.communityHall.entity.*; +import com.gcc.communityHall.others.AppConfig; +import com.gcc.communityHall.repository.ErpPostDataRepository; +import org.apache.tomcat.util.json.JSONParser; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.AutoConfigurationPackage; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; -import com.gcc.communityHall.entity.BookingDetails; -import com.gcc.communityHall.entity.ExtraPayments; import com.gcc.communityHall.entity.BookingDetails.BookingStatus; import com.gcc.communityHall.entity.BookingDetails.RefundStatus; -import com.gcc.communityHall.entity.Payments; +import com.gcc.communityHall.entity.Users; import com.gcc.communityHall.paymentService.config.PaymentConfig; import com.gcc.communityHall.paymentService.entity.TransactionResponse; import com.gcc.communityHall.paymentService.repository.TransactionResponseRepository; @@ -27,100 +36,104 @@ import com.gcc.communityHall.repository.BookingDetailsRepository; import com.gcc.communityHall.repository.ExtraPaymentsRepository; import com.gcc.communityHall.repository.PaymentsRepository; import com.gcc.communityHall.service.Impl.BookingServiceImpl; - - - - +import com.gcc.communityHall.service.UserService; +import org.springframework.web.client.RestTemplate; +import org.springframework.web.util.UriComponentsBuilder; @Controller @RequestMapping("/communityhall/payment") public class PaymentController { - @Autowired + @Autowired PaymentGatewayService paymentService; - @Autowired - private PaymentConfig paymentConfig; + @Autowired + private PaymentConfig paymentConfig; + + @Autowired + private BookingServiceImpl bookser; + + @Autowired + private TransactionResponseRepository transactionResRepo; + + @Autowired + private PaymentsRepository paymentRepo; - @Autowired - private BookingServiceImpl bookser; + @Autowired + private ExtraPaymentsRepository extraPaymentsRepository; - @Autowired - private TransactionResponseRepository transactionResRepo; - - @Autowired - private PaymentsRepository paymentRepo; - - @Autowired - private ExtraPaymentsRepository extraPaymentsRepository; - - @Autowired - private BookingDetailsRepository bookingDetailsRepository; + @Autowired + private BookingDetailsRepository bookingDetailsRepository; + + @Autowired + private AppConfig appConfig; + + @Autowired + private ErpPostDataRepository erpPostDataRepository; @PostMapping(value = "/response") - public String response(Model model, @RequestParam(required = false) String msg) throws NoSuchAlgorithmException{ + public String response(Model model, @RequestParam(required = false) String msg) throws NoSuchAlgorithmException { + - - String salt = this.paymentConfig.getEncryptionKey(); + String salt = this.paymentConfig.getEncryptionKey(); - String confirmToken=""; + String confirmToken = ""; String status = this.paymentConfig.getTransactionSuccessCode(); String s = new String(msg); String c = new String(); - String res[] =s.split("\\|"); + String res[] = s.split("\\|"); - TransactionResponse response = this.paymentService.getTransactionResponseByTxansactionId(res[3],"temp"); - Payments payment=new Payments(); + TransactionResponse response = this.paymentService.getTransactionResponseByTxansactionId(res[3], "temp"); + Payments payment = new Payments(); payment.setTransactionId(response.getTxansactionId()); - double amount=0; - - - for(int i=0;i data = new TreeMap<>(); + /*static mandatory input to be sent */ + data.put("serviceId", "getOtherCollection"); + data.put("COLLECTION_TYPE", "Community Hall"); + data.put("TOTALTRANSACTIONCODE", "450310000"); +// /end of static/ +// /unique data to be send/ + data.put("ASSESSMENTNO", assesNo); + data.put("UNIQUERECEIPTID", res.getBookingId()); + data.put("TRANSACTIONNO", payment.getTransactionId()); + data.put("TRANSACTIONREFNO", res.getTpslTxnId()); + data.put("TRANSACTIONDATE", txDate); //payment date format dd/mm/yyyy -> 19/02/2025 + data.put("TOTALTRANSACTIONAMOUNT", payment.getBookingDetails().getAmountReceived()); + + data.put("MSTRCODEONE", "061"); + data.put("SPLITAMOUNTONE", payment.getBookingDetails().getHallAmount()); + data.put("MSTRCODETWO", "062"); + data.put("SPLITAMOUNTTWO", payment.getBookingDetails().getDepositAmount()); + data.put("MSTRCODETHREE", "063"); + data.put("SPLITAMOUNTTHREE", payment.getBookingDetails().getGst()); +// /Amount Collected from party/ + data.put("PARTYNAME", payment.getBookingDetails().getUsers().getName()); + data.put("PARTYADDRESS", payment.getBookingDetails().getUsers().getStreet() + "," + + payment.getBookingDetails().getUsers().getArea() + "," + payment.getBookingDetails().getUsers().getLocation() + "," + + payment.getBookingDetails().getUsers().getPinCode()); + data.put("PARTYMOBILE", payment.getBookingDetails().getUsers().getMobileNo()); + /* end */ + System.out.println(data); + System.out.println(appConfig.getCommErpUrl()); +// ResponseEntity stringResponseEntity = restTemplate.postForEntity(appConfig.getErpUrl(), data, String.class); +// System.out.println(stringResponseEntity.getBody()); + + erpData.setTx_id(payment.getTransactionId()); + erpData.setBooking_det_booking_id(res.getBookingId()); + erpData.setStatus(true); + erpData.setCdate(LocalDate.now()); + erpData.setPay_status(1); + erpPostDataRepository.save(erpData); + + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(appConfig.getCommErpUrl()); + for (Map.Entry entry : data.entrySet()) { + builder.queryParam(entry.getKey(), entry.getValue()); + } + + String urlMsg = builder.toUriString(); + System.out.println(urlMsg); + + try { + HttpURLConnection connection = null; + + URL url = new URL(urlMsg); + connection = (HttpURLConnection) url.openConnection(); + connection.setRequestMethod("GET"); + + int responseCode = connection.getResponseCode(); +// response=responseCode+""; + System.out.println("Response Code: " + responseCode); + + if (responseCode == HttpURLConnection.HTTP_OK) { // 200 OK + BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream())); + String inputLine; + StringBuilder response = new StringBuilder(); + while ((inputLine = in.readLine()) != null) { + response.append(inputLine); + } + in.close(); + System.out.println("Response: " + response.toString()); + + ObjectMapper objectMapper = new ObjectMapper(); + JsonNode jsonNode = objectMapper.readTree(response.toString()); + + String resultStatus = jsonNode.get("ResultStatus").asText(); + + if (!resultStatus.isEmpty() && resultStatus.equals("false")) { + erpData.setStatus(false); + erpPostDataRepository.save(erpData); + } + + } else { + System.out.println("GET request failed."); + } + + } catch (Exception e) { + e.printStackTrace(); + } + } + @PostMapping(value = "/additionaldamage-response") - public String additionaldamagePaymentresponse(Model model, @RequestParam(required = false) String msg) throws NoSuchAlgorithmException{ + public String additionaldamagePaymentresponse(Model model, @RequestParam(required = false) String msg) throws NoSuchAlgorithmException { - - String salt = this.paymentConfig.getEncryptionKey(); + String salt = this.paymentConfig.getEncryptionKey(); - String confirmToken=""; + String confirmToken = ""; String status = this.paymentConfig.getTransactionSuccessCode(); String s = new String(msg); String c = new String(); - String res[] =s.split("\\|"); + String res[] = s.split("\\|"); - TransactionResponse response = this.paymentService.getTransactionResponseByTxansactionId(res[3],"temp"); - ExtraPayments payment=new ExtraPayments(); + TransactionResponse response = this.paymentService.getTransactionResponseByTxansactionId(res[3], "temp"); + ExtraPayments payment = new ExtraPayments(); payment.setTransactionId(response.getTxansactionId()); - double amount=0; - - - for(int i=0;i data = new TreeMap<>(); + /*static mandatory input to be sent */ + data.put("serviceId", "getOtherCollection"); + data.put("COLLECTION_TYPE", "Community Hall"); + data.put("TOTALTRANSACTIONCODE", "450310000"); +// /end of static/ +// /unique data to be send/ + data.put("ASSESSMENTNO", assesNo); + data.put("UNIQUERECEIPTID", res.getBookingId()); + data.put("TRANSACTIONNO", payment.getTransactionId()); + data.put("TRANSACTIONREFNO", res.getTpslTxnId()); + data.put("TRANSACTIONDATE", txDate); //payment date format dd/mm/yyyy -> 19/02/2025 + data.put("TOTALTRANSACTIONAMOUNT", payment.getAmountReceived()); + + data.put("MSTRCODEONE", "061"); + data.put("SPLITAMOUNTONE", 0); + data.put("MSTRCODETWO", "062"); + data.put("SPLITAMOUNTTWO", payment.getAmountReceived()); + data.put("MSTRCODETHREE", "063"); + data.put("SPLITAMOUNTTHREE", 0); +// /Amount Collected from party/ + data.put("PARTYNAME", payment.getBookingDetails().getUsers().getName()); + data.put("PARTYADDRESS", payment.getBookingDetails().getUsers().getStreet() + "," + + payment.getBookingDetails().getUsers().getArea() + "," + payment.getBookingDetails().getUsers().getLocation() + "," + + payment.getBookingDetails().getUsers().getPinCode()); + data.put("PARTYMOBILE", payment.getBookingDetails().getUsers().getMobileNo()); + /* end */ + System.out.println(data); + System.out.println(appConfig.getCommErpUrl()); +// ResponseEntity stringResponseEntity = restTemplate.postForEntity(appConfig.getErpUrl(), data, String.class); +// System.out.println(stringResponseEntity.getBody()); + + erpData.setTx_id(payment.getTransactionId()); + erpData.setBooking_det_booking_id(res.getBookingId()); + erpData.setStatus(true); + erpData.setCdate(LocalDate.now()); + erpData.setPay_status(2); + erpPostDataRepository.save(erpData); + + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(appConfig.getCommErpUrl()); + for (Map.Entry entry : data.entrySet()) { + builder.queryParam(entry.getKey(), entry.getValue()); + } + + String urlMsg = builder.toUriString(); + System.out.println(urlMsg); + + try { + HttpURLConnection connection = null; + + URL url = new URL(urlMsg); + connection = (HttpURLConnection) url.openConnection(); + connection.setRequestMethod("GET"); + + int responseCode = connection.getResponseCode(); +// response=responseCode+""; + System.out.println("Response Code: " + responseCode); + + if (responseCode == HttpURLConnection.HTTP_OK) { // 200 OK + BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream())); + String inputLine; + StringBuilder response = new StringBuilder(); + while ((inputLine = in.readLine()) != null) { + response.append(inputLine); + } + in.close(); + System.out.println("Response: " + response.toString()); + + ObjectMapper objectMapper = new ObjectMapper(); + JsonNode jsonNode = objectMapper.readTree(response.toString()); + + String resultStatus = jsonNode.get("ResultStatus").asText(); + + if (!resultStatus.isEmpty() && resultStatus.equals("false")) { + erpData.setStatus(false); + erpPostDataRepository.save(erpData); + } + + } else { + System.out.println("GET request failed."); + } + + } catch (Exception e) { + e.printStackTrace(); + } + } + @PostMapping(value = "/updatetransaction") - public String updatetransaction(Model model, @RequestParam(required = false) String txansactionId,@RequestParam(required = false) String msg) throws NoSuchAlgorithmException{ + public String updatetransaction(Model model, @RequestParam(required = false) String txansactionId, @RequestParam(required = false) String msg) throws NoSuchAlgorithmException { + + Optional transactionresponse = transactionResRepo.findByTxansactionId(txansactionId); + TransactionResponse transactionres = transactionresponse.get(); + if ("temp".equals(transactionres.getStatusCode()) && !"0300".equals(transactionres.getStatusCode())) { + String salt = this.paymentConfig.getEncryptionKey(); - Optional transactionresponse=transactionResRepo.findByTxansactionId(txansactionId); - TransactionResponse transactionres=transactionresponse.get(); - if ("temp".equals(transactionres.getStatusCode()) && !"0300".equals(transactionres.getStatusCode())) { - String salt = this.paymentConfig.getEncryptionKey(); + String confirmToken = ""; + String status = this.paymentConfig.getTransactionSuccessCode(); + String s = new String(msg); + String c = new String(); + String res[] = s.split("\\|"); - String confirmToken=""; - String status = this.paymentConfig.getTransactionSuccessCode(); - String s = new String(msg); - String c = new String(); - String res[] =s.split("\\|"); + TransactionResponse response = this.paymentService.getTransactionResponseByTxansactionId(res[3], "temp"); + Payments payment = new Payments(); + payment.setTransactionId(response.getTxansactionId()); + double amount = 0; - TransactionResponse response = this.paymentService.getTransactionResponseByTxansactionId(res[3],"temp"); - Payments payment=new Payments(); - payment.setTransactionId(response.getTxansactionId()); - double amount=0; - - - for(int i=0;i transactionresponse = transactionResRepo.findByTxansactionId(txansactionId); diff --git a/src/main/java/com/gcc/communityHall/paymentService/controller/RefundController.java b/src/main/java/com/gcc/communityHall/paymentService/controller/RefundController.java new file mode 100644 index 00000000..16f7a4ea --- /dev/null +++ b/src/main/java/com/gcc/communityHall/paymentService/controller/RefundController.java @@ -0,0 +1,326 @@ +package com.gcc.communityHall.paymentService.controller; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.gcc.communityHall.entity.BookingDetails; +import com.gcc.communityHall.entity.Payments; +import com.gcc.communityHall.entity.RefundTransaction; +import com.gcc.communityHall.paymentService.config.PaymentConfig; +import com.gcc.communityHall.paymentService.entity.RefundClientInfo; +import com.gcc.communityHall.paymentService.entity.RefundResponse; +import com.gcc.communityHall.paymentService.entity.TransactionResponse; +import com.gcc.communityHall.paymentService.entity.TransactionStatusLog; +import com.gcc.communityHall.paymentService.repository.RefundClientInfoRepository; +import com.gcc.communityHall.paymentService.repository.TransRefundResRepository; +import com.gcc.communityHall.paymentService.repository.TransactionResponseRepository; +import com.gcc.communityHall.paymentService.repository.TransactionStatusLogRepository; +import com.gcc.communityHall.paymentService.service.PaymentGatewayServiceImpl; +import com.gcc.communityHall.repository.PaymentsRepository; +import com.gcc.communityHall.service.BookingService; +import com.gcc.communityHall.service.TransactionService; +import com.google.gson.Gson; +import jakarta.transaction.Transactional; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.client.RestTemplate; + +import java.time.LocalDate; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@RestController +public class RefundController { + + @Autowired + public RefundClientInfoRepository refundClientInfoRepository; + + @Autowired + public TransactionResponseRepository transactionResponseRepository; + + @Autowired + private TransactionStatusLogRepository transactionStatusLogRepository; + + @Autowired + private PaymentConfig paymentConfig; + + @Autowired + private PaymentsRepository paymentsRepository; + + @Autowired + private BookingService bookingService; + + @Autowired + private PaymentGatewayServiceImpl paymentGatewayService; + @Autowired + private TransRefundResRepository transRefundResRepository; + + @Autowired + private TransactionService transactionService; + @Autowired + private PaymentGatewayServiceImpl paymentGatewayServiceImpl; + + + @GetMapping(value = "/refundProcess") + public ResponseEntity refundProcess() { + try { + List> pendingTransactions = transactionResponseRepository.getTransactionResponseByStatus("temp"); + + for (Map transactionRecord : pendingTransactions) { + try { + Map status = new HashMap<>(); + Map merchant = new HashMap<>(); + Map transaction = new HashMap<>(); + + status.put("merchant", merchant); + status.put("transaction", transaction); + + merchant.put("identifier", paymentConfig.getMerchantId()); + transaction.put("identifier", transactionRecord.get("txansaction_id")); + transaction.put("requestType", "O"); + transaction.put("token", ""); + transaction.put("reference", ""); + + System.out.println("=====================================" + transactionRecord.get("txansaction_id")); + System.out.println(merchant); + System.out.println(transaction); + System.out.println(status); + System.out.println("======================================"); + String bookingDate = transactionRecord.get("booking_date").toString(); + if (bookingDate != null && !bookingDate.isEmpty()) { + String[] dateParts = bookingDate.split("-"); + String formattedDate = dateParts[2] + "-" + dateParts[1] + "-" + dateParts[0]; + transaction.put("dateTime", formattedDate); + } else { + transaction.put("dateTime", ""); + } + + + Gson gson = new Gson(); + String json = gson.toJson(status); + System.out.println("Hello json " + json); + String encryptHxRefund = paymentGatewayService.encryptHxRefund(json); + + RestTemplate restTemplate = new RestTemplate(); + String url = "https://www.tpsl-india.in/PaymentGateway/merchant2.pg/" + paymentConfig.getMerchantId(); + ResponseEntity postForEntity = restTemplate.postForEntity(url, encryptHxRefund, String.class); + + String decryptHxTRefund = paymentGatewayService.decryptHxTRefund(postForEntity.getBody()); + Map myObj = new ObjectMapper().readValue(decryptHxTRefund, Map.class); + Map paymentMethod = (Map) myObj.get("paymentMethod"); + Map response = (Map) paymentMethod.get("paymentTransaction"); + + System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); + System.out.println("hello2" + response); + System.out.println("hello " + myObj); + System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); + + TransactionStatusLog log = new TransactionStatusLog(); + log.setBookingId(transactionRecord.get("booking_id").toString()); + log.setUserId(transactionRecord.get("user_id").toString()); + log.setTransactionId(transactionRecord.get("txansaction_id").toString()); +// log.setStatus(response.get("status").toString()); + log.setErrorMessage(response.get("errorMessage").toString()); + log.setStatusMessage(response.get("statusMessage").toString()); + log.setStatusCode(response.get("statusCode").toString()); + log.setRefundIdentifier(response.get("refundIdentifier").toString()); + // log.setResponse(response.toString()); + log.setAmount(response.get("amount").toString()); + log.setBalanceAmt(response.get("balanceAmount").toString()); + log.setReceivedDate(response.get("dateTime").toString()); + + TransactionStatusLog saveLog = transactionStatusLogRepository.save(log); + + + TransactionResponse transRes = transactionResponseRepository.findById(Integer.parseInt(transactionRecord.get("id").toString()) + ).orElseThrow(() -> new Exception("TransactionResponse not found")); + + transRes.setStatusCode(log.getStatusCode()); + transRes.setAmount(log.getAmount()); + transRes.setTpslTxnId(response.get("identifier").toString()); + transRes.setResponse(response.toString()); + transRes.setDate(log.getReceivedDate()); + + transactionResponseRepository.save(transRes); + + + Payments payments = paymentsRepository.findByBookingId(Integer.valueOf(String.valueOf(transRes.getBookingId()))); + + System.out.println("payments hello" + payments); + if (payments != null && response.get("statusCode").toString().equals("0300")) { + +// payments.setBookingDetails(payments.getBookingDetails()); + payments.setTransactionId(transRes.getTxansactionId()); + payments.setAmountReceived(Double.parseDouble(response.get("amount").toString())); + payments.setPaymentStatus("Success"); + payments.setCdate(new Date()); + + paymentsRepository.save(payments); + + bookingService.updateBookingStatus(transRes.getBookingId(), BookingDetails.BookingStatus.REFUNDED, "Booking Not Confirmed. Amount will be refunded shortly."); + intiateRefund(transRes.getBookingId(), Integer.parseInt(transRes.getUserId())); + + } else if (response.get("statusCode").toString().equals("0300")) { + payments = new Payments(); + BookingDetails bookingsById = bookingService.getBookingsById(transRes.getBookingId()); + payments.setBookingDetails(bookingsById); + payments.setTransactionId(transRes.getTxansactionId()); + payments.setAmountReceived(Double.parseDouble(response.get("amount").toString())); + payments.setPaymentStatus("Success"); + payments.setCdate(new Date()); + + paymentsRepository.save(payments); + + bookingService.updateBookingStatus(transRes.getBookingId(), BookingDetails.BookingStatus.REFUNDED, "Booking Not Confirmed. Amount will be refunded shortly."); + intiateRefund(transRes.getBookingId(), Integer.parseInt(transRes.getUserId())); + } else { + payments = new Payments(); + payments.setBookingDetails(payments.getBookingDetails()); + payments.setTransactionId(transRes.getTxansactionId()); + try { + payments.setAmountReceived(Double.parseDouble(response.get("amount") != null ? response.get("amount").toString() : "0"));//error here + }catch (Exception e ){ + payments.setAmountReceived(0); + } + payments.setPaymentStatus("Not Completed"); + payments.setCdate(new Date()); + + paymentsRepository.save(payments); + System.out.println("bookingId "+transRes.getBookingId()); + bookingService.updateBookingStatus(transRes.getBookingId(), BookingDetails.BookingStatus.PAYMENT_FAILURE, "Booking Not Confirmed. Amount Not Received."); + + + } + updateRefundInfo(response, log); + + } catch (Exception ex) { + System.err.println("Error processing transaction record: " + ex.getMessage()); + ex.printStackTrace(); + } + } + } catch (Exception e) { + System.err.println("Error fetching or saving payment status: " + e.getMessage()); + e.printStackTrace(); + } + return ResponseEntity.ok("refundProcess"); + + } + + + public void updateRefundInfo(Map response, TransactionStatusLog log) { + + if (response.get("refundDdetails") != null) { + + Map refundInfo = (Map) response.get("refundDdetails"); + List> refundDetails = (List>) refundInfo.get("RefundDetails"); + System.out.println("inifcon :" + refundDetails); + if (refundDetails != null && !refundDetails.isEmpty()) { + RefundResponse refundResponse = new RefundResponse(); + refundResponse.setAmount(response.get("amount") != null ? response.get("amount").toString() : ""); + refundResponse.setBalaceAmount(response.get("balanceAmount") != null ? response.get("balanceAmount").toString() : ""); + refundResponse.setTxansactionId(log.getTransactionId()); + + Map mapRef = refundDetails.get(refundDetails.size() - 1); + LocalDate df = LocalDate.now(); + try { + df = LocalDate.parse(mapRef.get("REF_TXN_DATE").toString()); + } catch (Exception e) { + df = LocalDate.now(); + } + ; + refundResponse.setDate(df); + if (mapRef.get("STATUS") != null && mapRef.get("STATUS").toString().equals("INITIATED")) { + refundResponse.setStatusCode("0400"); + } else { + refundResponse.setStatusCode("0399"); + } + refundResponse.setResponse(refundDetails.toString()); + refundResponse.setBookingId(Integer.parseInt(log.getBookingId())); + refundResponse.setUserId(log.getUserId()); + RefundResponse saverRefundResponse = transRefundResRepository.save(refundResponse); + + Double amt = Double.parseDouble(response.get("amount").toString()); + Double balAmt = Double.parseDouble(response.get("balanceAmount").toString()); + if (amt != balAmt) { + RefundTransaction refundTrans = transactionService.getRefundTrans(saverRefundResponse.getBookingId()); + if (refundTrans != null) { + + refundTrans.setAmountRefunded(amt - balAmt); + refundTrans.setRefundStatus("0400"); + refundTrans.setRefundIdentifier(response.get("refundIdentifier").toString()); + refundTrans.setCdate(new Date()); + + + transactionService.saveRefundTransaction(refundTrans); + } else { + refundTrans = new RefundTransaction(); + refundTrans.setAmountRefunded(amt - balAmt); + refundTrans.setRefundStatus("0400"); + refundTrans.setRefundIdentifier(response.get("refundIdentifier").toString()); + refundTrans.setCdate(new Date()); + refundTrans.setTransactionId(log.getTransactionId()); + BookingDetails bookingsById = bookingService.getBookingsById(Integer.parseInt(log.getBookingId())); + + refundTrans.setBookingDetails(bookingsById); + transactionService.saveRefundTransaction(refundTrans); + + + } + bookingService.updateRefundStatus(saverRefundResponse.getBookingId(), BookingDetails.RefundStatus.COMPLETED); + } + + saveRefundClientInfo(refundDetails, log.getUserId(), log.getBookingId(), log.getTransactionId()); + } + + + } + + + } + + public String saveRefundClientInfo(List> refundDetail, String userId, String bookingId, String transactionId) { + + + if (refundDetail == null || refundDetail.isEmpty()) { + return "error"; + } + + + for (Map refund : refundDetail) { + + RefundClientInfo refundClientInfo = new RefundClientInfo(); + refundClientInfo.setUserId(Integer.parseInt(userId)); + refundClientInfo.setBookingId(Integer.parseInt(bookingId)); + refundClientInfo.setTransactionId(transactionId); + refundClientInfo.setClntRfndId(refund.get("clnt_rfnd_id") != null ? refund.get("clnt_rfnd_id").toString() : ""); + refundClientInfo.setArnNo(refund.get("ARN_Number") != null ? refund.get("ARN_Number").toString() : ""); + refundClientInfo.setGetRefTxnDate(refund.get("REF_TXN_DATE") != null ? refund.get("REF_TXN_DATE").toString() : ""); + refundClientInfo.setRefTxnAmt(refund.get("REF_TXN_AMT") != null ? refund.get("REF_TXN_AMT").toString() : ""); + refundClientInfo.setRefTxnId(refund.get("REF_TXN_ID") != null ? refund.get("REF_TXN_ID").toString() : ""); + refundClientInfo.setStatus(refund.get("STATUS") != null ? refund.get("STATUS").toString() : ""); + refundClientInfo.setSrno(refund.get("SR_NO") != null ? refund.get("SR_NO").toString() : ""); + + refundClientInfoRepository.save(refundClientInfo); + + } + return "success"; + + } + + @Transactional + public void intiateRefund(int bookingId, int userId) throws Exception { + String s = paymentGatewayServiceImpl.refundTheAmount(bookingId, userId); + if (s.equals("Refunded")) { + bookingService.updateRefundStatus(bookingId, BookingDetails.RefundStatus.COMPLETED); + + } else { + bookingService.updateRefundStatus(bookingId, BookingDetails.RefundStatus.FAILURE); + } + + + } +} + + diff --git a/src/main/java/com/gcc/communityHall/paymentService/entity/RefundClientInfo.java b/src/main/java/com/gcc/communityHall/paymentService/entity/RefundClientInfo.java new file mode 100644 index 00000000..2e976b0b --- /dev/null +++ b/src/main/java/com/gcc/communityHall/paymentService/entity/RefundClientInfo.java @@ -0,0 +1,140 @@ +package com.gcc.communityHall.paymentService.entity; + +import jakarta.persistence.*; + +import java.util.Date; + +@Entity +public class RefundClientInfo { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private int id; + private String srno; + private String refTxnId; + private String refTxnAmt; + private String getRefTxnDate; + private String Status; + private String clntRfndId; + private String transactionId; + private String arnNo; + private int bookingId; + private int userId; + @Column(name = "cdate",nullable = false, columnDefinition = "DATETIME DEFAULT CURRENT_TIMESTAMP") + private Date cdate = new Date(); + + public String getClntRfndId() { + return clntRfndId; + } + + public void setClntRfndId(String clntRfndId) { + this.clntRfndId = clntRfndId; + } + + public String getTransactionId() { + return transactionId; + } + + public void setTransactionId(String transactionId) { + this.transactionId = transactionId; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getSrno() { + return srno; + } + + public void setSrno(String srno) { + this.srno = srno; + } + + public String getRefTxnId() { + return refTxnId; + } + + public void setRefTxnId(String refTxnId) { + this.refTxnId = refTxnId; + } + + public String getRefTxnAmt() { + return refTxnAmt; + } + + public void setRefTxnAmt(String refTxnAmt) { + this.refTxnAmt = refTxnAmt; + } + + public String getGetRefTxnDate() { + return getRefTxnDate; + } + + public void setGetRefTxnDate(String getRefTxnDate) { + this.getRefTxnDate = getRefTxnDate; + } + + public String getStatus() { + return Status; + } + + public void setStatus(String status) { + Status = status; + } + + + + public String getArnNo() { + return arnNo; + } + + public void setArnNo(String arnNo) { + this.arnNo = arnNo; + } + + public int getBookingId() { + return bookingId; + } + + public void setBookingId(int bookingId) { + this.bookingId = bookingId; + } + + public int getUserId() { + return userId; + } + + public void setUserId(int userId) { + this.userId = userId; + } + + public Date getCdate() { + return cdate; + } + + public void setCdate(Date cdate) { + this.cdate = cdate; + } + + @Override + public String toString() { + return "RefundClientInfo{" + + "id=" + id + + ", srno='" + srno + '\'' + + ", refTxnId='" + refTxnId + '\'' + + ", refTxnAmt='" + refTxnAmt + '\'' + + ", getRefTxnDate='" + getRefTxnDate + '\'' + + ", Status='" + Status + '\'' + + ", clntRfndId='" + clntRfndId + '\'' + + ", arnNo='" + arnNo + '\'' + + ", bookingId=" + bookingId + + ", userId=" + userId + + ", cdate=" + cdate + + '}'; + } +} diff --git a/src/main/java/com/gcc/communityHall/paymentService/entity/TransactionResponse.java b/src/main/java/com/gcc/communityHall/paymentService/entity/TransactionResponse.java index b2b69577..b899b89a 100644 --- a/src/main/java/com/gcc/communityHall/paymentService/entity/TransactionResponse.java +++ b/src/main/java/com/gcc/communityHall/paymentService/entity/TransactionResponse.java @@ -1,10 +1,8 @@ package com.gcc.communityHall.paymentService.entity; -import jakarta.persistence.Column; -import jakarta.persistence.Entity; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.GenerationType; -import jakarta.persistence.Id; +import jakarta.persistence.*; + +import java.time.LocalDateTime; @Entity public class TransactionResponse { @@ -24,12 +22,23 @@ public class TransactionResponse { private String response; private String Amount; + @Column(name = "cdate",nullable = false, columnDefinition = "DATETIME DEFAULT CURRENT_TIMESTAMP") + private LocalDateTime cdate = LocalDateTime.now(); + + public LocalDateTime getCdate() { + return cdate; + } + + public void setCdate(LocalDateTime cdate) { + this.cdate = cdate; + } + public TransactionResponse() { } - public TransactionResponse(Integer id, String userId, int bookingId,int hallId, String txansactionId, String statusCode, - String tpslTxnId, String date, String response, String amount) { + public TransactionResponse(Integer id, String userId, int bookingId, int hallId, String txansactionId, String statusCode, + String tpslTxnId, String date, String response, String amount) { super(); this.id = id; this.userId = userId; diff --git a/src/main/java/com/gcc/communityHall/paymentService/entity/TransactionStatusLog.java b/src/main/java/com/gcc/communityHall/paymentService/entity/TransactionStatusLog.java new file mode 100644 index 00000000..f1e46a4a --- /dev/null +++ b/src/main/java/com/gcc/communityHall/paymentService/entity/TransactionStatusLog.java @@ -0,0 +1,160 @@ +package com.gcc.communityHall.paymentService.entity; + +import jakarta.persistence.*; + +import java.time.LocalDateTime; + +@Entity + +public class TransactionStatusLog { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; + + private String transactionId; + private String bookingId; + private String userId; + private String status; + private String errorMessage; + private String statusMessage; + private String statusCode; + private String refundIdentifier; + @Column(columnDefinition = "TEXT") + private String response; + private String amount; + private String balanceAmt; + private String receivedDate; + + @Column(name = "cdate",nullable = false, columnDefinition = "DATETIME DEFAULT CURRENT_TIMESTAMP") + private LocalDateTime cdate = LocalDateTime.now(); + + public String getStatusCode() { + return statusCode; + } + + public void setStatusCode(String statusCode) { + this.statusCode = statusCode; + } + + public Integer getId() { + return id; + } + + public String getTransactionId() { + return transactionId; + } + + public String getBookingId() { + return bookingId; + } + + public String getUserId() { + return userId; + } + + public String getStatus() { + return status; + } + + public String getErrorMessage() { + return errorMessage; + } + + public String getStatusMessage() { + return statusMessage; + } + + public void setId(Integer id) { + this.id = id; + } + + public void setTransactionId(String transactionId) { + this.transactionId = transactionId; + } + + public void setBookingId(String bookingId) { + this.bookingId = bookingId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public void setStatus(String status) { + this.status = status; + + } + + public void setErrorMessage(String errorMessage) { + this.errorMessage = errorMessage; + } + + public void setStatusMessage(String statusMessage) { + this.statusMessage = statusMessage; + } + + public String getRefundIdentifier() { + return refundIdentifier; + } + + public void setRefundIdentifier(String refundIdentifier) { + this.refundIdentifier = refundIdentifier; + } + + public String getResponse() { + return response; + } + + public void setResponse(String response) { + this.response = response; + } + + public LocalDateTime getCdate() { + return cdate; + } + + public void setCdate(LocalDateTime cdate) { + this.cdate = cdate; + } + + public String getAmount() { + return amount; + } + + public void setAmount(String amount) { + this.amount = amount; + } + + public String getBalanceAmt() { + return balanceAmt; + } + + public void setBalanceAmt(String balanceAmt) { + this.balanceAmt = balanceAmt; + } + + public String getReceivedDate() { + return receivedDate; + } + + public void setReceivedDate(String receivedDate) { + this.receivedDate = receivedDate; + } + + @Override + public String toString() { + return "TransactionStatusLog{" + + "id=" + id + + ", transactionId='" + transactionId + '\'' + + ", bookingId='" + bookingId + '\'' + + ", userId='" + userId + '\'' + + ", status='" + status + '\'' + + ", errorMessage='" + errorMessage + '\'' + + ", statusMessage='" + statusMessage + '\'' + + ", statusCode='" + statusCode + '\'' + + ", refundIdentifier='" + refundIdentifier + '\'' + + ", cdate='" + cdate + '\'' + + '}'; + } +} diff --git a/src/main/java/com/gcc/communityHall/paymentService/repository/RefundClientInfoRepository.java b/src/main/java/com/gcc/communityHall/paymentService/repository/RefundClientInfoRepository.java new file mode 100644 index 00000000..d87bfe71 --- /dev/null +++ b/src/main/java/com/gcc/communityHall/paymentService/repository/RefundClientInfoRepository.java @@ -0,0 +1,8 @@ +package com.gcc.communityHall.paymentService.repository; + + +import com.gcc.communityHall.paymentService.entity.RefundClientInfo; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface RefundClientInfoRepository extends JpaRepository { +} diff --git a/src/main/java/com/gcc/communityHall/paymentService/repository/TransactionResponseRepository.java b/src/main/java/com/gcc/communityHall/paymentService/repository/TransactionResponseRepository.java index 75769995..bb71977f 100644 --- a/src/main/java/com/gcc/communityHall/paymentService/repository/TransactionResponseRepository.java +++ b/src/main/java/com/gcc/communityHall/paymentService/repository/TransactionResponseRepository.java @@ -1,6 +1,7 @@ package com.gcc.communityHall.paymentService.repository; import java.util.List; +import java.util.Map; import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; @@ -53,4 +54,18 @@ public interface TransactionResponseRepository extends JpaRepository> getTransactionResponseByStatus(String status); + + + @Query(value = "SELECT tr.id, tr.amount, tr.booking_id, tr.hall_id, tr.response, tr.tpsl_txn_id, tr.txansaction_id, tr.cdate, " + + "tr.user_id, bd.booking_date FROM transaction_response tr " + + "INNER JOIN booking_details bd ON tr.booking_id = bd.booking_id " + + "WHERE tr.status_code = 'temp' AND tr.cdate < DATE_SUB(NOW(), INTERVAL 1 HOUR);", nativeQuery = true) + List> getTransResBycdateandStatus(String status); } diff --git a/src/main/java/com/gcc/communityHall/paymentService/repository/TransactionStatusLogRepository.java b/src/main/java/com/gcc/communityHall/paymentService/repository/TransactionStatusLogRepository.java new file mode 100644 index 00000000..223c6f4d --- /dev/null +++ b/src/main/java/com/gcc/communityHall/paymentService/repository/TransactionStatusLogRepository.java @@ -0,0 +1,7 @@ +package com.gcc.communityHall.paymentService.repository; + +import com.gcc.communityHall.paymentService.entity.TransactionStatusLog; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface TransactionStatusLogRepository extends JpaRepository { +} \ No newline at end of file diff --git a/src/main/java/com/gcc/communityHall/paymentService/scheduler/ERPScheduler.java b/src/main/java/com/gcc/communityHall/paymentService/scheduler/ERPScheduler.java new file mode 100644 index 00000000..50d6eba5 --- /dev/null +++ b/src/main/java/com/gcc/communityHall/paymentService/scheduler/ERPScheduler.java @@ -0,0 +1,291 @@ +package com.gcc.communityHall.paymentService.scheduler; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.gcc.communityHall.entity.BookingDetails; +import com.gcc.communityHall.entity.ExtraPayments; +import com.gcc.communityHall.entity.Payments; +import com.gcc.communityHall.entity.erpPostData; +import com.gcc.communityHall.others.AppConfig; +import com.gcc.communityHall.paymentService.entity.TransactionResponse; +import com.gcc.communityHall.paymentService.repository.TransactionResponseRepository; +import com.gcc.communityHall.repository.ErpPostDataRepository; +import com.gcc.communityHall.repository.ExtraPaymentsRepository; +import com.gcc.communityHall.repository.PaymentsRepository; +import com.gcc.communityHall.service.BookingService; +import com.gcc.communityHall.service.PaymentsService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.annotation.EnableScheduling; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; +import org.springframework.stereotype.Service; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.client.RestTemplate; +import org.springframework.web.util.UriComponentsBuilder; + +import javax.swing.text.html.Option; +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.net.HttpURLConnection; +import java.net.URL; +import java.text.SimpleDateFormat; +import java.time.LocalDate; +import java.util.*; + +@Component +//@EnableScheduling +public class ERPScheduler { + + @Autowired + private ErpPostDataRepository erpPostDataRepository; + + @Autowired + private AppConfig appConfig; + + @Autowired + private PaymentsRepository paymentsRepository; + + @Autowired + private TransactionResponseRepository transactionResponseRepository; + + @Autowired + private ExtraPaymentsRepository extraPaymentsRepository; + + + @Scheduled(fixedRate = 30000) + public void checkERPPostData() { + + Payments payment = new Payments(); + ExtraPayments expayment = new ExtraPayments(); + + List notpostedlist = erpPostDataRepository.getNotPostedDetails(); + + System.out.println("notpostedlist....." + notpostedlist); + + if (!notpostedlist.isEmpty()) { + for (erpPostData data : notpostedlist) { + + Long bookingId = (long) data.getBooking_det_booking_id(); + String txId = data.getTx_id(); + int status = data.getPay_status(); + + if (bookingId == null) { + System.out.println("Invalid Booking ID: " + bookingId); + } else { + System.out.println("Processing Booking ID: " + bookingId); + } + if (status == 1) { + payment = paymentsRepository.findByBookingId(Math.toIntExact(bookingId)); + } else if (status == 2) { + expayment = extraPaymentsRepository.getExtraPaymentsByBookingId(Math.toIntExact(bookingId)).orElse(null); + } + // TransactionResponse txRes = transactionResponseRepository.findById(Integer.valueOf(txId)).orElse(null); + + TransactionResponse txRes = transactionResponseRepository.findByTxansactionId(txId).orElse(null); + + if (payment == null) { + System.out.println("No Payment found for Booking ID: " + bookingId); + } + if (txRes == null) { + System.out.println("No Transaction Response found for TX ID: " + txId); + } + if (expayment == null) { + System.out.println("No Extra Payment found for Booking ID: " + bookingId); + } + + + if (status == 1) { + if (payment != null && txRes != null) { + postDataToERP(payment, txRes); + } + } else if (status == 2) { + if (expayment != null && txRes != null) { + postEDDataToERP(expayment, txRes); + } + } + } + } else { + System.out.println("No records found to process."); + } + } + + public void postDataToERP(Payments payment, TransactionResponse res) { + System.out.println("postDataToERP..."); + + erpPostData erpData = new erpPostData(); + + SimpleDateFormat outputFormat = new SimpleDateFormat("dd/MM/yyyy"); + String txDate = outputFormat.format(payment.getCdate()); + String assesNo = LocalDate.now().getYear() + "/COMM/" + res.getBookingId(); + + Map data = new TreeMap<>(); + /*static mandatory input to be sent */ + data.put("serviceId", "getOtherCollection"); + data.put("COLLECTION_TYPE", "Community Hall"); + data.put("TOTALTRANSACTIONCODE", "450310000"); +// /end of static/ +// /unique data to be send/ + data.put("ASSESSMENTNO", assesNo); + data.put("UNIQUERECEIPTID", res.getBookingId()); + data.put("TRANSACTIONNO", payment.getTransactionId()); + data.put("TRANSACTIONREFNO", res.getTpslTxnId()); + data.put("TRANSACTIONDATE", txDate); //payment date format dd/mm/yyyy -> 19/02/2025 + data.put("TOTALTRANSACTIONAMOUNT", payment.getBookingDetails().getAmountReceived()); + + data.put("MSTRCODEONE", "061"); + data.put("SPLITAMOUNTONE", payment.getBookingDetails().getHallAmount()); + data.put("MSTRCODETWO", "062"); + data.put("SPLITAMOUNTTWO", payment.getBookingDetails().getDepositAmount()); + data.put("MSTRCODETHREE", "063"); + data.put("SPLITAMOUNTTHREE", payment.getBookingDetails().getGst()); +// /Amount Collected from party/ + data.put("PARTYNAME", payment.getBookingDetails().getUsers().getName()); + data.put("PARTYADDRESS", payment.getBookingDetails().getUsers().getStreet() + "," + payment.getBookingDetails().getUsers().getArea() + "," + payment.getBookingDetails().getUsers().getLocation() + "," + payment.getBookingDetails().getUsers().getPinCode()); + data.put("PARTYMOBILE", payment.getBookingDetails().getUsers().getMobileNo()); + /* end */ + System.out.println(data); + System.out.println(appConfig.getCommErpUrl()); +// ResponseEntity stringResponseEntity = restTemplate.postForEntity(appConfig.getErpUrl(), data, String.class); +// System.out.println(stringResponseEntity.getBody()); + + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(appConfig.getCommErpUrl()); + for (Map.Entry entry : data.entrySet()) { + builder.queryParam(entry.getKey(), entry.getValue()); + } + + String urlMsg = builder.toUriString(); + System.out.println(urlMsg); + + try { + HttpURLConnection connection = null; + + URL url = new URL(urlMsg); + connection = (HttpURLConnection) url.openConnection(); + connection.setRequestMethod("GET"); + + int responseCode = connection.getResponseCode(); +// response=responseCode+""; + System.out.println("Response Code: " + responseCode); + + if (responseCode == HttpURLConnection.HTTP_OK) { // 200 OK + BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream())); + String inputLine; + StringBuilder response = new StringBuilder(); + while ((inputLine = in.readLine()) != null) { + response.append(inputLine); + } + in.close(); + System.out.println("Response: " + response.toString()); + + ObjectMapper objectMapper = new ObjectMapper(); + JsonNode jsonNode = objectMapper.readTree(response.toString()); + + String resultStatus = jsonNode.get("ResultStatus").asText(); + + if (!resultStatus.isEmpty() && resultStatus.equals("false")) { + erpPostDataRepository.updateERPStatus(false, erpData.getId()); + } else{ + erpPostDataRepository.updateERPStatus(true,erpData.getId()); + } + + } else { + System.out.println("GET request failed."); + } + + } catch (Exception e) { + e.printStackTrace(); + } + } + + public void postEDDataToERP(ExtraPayments payment, TransactionResponse res) { + System.out.println("Post ED Data to ERP...."); + RestTemplate restTemplate = new RestTemplate(); + erpPostData erpData = new erpPostData(); + + SimpleDateFormat outputFormat = new SimpleDateFormat("dd/MM/yyyy"); + String txDate = outputFormat.format(payment.getCdate()); + String assesNo = LocalDate.now().getYear() + "/COMM/ED/" + res.getBookingId(); + + Map data = new TreeMap<>(); + /*static mandatory input to be sent */ + data.put("serviceId", "getOtherCollection"); + data.put("COLLECTION_TYPE", "Community Hall"); + data.put("TOTALTRANSACTIONCODE", "450310000"); +// /end of static/ +// /unique data to be send/ + data.put("ASSESSMENTNO", assesNo); + data.put("UNIQUERECEIPTID", res.getBookingId()); + data.put("TRANSACTIONNO", payment.getTransactionId()); + data.put("TRANSACTIONREFNO", res.getTpslTxnId()); + data.put("TRANSACTIONDATE", txDate); //payment date format dd/mm/yyyy -> 19/02/2025 + data.put("TOTALTRANSACTIONAMOUNT", payment.getAmountReceived()); + + data.put("MSTRCODEONE", "061"); + data.put("SPLITAMOUNTONE", 0); + data.put("MSTRCODETWO", "062"); + data.put("SPLITAMOUNTTWO", payment.getAmountReceived()); + data.put("MSTRCODETHREE", "063"); + data.put("SPLITAMOUNTTHREE", 0); +// /Amount Collected from party/ + data.put("PARTYNAME", payment.getBookingDetails().getUsers().getName()); + data.put("PARTYADDRESS", payment.getBookingDetails().getUsers().getStreet() + "," + + payment.getBookingDetails().getUsers().getArea() + "," + payment.getBookingDetails().getUsers().getLocation() + "," + + payment.getBookingDetails().getUsers().getPinCode()); + data.put("PARTYMOBILE", payment.getBookingDetails().getUsers().getMobileNo()); + /* end */ + System.out.println(data); + System.out.println(appConfig.getCommErpUrl()); +// ResponseEntity stringResponseEntity = restTemplate.postForEntity(appConfig.getErpUrl(), data, String.class); +// System.out.println(stringResponseEntity.getBody()); + + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(appConfig.getCommErpUrl()); + for (Map.Entry entry : data.entrySet()) { + builder.queryParam(entry.getKey(), entry.getValue()); + } + + String urlMsg = builder.toUriString(); + System.out.println(urlMsg); + + try { + HttpURLConnection connection = null; + + URL url = new URL(urlMsg); + connection = (HttpURLConnection) url.openConnection(); + connection.setRequestMethod("GET"); + + int responseCode = connection.getResponseCode(); +// response=responseCode+""; + System.out.println("Response Code: " + responseCode); + + if (responseCode == HttpURLConnection.HTTP_OK) { // 200 OK + BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream())); + String inputLine; + StringBuilder response = new StringBuilder(); + while ((inputLine = in.readLine()) != null) { + response.append(inputLine); + } + in.close(); + System.out.println("Response: " + response.toString()); + + ObjectMapper objectMapper = new ObjectMapper(); + JsonNode jsonNode = objectMapper.readTree(response.toString()); + + String resultStatus = jsonNode.get("ResultStatus").asText(); + + if (!resultStatus.isEmpty() && resultStatus.equals("false")) { + erpPostDataRepository.updateERPStatus(false,erpData.getId()); + } else{ + erpPostDataRepository.updateERPStatus(true,erpData.getId()); + } + + } else { + System.out.println("GET request failed."); + } + + } catch (Exception e) { + e.printStackTrace(); + } + } +} diff --git a/src/main/java/com/gcc/communityHall/paymentService/scheduler/PaymentStatusScheduler.java b/src/main/java/com/gcc/communityHall/paymentService/scheduler/PaymentStatusScheduler.java new file mode 100644 index 00000000..17367810 --- /dev/null +++ b/src/main/java/com/gcc/communityHall/paymentService/scheduler/PaymentStatusScheduler.java @@ -0,0 +1,335 @@ +package com.gcc.communityHall.paymentService.scheduler;/* +// Import necessary packages +package com.gcc.communityHall.paymentService.Scheduler; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.gcc.communityHall.entity.BookingDetails; +import com.gcc.communityHall.entity.Payments; +import com.gcc.communityHall.entity.RefundTransaction; +import com.gcc.communityHall.paymentService.config.PaymentConfig; +import com.gcc.communityHall.paymentService.entity.RefundClientInfo; +import com.gcc.communityHall.paymentService.entity.RefundResponse; +import com.gcc.communityHall.paymentService.entity.TransactionResponse; +import com.gcc.communityHall.paymentService.entity.TransactionStatusLog; +import com.gcc.communityHall.paymentService.repository.RefundClientInfoRepository; +import com.gcc.communityHall.paymentService.repository.TransRefundResRepository; +import com.gcc.communityHall.paymentService.repository.TransactionResponseRepository; +import com.gcc.communityHall.paymentService.repository.TransactionStatusLogRepository; +import com.gcc.communityHall.paymentService.service.PaymentGatewayServiceImpl; +import com.gcc.communityHall.repository.PaymentsRepository; +import com.gcc.communityHall.service.BookingService; +import com.gcc.communityHall.service.TransactionService; +import com.google.gson.Gson; +import jakarta.transaction.Transactional; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; +import org.springframework.scheduling.annotation.EnableScheduling; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; +import org.springframework.web.client.RestTemplate; + +import java.time.LocalDate; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Component +@EnableScheduling +public class PaymentStatusScheduler { + + @Autowired + public RefundClientInfoRepository refundClientInfoRepository; + + @Autowired + public TransactionResponseRepository transactionResponseRepository; + + @Autowired + private TransactionStatusLogRepository transactionStatusLogRepository; + + @Autowired + private PaymentConfig paymentConfig; + + @Autowired + private PaymentsRepository paymentsRepository; + + @Autowired + private BookingService bookingService; + + @Autowired + private PaymentGatewayServiceImpl paymentGatewayService; + @Autowired + private TransRefundResRepository transRefundResRepository; + + @Autowired + private TransactionService transactionService; + @Autowired + private PaymentGatewayServiceImpl paymentGatewayServiceImpl; + +// @Scheduled(cron = "0 0 0 * * ?", zone = "Asia/Kolkata") //executed at 12:00 AM + // @Scheduled(fixedRate = 900000) + @Scheduled(fixedRate = 30000) + public void fetchAndSavePaymentStatus() { + // System.out.println("Fetching Payment Status...At 12:00 AM IST"); + System.out.println("Fetching Payment Status...At 15 min Testing"); + + try { + List> pendingTransactions = transactionResponseRepository.getTransResBycdateandStatus("temp"); + + for (Map transactionRecord : pendingTransactions) { + try { + Map status = new HashMap<>(); + Map merchant = new HashMap<>(); + Map transaction = new HashMap<>(); + + status.put("merchant", merchant); + status.put("transaction", transaction); + + merchant.put("identifier", paymentConfig.getMerchantId()); + transaction.put("identifier", transactionRecord.get("txansaction_id")); + transaction.put("requestType", "O"); + transaction.put("token", ""); + transaction.put("reference", ""); + + System.out.println("====================================="+ transactionRecord.get("txansaction_id")); + System.out.println(merchant); + System.out.println(transaction); + System.out.println(status); + System.out.println(transactionRecord.toString()); + System.out.println("======================================"); + String bookingDate = transactionRecord.get("booking_date").toString(); + // System.out.println("cdate check"+transactionRecord.get("cdate").toString()); + String cdate = transactionRecord.get("cdate").toString(); + if (cdate != null && !cdate.isEmpty()) { + String[] dateParts1 = cdate.split(" "); + String[] dateParts = dateParts1[0].split("-"); + String formattedDate = dateParts[2] + "-" + dateParts[1] + "-" + dateParts[0]; + transaction.put("dateTime", formattedDate); + System.out.println("formattedDate"+formattedDate); + } else { + transaction.put("dateTime", ""); + } + + + Gson gson = new Gson(); + String json = gson.toJson(status); + System.out.println("Hello json "+json); + String encryptHxRefund = paymentGatewayService.encryptHxRefund(json); + + RestTemplate restTemplate = new RestTemplate(); + String url = "https://www.tpsl-india.in/PaymentGateway/merchant2.pg/" + paymentConfig.getMerchantId(); + ResponseEntity postForEntity = restTemplate.postForEntity(url, encryptHxRefund, String.class); + + String decryptHxTRefund = paymentGatewayService.decryptHxTRefund(postForEntity.getBody()); + Map myObj = new ObjectMapper().readValue(decryptHxTRefund, Map.class); + Map paymentMethod = (Map)myObj.get("paymentMethod"); + Map response = (Map)paymentMethod.get("paymentTransaction"); + + System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); + System.out.println("hello2" + response); + System.out.println("hello "+myObj); + System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); + + TransactionStatusLog log = new TransactionStatusLog(); + log.setBookingId(transactionRecord.get("booking_id").toString()); + log.setUserId(transactionRecord.get("user_id").toString()); + log.setTransactionId(transactionRecord.get("txansaction_id").toString()); +// log.setStatus(response.get("status").toString()); + log.setErrorMessage(response.get("errorMessage").toString()); + log.setStatusMessage(response.get("statusMessage").toString()); + log.setStatusCode(response.get("statusCode").toString()); + log.setRefundIdentifier(response.get("refundIdentifier").toString()); + // log.setResponse(response.toString()); + log.setAmount(response.get("amount").toString()); + log.setBalanceAmt(response.get("balanceAmount").toString()); + log.setReceivedDate(response.get("dateTime").toString()); + + TransactionStatusLog saveLog = transactionStatusLogRepository.save(log); + + + TransactionResponse transRes = transactionResponseRepository.findById(Integer.parseInt(transactionRecord.get("id").toString()) + ).orElseThrow(() -> new Exception("TransactionResponse not found")); + + transRes.setStatusCode(log.getStatusCode()); + transRes.setAmount(log.getAmount()); + transRes.setTpslTxnId(response.get("identifier").toString()); + transRes.setResponse(response.toString()); + transRes.setDate(log.getReceivedDate()); + + transactionResponseRepository.save(transRes); + + + Payments payments = paymentsRepository.findByBookingId(Integer.valueOf(String.valueOf(transRes.getBookingId()))); + + System.out.println("payments hello"+payments); + if(payments!=null && response.get("statusCode").toString().equals("0300")) { + +// payments.setBookingDetails(payments.getBookingDetails()); + payments.setTransactionId(transRes.getTxansactionId()); + payments.setAmountReceived(Double.parseDouble(response.get("amount").toString())); + payments.setPaymentStatus("Success"); + Date date = new Date(payments.getCdate().getTime()); + + //paymentsRepository.updatePaymentInfo(payments.getPaymentId(),payments.getTransactionId(),payments.getAmountReceived(),payments.getPaymentStatus(),transRes.getBookingId()); + + bookingService.updateBookingStatus(transRes.getBookingId(), BookingDetails.BookingStatus.REFUNDED, "Booking Not Confirmed. Amount will be refunded shortly."); + intiateRefund(transRes.getBookingId(),Integer.parseInt(transRes.getUserId())); + + }else if(response.get("statusCode").toString().equals("0300")){ + payments = new Payments(); + + + BookingDetails bookingsById = bookingService.getBookingsById(transRes.getBookingId()); + payments.setBookingDetails(bookingsById); + payments.setTransactionId(transRes.getTxansactionId()); + payments.setAmountReceived(Double.parseDouble(response.get("amount").toString())); + payments.setPaymentStatus("Success"); + payments.setCdate(new Date()); + + //paymentsRepository.insertPaymentinfo(payments.getPaymentId(),payments.getTransactionId(),payments.getAmountReceived(),payments.getPaymentStatus(),transRes.getBookingId(),payments.getCdate() ); + + bookingService.updateBookingStatus(transRes.getBookingId(), BookingDetails.BookingStatus.REFUNDED, "Booking Not Confirmed. Amount will be refunded shortly."); + intiateRefund(transRes.getBookingId(),Integer.parseInt(transRes.getUserId())); + } + + else{ + payments.setBookingDetails(payments.getBookingDetails()); + payments.setTransactionId(transRes.getTxansactionId()); + payments.setAmountReceived(Double.parseDouble(response.get("amount")!=null?response.get("amount").toString():"0")); payments.setPaymentStatus("Not Completed"); + payments.setCdate(new Date()); + + paymentsRepository.save(payments); + bookingService.updateBookingStatus(transRes.getBookingId(), BookingDetails.BookingStatus.PAYMENT_FAILURE, "Booking Not Confirmed. Amount Not Received."); + + + } + updateRefundInfo(response,log); + + } catch (Exception ex) { + System.err.println("Error processing transaction record: " + ex.getMessage()); + ex.printStackTrace(); + } + } + } catch (Exception e) { + System.err.println("Error fetching or saving payment status: " + e.getMessage()); + e.printStackTrace(); + } + + + } + + + public void updateRefundInfo(Map response,TransactionStatusLog log){ + + if(response.get("refundDdetails") != null ){ + + Map refundInfo= (Map) response.get("refundDdetails"); + List> refundDetails = (List>) refundInfo.get("RefundDetails"); + System.out.println("inifcon :"+ refundDetails); + if(refundDetails != null && !refundDetails.isEmpty()){ + RefundResponse refundResponse = new RefundResponse(); + refundResponse.setAmount(response.get("amount")!=null?response.get("amount").toString():""); + refundResponse.setBalaceAmount(response.get("balanceAmount")!=null?response.get("balanceAmount").toString():""); + refundResponse.setTxansactionId(log.getTransactionId()); + + Map mapRef = refundDetails.get(refundDetails.size()-1); + LocalDate df = LocalDate.now(); + try{df =LocalDate.parse(mapRef.get("REF_TXN_DATE").toString());}catch (Exception e){df = LocalDate.now();}; + refundResponse.setDate(df); + if(mapRef.get("STATUS")!=null && mapRef.get("STATUS").toString().equals("INITIATED")){ + refundResponse.setStatusCode("0400"); + }else{ + refundResponse.setStatusCode("0399"); + } + refundResponse.setResponse(refundDetails.toString()); + refundResponse.setBookingId(Integer.parseInt(log.getBookingId())); + refundResponse.setUserId(log.getUserId()); + RefundResponse saverRefundResponse = transRefundResRepository.save(refundResponse); + + Double amt = Double.parseDouble(response.get("amount").toString()); + Double balAmt = Double.parseDouble(response.get("balanceAmount").toString()); + if(amt != balAmt ) { + RefundTransaction refundTrans = transactionService.getRefundTrans(saverRefundResponse.getBookingId()); + if (refundTrans != null) { + + refundTrans.setAmountRefunded(amt - balAmt); + refundTrans.setRefundStatus("0400"); + refundTrans.setRefundIdentifier(response.get("refundIdentifier").toString()); + refundTrans.setCdate(new Date()); + + + transactionService.saveRefundTransaction(refundTrans); + } else { + refundTrans = new RefundTransaction(); + refundTrans.setAmountRefunded(amt - balAmt); + refundTrans.setRefundStatus("0400"); + refundTrans.setRefundIdentifier(response.get("refundIdentifier").toString()); + refundTrans.setCdate(new Date()); + refundTrans.setTransactionId(log.getTransactionId()); + BookingDetails bookingsById = bookingService.getBookingsById(Integer.parseInt(log.getBookingId())); + + refundTrans.setBookingDetails(bookingsById); + transactionService.saveRefundTransaction(refundTrans); + + + } + bookingService.updateRefundStatus(saverRefundResponse.getBookingId(),BookingDetails.RefundStatus.COMPLETED); } + + saveRefundClientInfo(refundDetails,log.getUserId() ,log.getBookingId(), log.getTransactionId()); + } + + + + } + + + } + public String saveRefundClientInfo(List> refundDetail,String userId,String bookingId,String transactionId) { + + + + if (refundDetail == null || refundDetail.isEmpty()) { + return "error"; + } + + + for (Map refund : refundDetail) { + + RefundClientInfo refundClientInfo = new RefundClientInfo(); + refundClientInfo.setUserId(Integer.parseInt(userId)); + refundClientInfo.setBookingId(Integer.parseInt(bookingId)); + refundClientInfo.setTransactionId(transactionId); + refundClientInfo.setClntRfndId(refund.get("clnt_rfnd_id")!=null?refund.get("clnt_rfnd_id").toString():""); + refundClientInfo.setArnNo(refund.get("ARN_Number")!=null?refund.get("ARN_Number").toString():""); + refundClientInfo.setGetRefTxnDate(refund.get("REF_TXN_DATE")!=null?refund.get("REF_TXN_DATE").toString():""); + refundClientInfo.setRefTxnAmt(refund.get("REF_TXN_AMT")!=null?refund.get("REF_TXN_AMT").toString():""); + refundClientInfo.setRefTxnId(refund.get("REF_TXN_ID")!=null?refund.get("REF_TXN_ID").toString():""); + refundClientInfo.setStatus(refund.get("STATUS")!=null?refund.get("STATUS").toString():""); + refundClientInfo.setSrno(refund.get("SR_NO")!=null?refund.get("SR_NO").toString():""); + + refundClientInfoRepository.save(refundClientInfo); + + } + return "success"; + + } + + @Transactional + public void intiateRefund(int bookingId,int userId) throws Exception { + String s = paymentGatewayServiceImpl.refundTheAmount(bookingId, userId); + if(s.equals("Refunded")){ + bookingService.updateRefundStatus(bookingId,BookingDetails.RefundStatus.COMPLETED); + + }else + + { + bookingService.updateRefundStatus(bookingId,BookingDetails.RefundStatus.FAILURE); + } + + + } + + } + + +*/ diff --git a/src/main/java/com/gcc/communityHall/repository/ErpPostDataRepository.java b/src/main/java/com/gcc/communityHall/repository/ErpPostDataRepository.java new file mode 100644 index 00000000..b5d37224 --- /dev/null +++ b/src/main/java/com/gcc/communityHall/repository/ErpPostDataRepository.java @@ -0,0 +1,25 @@ +package com.gcc.communityHall.repository; + +import com.gcc.communityHall.entity.erpPostData; +import jakarta.transaction.Transactional; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Modifying; +import org.springframework.data.jpa.repository.Query; +import org.springframework.stereotype.Repository; + +import javax.swing.text.html.Option; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +@Repository +public interface ErpPostDataRepository extends JpaRepository { + + @Query(value = "SELECT * FROM erp_post_data WHERE status = false", nativeQuery = true) + List getNotPostedDetails(); + + @Modifying + @Transactional + @Query(value = "update erp_post_data set status = ? where id =?", nativeQuery = true) + void updateERPStatus(boolean status, Long id); +} diff --git a/src/main/java/com/gcc/communityHall/repository/ExtraPaymentsRepository.java b/src/main/java/com/gcc/communityHall/repository/ExtraPaymentsRepository.java index 77e80258..448f2b2e 100644 --- a/src/main/java/com/gcc/communityHall/repository/ExtraPaymentsRepository.java +++ b/src/main/java/com/gcc/communityHall/repository/ExtraPaymentsRepository.java @@ -1,12 +1,19 @@ package com.gcc.communityHall.repository; +import com.gcc.communityHall.entity.Payments; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; import org.springframework.stereotype.Repository; import com.gcc.communityHall.entity.EbDetails; import com.gcc.communityHall.entity.ExtraPayments; +import java.util.Optional; + @Repository public interface ExtraPaymentsRepository extends JpaRepository { + @Query(value = "SELECT * FROM extra_payments WHERE booking_details_booking_id = ? ",nativeQuery = true) + Optional getExtraPaymentsByBookingId(int id); + } diff --git a/src/main/java/com/gcc/communityHall/repository/PaymentsRepository.java b/src/main/java/com/gcc/communityHall/repository/PaymentsRepository.java index 74e9245f..11df3bd2 100644 --- a/src/main/java/com/gcc/communityHall/repository/PaymentsRepository.java +++ b/src/main/java/com/gcc/communityHall/repository/PaymentsRepository.java @@ -1,17 +1,17 @@ package com.gcc.communityHall.repository; - -import java.util.List; - +import com.gcc.communityHall.entity.Payments; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Repository; -import com.gcc.communityHall.entity.Payments; +import java.util.List; +import java.util.Optional; @Repository + public interface PaymentsRepository extends JpaRepository { @Query(value = "SELECT * FROM payments WHERE payment_status in ('paid') ",nativeQuery = true) @@ -23,4 +23,6 @@ public interface PaymentsRepository extends JpaRepository { + "WHERE h.zone = :zone", nativeQuery = true) List getPaymentListByzone(@Param("zone") String zone); //List findAllWithBookingDetailsAndUsers(); + @Query(value = "select * from payments where booking_details_booking_id=?",nativeQuery = true) + Payments findByBookingId(int bookingId); } \ No newline at end of file diff --git a/src/main/java/com/gcc/communityHall/repository/RefundTransactionRepository.java b/src/main/java/com/gcc/communityHall/repository/RefundTransactionRepository.java index 29d4dc46..4916144e 100644 --- a/src/main/java/com/gcc/communityHall/repository/RefundTransactionRepository.java +++ b/src/main/java/com/gcc/communityHall/repository/RefundTransactionRepository.java @@ -1,16 +1,16 @@ package com.gcc.communityHall.repository; -import java.util.List; - +import com.gcc.communityHall.entity.RefundTransaction; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; import org.springframework.stereotype.Repository; -import com.gcc.communityHall.entity.RefundTransaction; - @Repository public interface RefundTransactionRepository extends JpaRepository { + @Query(value = "select * from refund_transaction where booking_details_booking_id = ?",nativeQuery = true) + RefundTransaction findByBookingId(int bookingId); + } diff --git a/src/main/java/com/gcc/communityHall/service/Impl/PaymentsServiceImpl.java b/src/main/java/com/gcc/communityHall/service/Impl/PaymentsServiceImpl.java index 1c117ee9..efda0ec6 100644 --- a/src/main/java/com/gcc/communityHall/service/Impl/PaymentsServiceImpl.java +++ b/src/main/java/com/gcc/communityHall/service/Impl/PaymentsServiceImpl.java @@ -87,4 +87,5 @@ public class PaymentsServiceImpl implements PaymentsService{ return paymentsDTO; } + } diff --git a/src/main/java/com/gcc/communityHall/service/Impl/TransactionServiceImpl.java b/src/main/java/com/gcc/communityHall/service/Impl/TransactionServiceImpl.java index 101de001..cc316115 100644 --- a/src/main/java/com/gcc/communityHall/service/Impl/TransactionServiceImpl.java +++ b/src/main/java/com/gcc/communityHall/service/Impl/TransactionServiceImpl.java @@ -1,4 +1,24 @@ package com.gcc.communityHall.service.Impl; -public class TransactionServiceImpl { +import com.gcc.communityHall.entity.RefundTransaction; +import com.gcc.communityHall.repository.RefundTransactionRepository; +import com.gcc.communityHall.service.TransactionService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class TransactionServiceImpl implements TransactionService { + + @Autowired + private RefundTransactionRepository refundTransactionRepository; + + @Override + public RefundTransaction getRefundTrans(int bookingId) { + return refundTransactionRepository.findByBookingId(bookingId); + } + + @Override + public RefundTransaction saveRefundTransaction(RefundTransaction refundTransaction) { + return refundTransactionRepository.save(refundTransaction); + } } diff --git a/src/main/java/com/gcc/communityHall/service/PaymentsService.java b/src/main/java/com/gcc/communityHall/service/PaymentsService.java index 98265195..c4676faf 100644 --- a/src/main/java/com/gcc/communityHall/service/PaymentsService.java +++ b/src/main/java/com/gcc/communityHall/service/PaymentsService.java @@ -10,5 +10,4 @@ public interface PaymentsService { List getPaymentsByZone(String zone); List getAllPaymentDetails(); - } \ No newline at end of file diff --git a/src/main/java/com/gcc/communityHall/service/TransactionService.java b/src/main/java/com/gcc/communityHall/service/TransactionService.java index 134bf1f5..9eb4d32f 100644 --- a/src/main/java/com/gcc/communityHall/service/TransactionService.java +++ b/src/main/java/com/gcc/communityHall/service/TransactionService.java @@ -1,4 +1,10 @@ package com.gcc.communityHall.service; +import com.gcc.communityHall.entity.RefundTransaction; + public interface TransactionService { + + RefundTransaction getRefundTrans(int bookingId); + + RefundTransaction saveRefundTransaction(RefundTransaction refundTransaction); } diff --git a/src/main/resources/application-dev.properties b/src/main/resources/application-dev.properties index ea56de47..b5443d00 100644 --- a/src/main/resources/application-dev.properties +++ b/src/main/resources/application-dev.properties @@ -69,4 +69,5 @@ app.getOtpUrl=https://tmegov.onex-aura.com/api/sms? app.manualRefundCode=8520 -app.fullUrl=http://localhost:8080 \ No newline at end of file +app.fullUrl=http://localhost:8080 +app.commErpUrl=http://coc-staging.egovernments.org:9980/pgr/external/mobileservice \ No newline at end of file diff --git a/src/main/resources/paymentConfig.properties b/src/main/resources/paymentConfig.properties index 19408fa1..a1a4e5b1 100644 --- a/src/main/resources/paymentConfig.properties +++ b/src/main/resources/paymentConfig.properties @@ -1,15 +1,15 @@ -payment.worldline.merchantId=T955031 -payment.worldline.encryptionKey=1025180466GPADTD -payment.worldline.encryptionIV=3232693456UWOWHC -payment.worldline.schemeCode=FIRST -payment.worldline.merchantName=Greater Chennai Corporation -payment.worldline.transactionSuccessCode=0300 -payment.worldline.refundSuccessCode=0400 - -#payment.worldline.merchantId=L1037717 -#payment.worldline.encryptionKey=6207149300MFLGNY -#payment.worldline.encryptionIV=3422107798TKQCNG +#payment.worldline.merchantId=T955031 +#payment.worldline.encryptionKey=1025180466GPADTD +#payment.worldline.encryptionIV=3232693456UWOWHC #payment.worldline.schemeCode=FIRST #payment.worldline.merchantName=Greater Chennai Corporation #payment.worldline.transactionSuccessCode=0300 #payment.worldline.refundSuccessCode=0400 + +payment.worldline.merchantId=T1037717 +payment.worldline.encryptionKey=6207149300MFLGNY +payment.worldline.encryptionIV=3422107798TKQCNG +payment.worldline.schemeCode=FIRST +payment.worldline.merchantName=Greater Chennai Corporation +payment.worldline.transactionSuccessCode=0300 +payment.worldline.refundSuccessCode=0400 diff --git a/src/main/resources/templates/officiallogin.html b/src/main/resources/templates/officiallogin.html index b4e60152..ae12f748 100644 --- a/src/main/resources/templates/officiallogin.html +++ b/src/main/resources/templates/officiallogin.html @@ -4,492 +4,712 @@ - - -
- - -
- -
-
-
- -
-
+ + + +
+ + +
+ +
+
+
+ +
+
- -
-
-
- -
-
- - Logo Sm - -
- -
- பெருநகர சென்னை மாநகராட்சி -
-
- -
-
- -

-
- - - - - - +
-
- -
-

- - - - -
- -
- - -
-
-
- -
- - -
- - - - - - - - - - - + + + + + + + + - \ No newline at end of file + +