class PisCommonPaymentServiceInternal implements PisCommonPaymentService {

    @Override
    @Transactional
    public CmsResponse<Boolean> updateCommonPaymentStatusById(String paymentId, TransactionStatus status) {
        Optional<Boolean> isUpdatedOptional = pisCommonPaymentDataRepository.findByPaymentId(paymentId)
                                                  .map(pisCommonPaymentConfirmationExpirationService::checkAndUpdateOnConfirmationExpiration)
                                                  .filter(pm -> !pm.getTransactionStatus().isFinalisedStatus())
                                                  .map(pmt -> setStatusAndSaveCommonPaymentData(pmt, status))
                                                  .map(con -> con.getTransactionStatus() == status);

        if (isUpdatedOptional.isPresent()) {
            return CmsResponse.<Boolean>builder()
                       .payload(isUpdatedOptional.get())
                       .build();
        }

        log.info("Payment ID: [{}]. Update common payment by ID failed, because payment was not found by the ID",
                 paymentId);
        return CmsResponse.<Boolean>builder()
                   .payload(false)
                   .build();
    }

}