Package com.bank.payment.services
Interface PaymentService
- All Known Implementing Classes:
PaymentServiceImpl
public interface PaymentService
Interface for Payment Service that defines methods for handling payment operations.
It includes methods for finding, deleting, saving payments, analyzing payments,
sending Pix transactions, and performing direct payments.
- Since:
- 1.0.0
- Version:
- 1.0.0, 06/26/2025
- Author:
- Fernando Cruz Cavina
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiondirectPayment
(Long idAccount, String pixKey, PaymentDto paymentDto) Processes a direct payment by performing the necessary checks and sending the Pix transaction.reviewPaymentBeforeProcessing
(Long idAccount, String pixKey, PaymentAnalyzeDto paymentAnalyzeDto) Analyzes both accounts (sender and receiver) and the Pix key to ensure that the payment can be processed.savePayment
(PaymentModel paymentModel) Saves a payment model to the database and publishes an event for the payment save and other microservices.void
sendPix
(ConclusionPaymentDto paymentDto) Sends a Pix transactions to the receiver's account after the payment has been analyzed and confirmed.
-
Method Details
-
findById
-
delete
-
savePayment
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.
- Parameters:
paymentModel
- the payment model to be saved- Returns:
PaymentModel
- the saved payment model
-
reviewPaymentBeforeProcessing
String reviewPaymentBeforeProcessing(Long idAccount, String pixKey, PaymentAnalyzeDto paymentAnalyzeDto) 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.
- Parameters:
idAccount
- the ID of the account making the paymentpixKey
- the Pix key of the receiverpaymentAnalyzeDto
- 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
Sends a Pix transactions to the receiver's account after the payment has been analyzed and confirmed.- Parameters:
paymentDto
- the DTO containing, for example, the payment amount, sender and receiver details
-
directPayment
Processes a direct payment by performing the necessary checks and sending the Pix transaction.- Parameters:
idAccount
- the ID of the account making the paymentpixKey
- the Pix key of the receiverpaymentDto
- the DTO containing payment details- Returns:
- a String message indicating the result of the direct payment operation
-