class PaymentServiceForAuthorisation {

    public ResponseObject<Xs2aScaStatusResponse> getAuthorisationScaStatus(String paymentId, String authorisationId, PaymentType paymentType, String paymentProduct) {
        ResponseObject<PaymentScaStatus> paymentScaStatusResponse = getPaymentScaStatus(paymentId, authorisationId, paymentType, paymentProduct);
        if (paymentScaStatusResponse.hasError()) {
            return ResponseObject.<Xs2aScaStatusResponse>builder()
                       .fail(paymentScaStatusResponse.getError())
                       .build();
        }

        PaymentScaStatus paymentScaStatus = paymentScaStatusResponse.getBody();
        ScaStatus scaStatus = paymentScaStatus.getScaStatus();

        if (scaStatus.isNotFinalisedStatus()) {
            Xs2aScaStatusResponse response = new Xs2aScaStatusResponse(scaStatus, null);
            return ResponseObject.<Xs2aScaStatusResponse>builder()
                       .body(response)
                       .build();
        }

        ResponseObject<Boolean> beneficiaryFlagResponse = getTrustedBeneficiaryFlag(paymentScaStatus.getPsuIdData(),
                                                                                    paymentId, authorisationId,
                                                                                    paymentScaStatus.getPisCommonPaymentResponse());
        if (beneficiaryFlagResponse.hasError()) {
            return ResponseObject.<Xs2aScaStatusResponse>builder()
                       .fail(beneficiaryFlagResponse.getError())
                       .build();
        }

        Boolean beneficiaryFlag = beneficiaryFlagResponse.getBody();
        Xs2aScaStatusResponse response = new Xs2aScaStatusResponse(scaStatus, beneficiaryFlag);

        return ResponseObject.<Xs2aScaStatusResponse>builder()
                   .body(response)
                   .build();
    }

}