Rev 34447 | Blame | Compare with Previous | Last modification | View Log | RSS feed
package com.spice.profitmandi.web.controller;import org.springframework.stereotype.Controller;import org.springframework.transaction.annotation.Transactional;import org.springframework.web.bind.annotation.*;@Controller@RequestMapping("/payments")@Transactional(rollbackFor = Throwable.class)public class PaymentsController {/*@Autowiredprivate ResponseSender<?> responseSender;@Autowiredprivate PineLabService pineLabService;private static final Logger LOGGER = LogManager.getLogger(PaymentsController.class);@PostMapping("/get-emi-options")public ResponseEntity<?> getEmiOptions(@RequestBody CalculateEmiRequest calculateEmiRequest) throws ProfitMandiBusinessException {try {Map<String, Object> params = new HashMap<>();EmiResponse response = null;if (calculateEmiRequest.getProvider().equals("pinelabs")) {params.put("amount_in_paisa", calculateEmiRequest.getAmountInPaisa());params.put("product_details", calculateEmiRequest.getProductDetails());response = pineLabService.getEmiOptions(params);}return responseSender.ok(response);} catch (ProfitMandiBusinessException e){return responseSender.badRequest(e);}}@PostMapping("/emi/plans")public ResponseEntity<?> getEmiPlans(@RequestBody CalculateEmiRequest calculateEmiRequest) throws IOException {Response response;Map<String, Object> params = new HashMap<>();if (calculateEmiRequest.getProvider().equals("pinelabs")) {Map<String, Object> orderAmount = new HashMap<>();orderAmount.put("value", calculateEmiRequest.getAmountInPaisa());orderAmount.put("currency", "INR");params.put("order_amount", orderAmount);ObjectMapper objectMapper = new ObjectMapper();String requestBody = objectMapper.writeValueAsString(params);response = pineLabService.getEMIs(requestBody);LOGGER.info("plural controller response: {}",response);if (response.isSuccessful()){return responseSender.ok(response.body());} else {return responseSender.ok(response.message());}}return responseSender.ok(null);}@PostMapping("/emi/validate")public ResponseEntity<?> validateEmiPlans(@RequestBody ValidateEmiRequest validateEmiRequest) throws IOException {if (validateEmiRequest.getProvider().equals("pinelabs")) {Response response;Map<String, Object> params = new HashMap<>();params.put("order_amount", validateEmiRequest.getOrderAmount());params.put("payment_amount", validateEmiRequest.getPaymentAmount());params.put("offer_data", validateEmiRequest.getOfferData());params.put("payment_method", validateEmiRequest.getPaymentMethod());ObjectMapper objectMapper = new ObjectMapper();String requestBody = objectMapper.writeValueAsString(params);response = pineLabService.getEMIs(requestBody);if (response.isSuccessful()){return responseSender.ok(response.body());} else {return responseSender.ok(response.message());}}return responseSender.ok(null);}@PostMapping("/emi/place-order")public ResponseEntity<?> placeEMIOrder(@RequestBody CreateOrderRequest createOrderRequest) throws IOException {if (createOrderRequest.getProvider().equals("pinelabs")) {Response response;Map<String, Object> params = new HashMap<>();params.put("order_amount", createOrderRequest.getOrderAmount());params.put("pre_auth", false);params.put("callback_url", createOrderRequest.getCallbackUrl());params.put("failure_callback_url", createOrderRequest.getFailureCallbackUrl());params.put("allowed_payment_methods", createOrderRequest.getAllowedPaymentMethods());params.put("notes", createOrderRequest.getNotes());params.put("purchase_details", createOrderRequest.getPurchaseDetails());params.put("cart_coupon_discount_amount", createOrderRequest.getCartCouponDiscountAmount());ObjectMapper objectMapper = new ObjectMapper();String requestBody = objectMapper.writeValueAsString(params);response = pineLabService.placeOrder(requestBody);if (response.isSuccessful()){return responseSender.ok(response.body());} else {return responseSender.ok(response.message());}}return responseSender.ok(null);}@PostMapping("/emi/create-payment")public ResponseEntity<?> placeCreatePayment(@RequestBody CreatePaymentRequest createPaymentRequest) throws IOException {if (createPaymentRequest.getProvider().equals("pinelabs")) {Response response;Map<String, Object> params = new HashMap<>();params.put("payments", createPaymentRequest.getPayments());ObjectMapper objectMapper = new ObjectMapper();String requestBody = objectMapper.writeValueAsString(params);response = pineLabService.placeOrder(requestBody);if (response.isSuccessful()){return responseSender.ok(response.body());} else {return responseSender.ok(response.message());}}return responseSender.ok(null);}*/}