Package com.bank.payment.services.impl
Class PaymentServiceImpl
java.lang.Object
com.bank.payment.services.impl.PaymentServiceImpl
- All Implemented Interfaces:
PaymentService
-
Constructor Summary
Constructors -
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.
-
Constructor Details
-
PaymentServiceImpl
public PaymentServiceImpl()
-
-
Method Details
-
findById
- Specified by:
findById
in interfacePaymentService
-
delete
- Specified by:
delete
in interfacePaymentService
-
savePayment
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 interfacePaymentService
- 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 interfacePaymentService
- 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
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 interfacePaymentService
- Parameters:
paymentDto
- the DTO containing, for example, the payment amount, sender and receiver details
-
directPayment
Description copied from interface:PaymentService
Processes a direct payment by performing the necessary checks and sending the Pix transaction.- Specified by:
directPayment
in interfacePaymentService
- 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
-