Package api.mpba.rastvdmy.service.impl
Class PaymentServiceImpl
java.lang.Object
api.mpba.rastvdmy.service.impl.PaymentServiceImpl
- All Implemented Interfaces:
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 Summary
ConstructorDescriptionPaymentServiceImpl
(PaymentRepository paymentRepository, BankAccountRepository accountRepository, CardRepository cardRepository, CurrencyDataService currencyDataService, JwtService jwtService, UserProfileRepository userProfileRepository) Constructor for PaymentServiceImpl. -
Method Summary
Modifier and TypeMethodDescriptioncreateBankTransfer
(jakarta.servlet.http.HttpServletRequest request, UUID accountId, String recipientNumber, BigDecimal amount, String description) Creates a bank transfer payment.createCardPayment
(jakarta.servlet.http.HttpServletRequest request, UUID accountId, UUID cardId) Creates a card payment.getAllPayments
(jakarta.servlet.http.HttpServletRequest request, String bankName, UUID accountId) Retrieves all payments associated with a given bank account or card.getPaymentById
(jakarta.servlet.http.HttpServletRequest request, String bankName, UUID accountId, UUID paymentId) Retrieves a specific payment by its ID.
-
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 usedaccountRepository
- the bank account repository to be usedcardRepository
- the card repository to be usedcurrencyDataService
- the currency data service to be usedjwtService
- the JWT service to be useduserProfileRepository
- 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 interfacePaymentService
- Parameters:
request
- the HTTP request containing user databankName
- the name of the bank associated with the paymentsaccountId
- 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 interfacePaymentService
- Parameters:
request
- the HTTP request containing user databankName
- the name of the bank associated with the paymentaccountId
- the ID of the bank accountpaymentId
- 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 interfacePaymentService
- Parameters:
request
- the HTTP request containing user dataaccountId
- the ID of the bank accountrecipientNumber
- the account number of the recipientamount
- the amount to be transferreddescription
- 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 interfacePaymentService
- Parameters:
request
- the HTTP request containing user dataaccountId
- the ID of the bank accountcardId
- the ID of the card- Returns:
- the created Payment object
- Throws:
Exception
- if an error occurs during payment creation
-