I'm trying to pay through a UPI hyperlink like
upi://pay?pa=abc@upi&pn=payeeName&tr=1234&tn=Pay%20to%20payeeName&am=1&mam=1&cu=INR&url=https://test.com/payment/orderId=123456
After the UPI payment is done, the Spring controller which handles the "callback" request to https://test.com/payment/orderId=12345, is not getting called.
So how to get response of UPI Hyperlink payment in Java correctly?
Edit:
This is the controller method. I have also tried @GetMapping
instead of @PostMapping
.
@PostMapping("/payment")
public ModelAndView credPayment(HttpServletRequest request) {
String key = request.getParameter("orderId");
String txnId = request.getParameter("txnId");
String responseCode = request.getParameter("responseCode");
String approvalRefNo = request.getParameter("ApprovalRefNo");
String status = request.getParameter("Status");
String txnRef = request.getParameter("txnRef");
System.out.println("Parameter Names");
while (request.getParameterNames().hasMoreElements()) {
System.out.println(request.getParameterNames().nextElement());
}
System.out.println("Header Names");
while (request.getHeaderNames().hasMoreElements()) {
System.out.println(request.getHeaderNames().nextElement());
}
System.out.println("txnId : "+txnId);
System.out.println("responseCode : "+responseCode);
System.out.println("ApprovalRefNo : "+approvalRefNo);
System.out.println("Status : "+status);
System.out.println("txnRef : "+txnRef);
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("redirect:/");
return modelAndView;
}
If I understood it correctly, your redirect URL is
https://test.com/payment/orderId=123456
And when this is called, you need to get order id value in your controller.
Then try changing your method to something like this:
@GetMapping(value = "/payment/{order}")
public ModelAndView credPayment(@PathVariable("order") String order, HttpServletRequest request) {
System.out.println(order); // prints orderId=123456
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("redirect:/");
return modelAndView;
}
Issue:
You have configured your URL mapping as /payment
only, so anything after that will get excluded from this mapping, eg: /payment/sdfdsfs
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With