Class PaymentServiceImpl

java.lang.Object
com.bank.payment.services.impl.PaymentServiceImpl
All Implemented Interfaces:
PaymentService

@Service public class PaymentServiceImpl extends Object implements PaymentService
  • Constructor Details

    • PaymentServiceImpl

      public PaymentServiceImpl()
  • Method Details

    • findById

      public PaymentModel findById(Long idPayment)
      Specified by:
      findById in interface PaymentService
    • delete

      public String delete(Long idPayment)
      Specified by:
      delete in interface PaymentService
    • savePayment

      public PaymentModel savePayment(PaymentModel paymentModel)
      Description copied from interface: PaymentService
      Saves a payment model to the database and publishes an event for the payment save and other microservices.

      For example, it can be used to save a payment after analyzing it or processing a direct payment.

      Specified by:
      savePayment in interface PaymentService
      Parameters:
      paymentModel - the payment model to be saved
      Returns:
      PaymentModel - the saved payment model
    • reviewPaymentBeforeProcessing

      public String reviewPaymentBeforeProcessing(Long idAccount, String pixKey, PaymentAnalyzeDto paymentAnalyzeDto)
      Description copied from interface: PaymentService
      Analyzes both accounts (sender and receiver) and the Pix key to ensure that the payment can be processed.

      This method checks if the sender has sufficient balance, if the receiver account exists, and if the Pix key is valid.

      Specified by:
      reviewPaymentBeforeProcessing in interface PaymentService
      Parameters:
      idAccount - the ID of the account making the payment
      pixKey - the Pix key of the receiver
      paymentAnalyzeDto - the DTO containing payment analysis details
      Returns:
      a String message asking the user to confirm the payment or an error message if the analysis fails
    • sendPix

      public void sendPix(ConclusionPaymentDto paymentDto)
      Description copied from interface: PaymentService
      Sends a Pix transactions to the receiver's account after the payment has been analyzed and confirmed.
      Specified by:
      sendPix in interface PaymentService
      Parameters:
      paymentDto - the DTO containing, for example, the payment amount, sender and receiver details
    • directPayment

      public String directPayment(Long idAccount, String pixKey, PaymentDto paymentDto)
      Description copied from interface: PaymentService
      Processes a direct payment by performing the necessary checks and sending the Pix transaction.
      Specified by:
      directPayment in interface PaymentService
      Parameters:
      idAccount - the ID of the account making the payment
      pixKey - the Pix key of the receiver
      paymentDto - the DTO containing payment details
      Returns:
      a String message indicating the result of the direct payment operation