working web based and intent
This commit is contained in:
@@ -1,17 +1,23 @@
|
||||
package com.billpaymentservice.bbps.controller;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.billpaymentservice.bbps.dto.ResponseModel;
|
||||
import com.billpaymentservice.bbps.dto.request.PaymentStartUserRequest;
|
||||
import com.billpaymentservice.bbps.dto.request.CallbackRequest;
|
||||
import com.billpaymentservice.bbps.service.PaymentStartService;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/payment")
|
||||
public class PaymentStartController {
|
||||
private final PaymentStartService paymentStartService;
|
||||
|
||||
@@ -20,12 +26,28 @@ public class PaymentStartController {
|
||||
}
|
||||
|
||||
@PostMapping(value = "/startWebPayment", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<ResponseModel> startPayment(@Validated @RequestBody PaymentStartUserRequest paymentStartUserRequest) {
|
||||
public ResponseEntity<ResponseModel> startWebPayment(@Validated @RequestBody PaymentStartUserRequest paymentStartUserRequest) {
|
||||
|
||||
ResponseModel response = paymentStartService.startWebPayment(paymentStartUserRequest);
|
||||
return ResponseEntity.ok(response);
|
||||
}
|
||||
|
||||
@PostMapping(value = "/callback/startPayment", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Map<String, String>> handleCallback(@RequestBody CallbackRequest callbackRequest) {
|
||||
ResponseModel resp = paymentStartService.handleStartCallback(callbackRequest);
|
||||
Map<String, String> result = new HashMap<>();
|
||||
// Use the status field from ResponseModel as merchant status code string
|
||||
result.put("status", resp.getStatus());
|
||||
return ResponseEntity.ok(result);
|
||||
}
|
||||
|
||||
@PostMapping(value = "/startIntentPayment", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<ResponseModel> startIntentPayment(@Validated @RequestBody PaymentStartUserRequest paymentStartUserRequest) {
|
||||
if (this.paymentStartService == null) {
|
||||
// Defensive: if bean not injected, return failure
|
||||
return ResponseEntity.badRequest().body(new ResponseModel("PaymentStartService not available", "FAILED", 400, null));
|
||||
}
|
||||
ResponseModel response = paymentStartService.startWebPayment(paymentStartUserRequest);
|
||||
ResponseModel response = paymentStartService.startIntentPayment(paymentStartUserRequest);
|
||||
return ResponseEntity.ok(response);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user