class CmsToXs2aPaymentMapper {

    public CommonPayment mapToXs2aCommonPayment(CommonPaymentData response) {
        return Optional.ofNullable(response)
                   .map(r -> {
                            CommonPayment commonPayment = new CommonPayment();
                            commonPayment.setPaymentId(r.getExternalId());
                            commonPayment.setTransactionStatus(r.getTransactionStatus());
                            commonPayment.setPaymentProduct(r.getPaymentProduct());
                            commonPayment.setPaymentType(r.getPaymentType());
                            commonPayment.setPaymentData(r.getPaymentData());
                            commonPayment.setPsuDataList(r.getPsuData());
                            commonPayment.setStatusChangeTimestamp(r.getStatusChangeTimestamp());
                            commonPayment.setCreationTimestamp(r.getCreationTimestamp());
                            return commonPayment;
                        }
                   )
                   .orElse(null);
    }

}