Class PaymentServiceImpl

java.lang.Object
api.mpba.rastvdmy.service.impl.PaymentServiceImpl
All Implemented Interfaces:
PaymentService

@Service public class PaymentServiceImpl extends Object implements PaymentService
Implementation of the PaymentService interface for managing payment operations, including bank transfers and card payments. This service handles the creation, retrieval, and validation of payments while ensuring proper encryption and security.
  • Constructor Details

    • PaymentServiceImpl

      @Autowired public PaymentServiceImpl(PaymentRepository paymentRepository, BankAccountRepository accountRepository, CardRepository cardRepository, CurrencyDataService currencyDataService, JwtService jwtService, UserProfileRepository userProfileRepository)
      Constructor for PaymentServiceImpl.
      Parameters:
      paymentRepository - the payment repository to be used
      accountRepository - the bank account repository to be used
      cardRepository - the card repository to be used
      currencyDataService - the currency data service to be used
      jwtService - the JWT service to be used
      userProfileRepository - the user profile repository to be used
  • Method Details

    • getAllPayments

      public List<Payment> getAllPayments(jakarta.servlet.http.HttpServletRequest request, String bankName, UUID accountId)
      Retrieves all payments associated with a given bank account or card.
      Specified by:
      getAllPayments in interface PaymentService
      Parameters:
      request - the HTTP request containing user data
      bankName - the name of the bank associated with the payments
      accountId - the ID of the bank account
      Returns:
      a list of payments related to the specified account
      Throws:
      ApplicationException - if the bank account is invalid or no payments are found
    • getPaymentById

      public Payment getPaymentById(jakarta.servlet.http.HttpServletRequest request, String bankName, UUID accountId, UUID paymentId)
      Retrieves a specific payment by its ID.
      Specified by:
      getPaymentById in interface PaymentService
      Parameters:
      request - the HTTP request containing user data
      bankName - the name of the bank associated with the payment
      accountId - the ID of the bank account
      paymentId - the ID of the payment to retrieve
      Returns:
      the requested payment
      Throws:
      ApplicationException - if the payment is not found or is not associated with the specified bank
    • createBankTransfer

      public Payment createBankTransfer(jakarta.servlet.http.HttpServletRequest request, UUID accountId, String recipientNumber, BigDecimal amount, String description) throws Exception
      Creates a bank transfer payment.
      Specified by:
      createBankTransfer in interface PaymentService
      Parameters:
      request - the HTTP request containing user data
      accountId - the ID of the bank account
      recipientNumber - the account number of the recipient
      amount - the amount to be transferred
      description - a description for the payment
      Returns:
      the created Payment object
      Throws:
      Exception - if an error occurs during payment creation
    • createCardPayment

      public Payment createCardPayment(jakarta.servlet.http.HttpServletRequest request, UUID accountId, UUID cardId) throws Exception
      Creates a card payment.
      Specified by:
      createCardPayment in interface PaymentService
      Parameters:
      request - the HTTP request containing user data
      accountId - the ID of the bank account
      cardId - the ID of the card
      Returns:
      the created Payment object
      Throws:
      Exception - if an error occurs during payment creation