class PisCommonPaymentServiceInternalEncrypted implements PisCommonPaymentServiceEncrypted {

    @Override
    @Transactional
    public CmsResponse<CreatePisCommonPaymentResponse> createCommonPayment(PisPaymentInfo request) {
        CmsResponse<CreatePisCommonPaymentResponse> paymentResponse = pisCommonPaymentService.createCommonPayment(request);

        if (paymentResponse.hasError()) {
            return paymentResponse;
        }

        CreatePisCommonPaymentResponse payment = paymentResponse.getPayload();
        Optional<String> encryptIdOptional = securityDataService.encryptId(payment.getPaymentId());

        if (encryptIdOptional.isEmpty()) {
            log.info("Payment ID: [{}]. Create common payment failed, couldn't encrypt payment id", payment.getPaymentId());
            return CmsResponse.<CreatePisCommonPaymentResponse>builder()
                       .error(TECHNICAL_ERROR)
                       .build();
        }

        return CmsResponse.<CreatePisCommonPaymentResponse>builder()
                   .payload(new CreatePisCommonPaymentResponse(encryptIdOptional.get(), payment.getTppNotificationContentPreferred()))
                   .build();
    }

}