added intentbased pg
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
package com.billpaymentservice.bbps.controller;
|
||||
|
||||
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.RestController;
|
||||
|
||||
import com.billpaymentservice.bbps.dto.ResponseModel;
|
||||
import com.billpaymentservice.bbps.dto.request.PaymentStartUserRequest;
|
||||
import com.billpaymentservice.bbps.service.PaymentStartService;
|
||||
|
||||
@RestController
|
||||
public class PaymentStartController {
|
||||
private final PaymentStartService paymentStartService;
|
||||
|
||||
public PaymentStartController(PaymentStartService paymentStartService) {
|
||||
this.paymentStartService = paymentStartService;
|
||||
}
|
||||
|
||||
@PostMapping(value = "/startWebPayment", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<ResponseModel> startPayment(@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.startPayment(paymentStartUserRequest);
|
||||
return ResponseEntity.ok(response);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user