Class PaymentController

java.lang.Object
com.bank.payment.controllers.PaymentController

@RestController @RequestMapping public class PaymentController extends Object
REST controller for handling payment operations.

Provides endpoints for retrieving, deleting, analyzing, and processing payments via Pix. Delegates business logic to the PaymentService.

  • GET /{idPayment} - Retrieve a payment by its ID
  • DELETE /{idPayment} - Delete a payment by its ID
  • POST /{idAccount}/pix/{pixKey} - Analyze a payment before processing
  • POST /{idAccount}/pix/{pixKey}/direct - Process a direct payment
Since:
1.0.0
Author:
Fernando Cruz Cavina
  • Constructor Details

    • PaymentController

      public PaymentController()
  • Method Details

    • getOnePayment

      @GetMapping("/{idPayment}") public org.springframework.http.ResponseEntity<Object> getOnePayment(@PathVariable("idPayment") Long idPayment)
      Retrieves a payment by its ID.
      Parameters:
      idPayment - the ID of the payment
      Returns:
      a ResponseEntity containing the payment details
    • deletePayment

      @DeleteMapping("/{idPayment}") public org.springframework.http.ResponseEntity<Object> deletePayment(@PathVariable("idPayment") Long idPayment)
      Deletes a payment by its ID.
      Parameters:
      idPayment - the ID of the payment to delete
      Returns:
      a ResponseEntity containing a confirmation message
    • analyzePayment

      @PostMapping("/{idAccount}/pix/{pixKey}") public org.springframework.http.ResponseEntity<Object> analyzePayment(@PathVariable("idAccount") Long idAccount, @PathVariable("pixKey") String pixKey, @RequestBody PaymentAnalyzeDto paymentDto)
      Analyzes a payment before processing, returning a confirmation message.
      Parameters:
      idAccount - the ID of the sender's account
      pixKey - the Pix key of the receiver
      paymentDto - the payment analysis data
      Returns:
      a ResponseEntity containing a confirmation message
    • directPayment

      @PostMapping("/{idAccount}/pix/{pixKey}/direct") public org.springframework.http.ResponseEntity<Object> directPayment(@PathVariable("idAccount") Long idAccount, @PathVariable("pixKey") String pixKey, @RequestBody @Validated PaymentDto paymentDto)
      Processes a direct payment from the sender to the receiver using Pix without any analysis.
      Parameters:
      idAccount - the ID of the sender's account
      pixKey - the Pix key of the receiver
      paymentDto - the payment data
      Returns:
      a ResponseEntity containing a confirmation message